-
Notifications
You must be signed in to change notification settings - Fork 0
/
pavement.py
68 lines (48 loc) · 1.27 KB
/
pavement.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
65
66
67
# coding: utf-8
from __future__ import absolute_import
import sys
sys.path = ['.'] + sys.path
import os
from paver.easy import task
from paver.easy import sh
from paver.easy import consume_args
import cult.ngram as ngram
from cult.worker_server import worker_server
@task
def run_worker_server():
clean()
if 'AWS_ACCESS_KEY_ID' not in os.environ:
print 'must have AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY on env'
exit()
if 'AWS_SECRET_ACCESS_KEY' not in os.environ:
print 'must have AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY on env'
exit()
worker_server()
clean()
@consume_args
@task
def clear_db_year(args):
clean()
if len(args) != 1:
print 'too few arguments - use: paver clear_db_year year'
exit()
year = int(args[0])
ngram.clear_db_year(year)
clean()
@consume_args
@task
def top(args):
clean()
if len(args) != 3:
print 'too few arguments - use: paver top year gram_size how_many'
exit()
year = int(args[0])
gram_size = int(args[1])
how_many = int(args[2])
ngram.top(gram_size, how_many, year)
clean()
@task
def clean():
sh('find . -name "__pycache__" -delete')
sh('find . -name "*.pyc" -delete')
sh('find . -name "*~" -delete')