forked from JasonThomasData/text_analysis_steam_reviews
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_app.py
56 lines (41 loc) · 1.38 KB
/
run_app.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
#!/usr/bin/python3
import sys
from application import scraper, database_manager, train_classify_data
if int(sys.version_info.major) < 3:
python_required_message = 'You must use Python3 with this program, exiting... \n'
sys.stdout.write(python_required_message)
sys.exit()
def inputs_feedback():
feedback = '''
Wrong number of inputs. These are valid:
- python3 run_app.py scrape_reviews continue OR
- python3 run_app.py scrape_reviews new OR
- python3 run_app.py classify_data OR
- python3 run_app.py make_report OR
'''
return feedback
def process_inputs(inputs):
'''
Check the inputs are valid call load the appropriate functions.
'''
db_location = 'database_steam_reviews.db'
input_length = len(inputs)
if inputs[1] == 'scrape_reviews':
if input_length == 2:
scraper.get_reviews(db_location)
elif inputs[2] == 'continue':
scraper.get_reviews(db_location)
elif inputs[2] == 'new':
database_manager.drop_steam_reviews()
scraper.get_reviews(db_location)
else:
return inputs_feedback()
elif inputs[1] == 'classify_data':
train_classify_data.classify_reviews(db_location)
else:
return inputs_feedback()
def receive_inputs():
inputs = sys.argv
return process_inputs(inputs)
print(receive_inputs())
sys.exit()