Skip to content

Commit

Permalink
returning stack trace to web service
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzalo authored and gonzalo committed Apr 10, 2014
1 parent 29c9fc8 commit f13fb87
Showing 1 changed file with 54 additions and 5 deletions.
59 changes: 54 additions & 5 deletions urbansim/server/urbansimd.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import numpy
import pandas as pd
import simplejson
from bottle import Bottle, route, run, response, hook, request, post
from bottle import Bottle, route, run, response, hook, request, post, error

from urbansim.urbansim import modelcompile
from urbansim.utils import misc
Expand Down Expand Up @@ -55,6 +55,11 @@ def enable_cors():
'Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token'


@error(500)
def error500(error):
return error.traceback


@route('/configs')
def list_configs():
def resp():
Expand All @@ -63,12 +68,34 @@ def resp():

def not_modelset(f):
c = open(os.path.join(misc.configs_dir(), f)).read()
print "here comes the file"
print f
print c
c = json.loads(c)
return 'model' in c and c['model'] != 'modelset'
# take into account new (empty) model
return not('model' in c and c['model'] == 'modelset')
return filter(not_modelset, files)
return wrap_request(request, response, resp())


@route('/configs', method="OPTIONS")
def ans_opt():
return {}


@route('/config_new/<configname>', method="PUT")
def new_config(configname):
config = "{}"
f = open(os.path.join(misc.configs_dir(), configname), "w")
f.write(config)
f.close()


@route('/config_new/<configname>', method="OPTIONS")
def ans_opt(configname):
return {}


@route('/config/<configname>', method="GET")
def read_config(configname):
def resp():
Expand All @@ -93,14 +120,19 @@ def resp():
return wrap_request(request, response, resp())


@route('/charts')
@route('/charts', method="GET")
def list_charts():
def resp():
files = os.listdir(misc.charts_dir())
return files
return wrap_request(request, response, resp())


@route('/charts', method="OPTIONS")
def ans_opt():
return {}


@route('/chart/<chartname>', method="GET")
def read_config(chartname):
def resp():
Expand All @@ -127,6 +159,8 @@ def resp():

@route('/chartdata', method=['OPTIONS', 'GET', 'POST'])
def query():
if request.method == "OPTIONS":
return {}
req = request.query.json
if (request.query.callback):
response.content_type = "application/javascript"
Expand Down Expand Up @@ -187,14 +221,19 @@ def get_chart_data(req):
return recs


@route('/maps')
@route('/maps', method="GET")
def list_maps():
def resp():
files = os.listdir(misc.maps_dir())
return files
return wrap_request(request, response, resp())


@route('/maps', method="OPTIONS")
def ans_opt():
return {}


@route('/map/<mapname>', method="GET")
def read_config(mapname):
def resp():
Expand All @@ -219,14 +258,19 @@ def resp():
return wrap_request(request, response, resp())


@route('/reports')
@route('/reports', method="GET")
def list_reports():
def resp():
files = os.listdir(misc.reports_dir())
return files
return wrap_request(request, response, resp())


@route('/reports', method="OPTIONS")
def ans_opt():
return {}


@route('/report/<reportname>', method="GET")
def read_config(reportname):
def resp():
Expand Down Expand Up @@ -309,6 +353,11 @@ def chart_type(c):
return jsonp(request, s)


@route('/charts', method="OPTIONS")
def ans_opt():
return {}


@route('/datasets')
def list_datasets():
def resp():
Expand Down

0 comments on commit f13fb87

Please sign in to comment.