예제 #1
0
def app(environ, start_response):
	try:
		start_response('200 OK', [('Content-Type', 'text/html')])
		form = cgi.FieldStorage(environ['wsgi.input'], environ=environ)
		dform = create_roundware_arguments(form)
		if not dform.has_key('operation') or dform['operation'] == '':
			result = True
		elif dform['operation'] == "move_listener" and dform['stream_url'] == '(null)':
			result = True
		else:
			result = server.catch_errors(dform)

		try: db.insert_event(form)
		except: pass

		if type(result) == type({}):
			if result.has_key('STREAM_URL'):
				result['RESULT'] = result['STREAM_URL']
			return json.dumps(result, sort_keys=True, indent=4)
		else:
			return json.dumps({ "RESULT" : result }, sort_keys=True, indent=4)
	except:
		return json.dumps({
			"ERROR_MESSAGE" : "An uncaught exception was raised. See traceback for details.",
			"TRACEBACK" : traceback.format_exc(),
		})
예제 #2
0
#!/usr/bin/env python

import cgi, cgitb 
from roundwared import server
import json

print "Content-type: text/plain"
print
# The following like is what should be here. However the OceanVoices client
# is still expecting a different protocol and thus the hack at the end of this
# file is in place to accomodate it.
#print server.webservice_main(server.form_to_dict(cgi.FieldStorage()))

# BEGIN HACK
val = server.catch_errors(server.form_to_dict(cgi.FieldStorage()))
if val.has_key('STREAM_URL'):
	print '"'+val['STREAM_URL']+'"';
else:
	print json.dumps(val, sort_keys=True, indent=4)
# END HACK