forked from aWhereAPI/API-Code-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenus.py
More file actions
84 lines (68 loc) · 3.08 KB
/
Copy pathmenus.py
File metadata and controls
84 lines (68 loc) · 3.08 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
from builtins import int
from builtins import input
from future import standard_library
standard_library.install_aliases()
from builtins import object
import os
import platform
class Menus(object):
def __init__(self, clear='clear', readLine='read'):
# Set the clear and pause command based on the running OS
self.clear = clear
self.readLine = readLine
operatingSystem = platform.system()
if operatingSystem == 'Windows':
self.clear = 'cls'
self.readLine = 'pause'
def clear_screen(self):
os.system(self.clear)
def get_delete_field_id(self):
print('Please type in the ID of the field you wish to delete.')
user_choice = input()
if not user_choice:
print('Input cannot be empty/null. Please try again.')
self.get_delete_field_id()
return user_choice
def get_weather_field_id(self):
print('Please type in the ID of the field you wish to view.')
user_choice = input()
if not user_choice:
print('Input cannot be empty/null. Please try again.')
self.get_delete_field_id()
return user_choice
def display_title(self):
# Clear the terminal screen and displays a title bar
os.system(self.clear)
print('\t\t**********************************************')
print('\t\t**** aWhere API Python Demo Application ****')
print('\t\t**********************************************')
print('\n')
print('This python demo is intended to display basic examples of how you\r')
print('can interact with the aWhere API Platform. \n')
print('The application was written in Python 3 but it should be backwards \r')
print('compatible with Python 2. It uses the "requests" library to perform HTTP requests.\n')
print('To continue, you\'ll need to have already created a Developer \r')
print('profile via our Developer Community.')
print('\n\t Register here ---> https://developer.awhere.com/api/get-started\n')
print('Next, you\'ll need to login to your profile and create an app.\r')
print('Upon creation of your app you\'ll be provided two keys, a secret key and an API key.\n\n')
print('Be sure to enter your keys in the awhere_demo.py file!')
os.system(self.readLine)
os.system(self.clear)
def display_menu(self):
print('\n')
print('Please input one of the following options and then press "Enter"\n')
print('\t 1. [GET] Get all fields associated with your account')
print('\t 2. [GET] Get Weather (Forecast, Norms and Observations) for an existing field')
print('\t 3. [POST] Create a test field')
print('\t 4. [DELETE] Delete a field')
print('\t 0. Quit ')
def get_user_input(self):
user_choice = input()
return int(user_choice)
def os_pause(self):
os.system(self.readLine)