-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathawhere_demo.py
More file actions
60 lines (51 loc) · 1.65 KB
/
Copy pathawhere_demo.py
File metadata and controls
60 lines (51 loc) · 1.65 KB
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
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
from header import AWhereAPI
from menus import Menus
def user_has_credentials():
global api_key
global api_secret
isValid = True
if (not api_key):
print('Error: Missing API Key. \nPlease place your API key in the main script and try again.')
return False
if (not api_secret):
print('Error: Missing API Secret Key. \nPlease pace your Secret key in the main script and try again.')
return False
return isValid
def handle_user_input(user_input, aWhere):
global quit_requested
if user_input == 1:
aWhere.get_fields()
elif user_input == 2:
aWhere.get_fields()
field_id = menu.get_weather_field_id()
aWhere.get_weather_by_id(field_id)
elif user_input == 3:
aWhere.create_test_field()
elif user_input == 4:
aWhere.get_fields()
field_id = menu.get_delete_field_id()
aWhere.delete_field_by_id(field_id)
elif user_input == 0:
quit_requested = True
else:
print('Invalid Selection! Please try again')
quit_requested = False
menu = Menus()
# Enter your Api Key and Secret below:
api_key = ''
api_secret = ''
# Main Entry Point
if user_has_credentials():
aWhere = AWhereAPI(api_key, api_secret)
menu.display_title()
while not quit_requested:
menu.display_menu()
user_input = menu.get_user_input()
menu.clear_screen()
handle_user_input(user_input, aWhere)