forked from ajdavis/proporti.onl
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy.py
executable file
·46 lines (38 loc) · 1.15 KB
/
deploy.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
46
#!/usr/bin/env python
import argparse
import os
import requests
my_domain = "mastodonproportional.pythonanywhere.com"
username = "mastodonproportional"
parser = argparse.ArgumentParser()
parser.add_argument(
"token",
metavar="PYTHON_ANYWHERE_TOKEN",
help="A Python Anywhere API token for your account",
)
args = parser.parse_args()
print("Rsync files....")
os.system(
"rsync -rv --exclude '*.pyc' *"
" mastodonproportional@ssh.pythonanywhere.com:mastodonproportional.pythonanywhere.com"
)
print("Reinstall dependencies....")
os.system(
"ssh mastodonproportional@ssh.pythonanywhere.com"
" '~/proporti.onl.venv/bin/pip install -U -r "
"~/mastodonproportional.pythonanywhere.com/requirements.txt'"
)
print("Restarting....")
uri = "https://www.pythonanywhere.com/api/v0/user/{uname}/webapps/{dom}/reload/"
response = requests.post(
uri.format(uname=username, dom=my_domain),
headers={"Authorization": "Token {token}".format(token=args.token)},
)
if response.status_code == 200:
print("All OK")
else:
print(
"Got unexpected status code {}: {!r}".format(
response.status_code, response.content
)
)