forked from xykonur/GateOne
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_and_run_gateone.py
executable file
·45 lines (38 loc) · 1.43 KB
/
update_and_run_gateone.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
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python
"""
Checks if Gate One is up-to-date inside the container by performing a
`git pull`. If new code was pulled it will be automatically installed via
`python setup.py install`
Once that's done it will automatically run the 'gateone' command; passing it any
arguments that were passed to this script.
To disable the automatic update mechanism simply pass --noupdate as a command
line argument to this script.
.. note::
This script will also update the Tornado framework via the pip command.
"""
import os, sys
try:
from commands import getstatusoutput
except ImportError: # Python 3
from subprocess import getstatusoutput
if __name__ == "__main__":
go_args = sys.argv[1:]
os.chdir('/gateone/GateOne')
if '--noupdate' not in go_args:
retcode, output = getstatusoutput('git pull')
if 'up-to-date' in output:
print("Gate One is already up-to-date")
else:
print("Installing the latest code...")
retcode, output = getstatusoutput('python setup.py install')
if retcode == 0:
print("Gate One has been updated.")
else:
print("Encountered a problem trying to install/upgrade Gate One...")
print(output)
sys.exit(1)
else:
go_args.remove('--noupdate')
os.execvp('/usr/bin/python', [
'/usr/bin/python', '/usr/local/bin/gateone'] + go_args)
os._exit(0)