-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
51 lines (37 loc) · 1.1 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
46
47
48
49
50
51
from crawler.spider import JoySpider
from data.transformation import transform_csv
import logging
import click
# Logger Setup
log_fmt = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
log_level = 'INFO'
logging.basicConfig(level=log_level, format=log_fmt)
logger = logging.getLogger(__name__)
@click.group()
def manage():
pass
@click.command()
def single():
"""Single run - save data to csv"""
JoySpider().single_run()
@click.command()
@click.option('--count', type=int, help='How many times to run')
def counted(count):
"""Counted run - save data to csv"""
JoySpider().counted_run(count)
@click.command()
@click.option('--days', type=int, help='Days to continue running')
@click.option('--hours', type=int, help='Hours to continue running')
def timed(days, hours):
"""Timed run - save data to csv"""
JoySpider().timed_run(days, hours)
@click.command()
def transform_data():
"""Transform CSV"""
transform_csv()
manage.add_command(single)
manage.add_command(counted)
manage.add_command(timed)
manage.add_command(transform_data)
if __name__ == '__main__':
manage()