-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
49 lines (45 loc) · 1.85 KB
/
main.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
'''
@Author: Shayne Zamora
@ProjectTitle: AroundME!
@Project: Used as a Google Places Command Line API Tool. Creates a Command Line Interface for Google Places.
'''
#imports and needs:
import googlemaps
import requests
import json
import userFunctions
client = googlemaps.Client(key='AIzaSyAMWWPiiqKIMReF93CjlGf2eaK6K-YMgFI')
##beginning of program
print ('Welcome to AroundME! \nA program where searching is easy!')
try:
while True:
print ('\nDo you want to: ')
print ('\n 1. Find your IP Address? Enter 1')
# Begin function to obtain city
get_ip = 'http://freegeoip.net/json'
ip = requests.get(get_ip)
j = json.loads(ip.text)
city = j['city'] + ', ' + j['region_code']
# End function to get city
print ('\n 2. Find a place near ' + city + '? Enter 2')
print ('\n 3. Find a travel time to a destination from a start location? Enter 3')
print ('\n 4. Enter the number 4 to exit the program!')
try:
selection = int(raw_input('\nEnter a valid value: '))
if selection == 1:
##run get ip address
userFunctions.getIPAddress()
elif selection == 2:
userFunctions.searchForSomething()
elif selection == 3:
userFunctions.getUserTimeTravel()
elif selection == 4:
print ('\nThanks for using AroundME! ~GOODBYE~')
break
########################### ERROR CATCHING ################################
else:
print '\nERROR: Not a valid answer! Please enter a valid number '
except ValueError:
print '\nERROR: Not a valid answer! Please enter a valid number '
except requests.exceptions.ConnectionError:
print '\nERROR: Cannot connect, please check your internet connection and try again'