-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
39 lines (31 loc) · 962 Bytes
/
fabfile.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
import json
import sys
import requests
from invoke import task
@task(name="reload")
def _reload(c):
"""Restart the web-app."""
with open(".pythonanywhere.json", "r") as f:
# Has keys api_token, username, and domain_name.
config = json.load(f)
print("Reloading the WSGI app.")
response = requests.post(
"https://www.pythonanywhere.com/api/v0/user/{username}/webapps/{domain_name}/reload/".format(
**config
),
headers={
"Authorization": "Token " + config["api_token"],
},
)
if response.status_code != 200:
print("Reloading the WSGI app failed.")
sys.exit(1)
@task(post=[_reload])
def deploy(c):
"""Deploy a new version of to-rss."""
with c.cd("to-rss"):
print("Fetching new code.")
c.run("git fetch")
c.run("git reset --hard origin/master")
print("Cleaning old Python files.")
c.run("pyclean .")