Skip to content

Commit

Permalink
Specify host_mode as parameter rather than actual host address
Browse files Browse the repository at this point in the history
  • Loading branch information
doorleyr committed Jul 14, 2020
1 parent d95e098 commit fd0954b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
12 changes: 8 additions & 4 deletions listen.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@

from statistics import mean

def main(host='https://cityio.media.mit.edu/'):
def main(host_mode='remote'):
reference=json.load(open('./tables/corktown/reference.json'))
if host_mode=='local':
host = 'http://127.0.0.1:5000/'
else:
host = 'https://cityio.media.mit.edu/'
# Individual Indicators
I = InnoIndicator()
P = ProxIndicator(name='proximity', host=host, indicator_type_in='numeric', table_name='corktown')
Expand All @@ -33,7 +37,7 @@ def main(host='https://cityio.media.mit.edu/'):
D]:
indicator.viz_type='bar'

H = Handler('corktown', quietly=False, host=host, reference=reference)
H = Handler('corktown', quietly=False, host_mode=host_mode, reference=reference)

H.add_indicators([
I,
Expand Down Expand Up @@ -89,7 +93,7 @@ def main(host='https://cityio.media.mit.edu/'):

if __name__ == '__main__':
if len(sys.argv)>1:
host=sys.argv[1]
main(host=host)
host_mode=sys.argv[1]
main(host_mode=host_mode)
else:
main()
2 changes: 1 addition & 1 deletion tables/corktown/mobility_sim_output.json

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ class Handler:
quietly : boolean (default=True)
If True, it will show the status of every API call.
'''
def __init__(self, table_name, GEOGRIDDATA_varname = 'GEOGRIDDATA', GEOGRID_varname = 'GEOGRID', quietly=True, host = 'https://cityio.media.mit.edu/', reference=None):
def __init__(self, table_name, GEOGRIDDATA_varname = 'GEOGRIDDATA', GEOGRID_varname = 'GEOGRID', quietly=True, host_mode ='remote' , reference=None):

self.host = host
if host_mode=='local':
self.host = 'http://127.0.0.1:5000/'
else:
self.host = 'https://cityio.media.mit.edu/'
self.table_name = table_name
self.quietly = quietly

Expand Down Expand Up @@ -529,7 +532,8 @@ def perform_update(self,grid_hash_id=None,append=True):

if len(new_values['heatmap']['features'])!=0:
r = requests.post(self.cityIO_post_url+'/access', data = json.dumps(new_values['heatmap']))

if not self.quietly:
print('Done with update')
self.grid_hash_id = grid_hash_id

def rollback(self):
Expand All @@ -543,7 +547,7 @@ def rollback(self):
r = requests.post(self.cityIO_post_url+'/indicators', data = json.dumps(self.previous_indicators))
r = requests.post(self.cityIO_post_url+'/access', data = json.dumps(self.previous_access))

def listen(self,showFront=True,append=False):
def listen(self,showFront=False,append=False):
'''
Listen for changes in the table's geogrid and update all indicators accordingly.
You can use the update_package method to see the object that will be posted to the table.
Expand Down

0 comments on commit fd0954b

Please sign in to comment.