forked from AudiovisualMetadataPlatform/amppd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
amp_hook_post.py
executable file
·34 lines (27 loc) · 949 Bytes
/
amp_hook_post.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/env python3
from amp.logging import setup_logging
import argparse
import logging
import zipfile
import shutil
import os
from pathlib import Path
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--debug', default=False, action='store_true', help="Enable debugging")
parser.add_argument('install_path', help="Where the package will be installed")
args = parser.parse_args()
setup_logging(None, args.debug)
# manually deploy the servlet if it is the UI or REST
amp_root = Path(os.environ['AMP_ROOT'])
logging.info("Deploying war file")
warfile = amp_root / 'tomcat/webapps/rest.war'
deployroot = amp_root / 'tomcat/webapps/rest'
# remove everything in the deploy root
if deployroot.exists():
shutil.rmtree(deployroot)
with zipfile.ZipFile(warfile, 'r') as zfile:
zfile.extractall(deployroot)
warfile.unlink()
if __name__ == "__main__":
main()