summaryrefslogtreecommitdiffstats
path: root/echo
diff options
context:
space:
mode:
authorZiad Sawalha <github@highbridgellc.com>2011-04-20 23:45:07 -0500
committerZiad Sawalha <github@highbridgellc.com>2011-04-20 23:45:07 -0500
commit415ea9d5a64de8295fa2847f5f3fd8f9b974cfc4 (patch)
treef8e6f7011f04ad16b699ac2201ae514d89cf3996 /echo
parent9790c7258c89b5fbf21b159a6cd5a2290f89c2d3 (diff)
downloadkeystone-415ea9d5a64de8295fa2847f5f3fd8f9b974cfc4.tar.gz
keystone-415ea9d5a64de8295fa2847f5f3fd8f9b974cfc4.tar.xz
keystone-415ea9d5a64de8295fa2847f5f3fd8f9b974cfc4.zip
PEP-8 for echo.py
Diffstat (limited to 'echo')
-rw-r--r--echo/echo/echo.py50
1 files changed, 27 insertions, 23 deletions
diff --git a/echo/echo/echo.py b/echo/echo/echo.py
index bf9271ec..81fd492f 100644
--- a/echo/echo/echo.py
+++ b/echo/echo/echo.py
@@ -25,14 +25,17 @@ except ImportError:
import json
import urllib
+
"""
Echo: a dummy service for OpenStack auth testing. It returns request info.
"""
+
+
class EchoApp(object):
def __init__(self, environ, start_response):
- self.envr = environ
+ self.envr = environ
self.start = start_response
- self.dom = self.toDOM(environ)
+ self.dom = self.toDOM(environ)
self.transform = etree.XSLT(etree.parse("xsl/echo.xsl"))
def __iter__(self):
@@ -41,7 +44,7 @@ class EchoApp(object):
str(' ') + '/'
return HTTPUseProxy(location=proxy_location)(env, start_response)
- accept = self.envr.get("HTTP_ACCEPT","application/json")
+ accept = self.envr.get("HTTP_ACCEPT", "application/json")
if accept == "application/xml":
return self.toXML()
else:
@@ -49,11 +52,11 @@ class EchoApp(object):
def toJSON(self):
self.start('200 OK', [('Content-Type', 'application/json')])
- token = str(self.envr.get("HTTP_X_AUTH_TOKEN",""))
-
- if token !='':
- res=self.ValidateToken({'type':'json','token':token})
- if int(res['response']['status'])==200 :
+ token = str(self.envr.get("HTTP_X_AUTH_TOKEN", ""))
+
+ if token != '':
+ res = self.ValidateToken({'type': 'json', 'token': token})
+ if int(res['response']['status']) == 200:
yield str(res['content'])
else:
pass
@@ -63,7 +66,7 @@ class EchoApp(object):
def toXML(self):
self.start('200 OK', [('Content-Type', 'application/xml')])
- yield etree.tostring (self.dom)
+ yield etree.tostring(self.dom)
def toDOM(self, environ):
echo = etree.Element("{http://docs.openstack.org/echo/api/v1.0}echo",
@@ -71,33 +74,34 @@ class EchoApp(object):
pathInfo=environ["PATH_INFO"],
queryString=environ.get('QUERY_STRING', ""))
content = etree.Element(
- "{http://docs.openstack.org/echo/api/v1.0}content")
- content.set ("type", environ["CONTENT_TYPE"])
+ "{http://docs.openstack.org/echo/api/v1.0}content")
+ content.set("type", environ["CONTENT_TYPE"])
content.text = ""
inReq = environ["wsgi.input"]
for line in inReq:
content.text = content.text + line
- echo.append (content)
+ echo.append(content)
return echo
-
+
#def ValidateToken(self,params):
# if params['token']:
- # http=Http()
+ # http = Http()
# url = "http://localhost:8080/token/"+str(params['token'])
# body = {}
# headers = {
- # "Accept" : "application/json",
- # "Content-Type": "application/json"}
- # response, content = http.request(url, 'GET', headers=headers,
- # body=urllib.urlencode(body))
- # return {'response':response,'content':content}
+ # "Accept": "application/json",
+ # "Content-Type": "application/json"}
+ # response, content = http.request(url, 'GET', headers=headers,
+ # body = urllib.urlencode(body))
+ # return {'response': response, 'content': content}
# else:
# return abort(401, "No Token Found!")
-
-def app_factory (global_conf, **local_conf):
- return EchoApp
+
+def app_factory(global_conf, **local_conf):
+ return EchoApp
+
if __name__ == "__main__":
app = loadapp("config:echo.ini", relative_to=".", \
- global_conf={"log_name":"echo.log"})
+ global_conf={"log_name": "echo.log"})
wsgi.server(eventlet.listen(('', 8090)), app)