forked from naspeh/pusto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
executable file
·45 lines (33 loc) · 1.09 KB
/
manage.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
import logging
import subprocess
import pusto
log = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
def sh(cmd):
log.info(cmd)
code = subprocess.call(cmd, shell=True)
if code:
raise SystemExit(code)
return 0
def process_args():
parser, cmd = pusto.get_parser()
cmd('rsync', help='rsync to server')\
.exe(lambda a: sh(
'rsync -av --delete ./build/ {0}:/opt/pusto/'
'&& rsync -av ./deploy/nginx.conf {0}:/etc/nginx/conf.d/pusto.conf'
'&& ssh {0} "nginx -s reload"'
.format('root@h1.pusto.org')
))
cmd('napokaz', help='napokaz updater')\
.arg('--push', action='store_true')\
.arg('--init', action='store_true')\
.exe(lambda a: sh(
'git remote add napokaz git@github.com:naspeh/napokaz.git'
if a.init else
'git subtree %s -P data/s/napokaz/src napokaz master'
% ('push' if a.push else 'pull --squash')
))
pusto.process(parser=parser)
if __name__ == '__main__':
process_args()