-
Notifications
You must be signed in to change notification settings - Fork 3
/
fabfile.py
64 lines (53 loc) · 2.01 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from __future__ import with_statement
import os
import time
import datetime
import logging
from fabric.operations import prompt
from fabric.api import *
from fabric.contrib.console import confirm
from fabric.colors import green
logger = logging.getLogger("root")
logging.basicConfig(
format = "\033[1;36m%(levelname)s: %(filename)s (def %(funcName)s %(lineno)s): \033[1;37m %(message)s",
level=logging.DEBUG
)
# development functions
def run():
# runs local dev server
local("python manage.py runserver")
def test():
# shortcut for running tests
local("python manage.py test calfire_tracker")
def scrape():
# production function to manually run the scraper in local environment
local("python manage.py scraper_wildfires")
def updateids():
local("python manage.py update_fire_ids")
def schema():
local("python manage.py schemamigration calfire_tracker --auto")
def localmigrate():
local("python manage.py migrate calfire_tracker")
def localtweets():
# production function to manually poll twitter in local environment
local("python manage.py tweepy_to_db")
def localfixture_dump(model=''):
# dumps fixtures file of wildfires in the database
# ex usage:
# fab local_fixture_dump:'calwildfire'
# fab local_fixture_dump:'wildfireupdate'
# fab local_fixture_dump:'wildfiretweet'
# fab local_fixture_dump:'wildfireannualreview'
# fab local_fixture_dump:'wildfiredisplaycontent'
local("python manage.py dumpdata calfire_tracker.%s --indent=2 > bak_%s.json" % (model, model))
def localfixture_load(model=''):
# dumps fixtures file of wildfires in the database
# ex usage:
# fab local_fixture_load:'calwildfire'
# fab local_fixture_load:'wildfireupdate'
# fab local_fixture_load:'wildfiretweet'
# fab local_fixture_load:'wildfireannualreview'
# fab local_fixture_load:'wildfiredisplaycontent'
local("python manage.py loaddata bak_%s.json" % (model))
def __env_cmd(cmd):
return env.bin_root + cmd