forked from minimaxir/facebook-page-post-scraper
-
Notifications
You must be signed in to change notification settings - Fork 2
/
tasks.py
90 lines (70 loc) · 1.74 KB
/
tasks.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from invoke import task
# BASICS #
@task()
def run(c):
"""
Collects all pages in entidades.csv
"""
c.run('python3 -m scraper.collector')
@task
def autotoken(c):
"""
Open Facebook Developers web page so that the user can
take a new token and update config.ini file
"""
c.run('python3 -m scraper.token_manager')
@task
def createconfig(c):
"""
Creates config.ini in scraper dir with the expected way
to use it
"""
c.run('echo "[DEFAULT]\ntoken = YOURTOKENHERE" >./scraper/config.ini')
@task
def chromedriver(c):
"""
Install chromedriver on Linux to get the token automatically
"""
print('Use make chromedriver for now!')
@task
def clean(c):
"""
Removes all json files
"""
c.run('rm -rf ./json')
c.run('rm -rf ./htmlcov')
c.run('rm -rf ./.coverage')
c.run('rm -rf ./json/')
# TESTING #
@task(clean)
def test(c):
"""
Runs the tests using green3
"""
c.run('green3 -vv')
@task(pre=clean)
def cov(c):
"""
Checks test coverage for the code
"""
c.run('coverage run -m py.test tests/test_page_scraper.py tests/test_token_manager.py')
c.run('coverage report -m scraper/page_scraper.py scraper/token_manager.py')
c.run('coverage html scraper/page_scraper.py scraper/token_manager.py')
@task
def style(c):
"""
Checks if your code is following PEP8
"""
c.run('pycodestyle tests/. scraper/. server/. --ignore=E402,W504,E127')
# @task(pre=[style, clean])
# def full(c):
# """
# Runs tests, checks code coverage and PEP8
# """
# c.run('python3 -m scraper.collector')
@task(pre=[style, clean])
def travis(c):
"""
What runs on Travis CI
"""
c.run('green3 tests/test_page_scraper_unit.py -vv -f')