* [PATCH rest-dbus] Fix pep8 errors
@ 2016-02-07 4:30 OpenBMC Patches
2016-02-07 4:30 ` OpenBMC Patches
0 siblings, 1 reply; 4+ messages in thread
From: OpenBMC Patches @ 2016-02-07 4:30 UTC (permalink / raw)
To: openbmc
https://github.com/openbmc/rest-dbus/pull/6
Manjunath A Kumatagi (1):
Fix pep8 errors
rest-dbus | 29 ++++++++++++++++++-----------
setup.py | 2 +-
2 files changed, 19 insertions(+), 12 deletions(-)
--
2.6.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH rest-dbus] Fix pep8 errors
2016-02-07 4:30 [PATCH rest-dbus] Fix pep8 errors OpenBMC Patches
@ 2016-02-07 4:30 ` OpenBMC Patches
2016-02-08 7:27 ` Stewart Smith
0 siblings, 1 reply; 4+ messages in thread
From: OpenBMC Patches @ 2016-02-07 4:30 UTC (permalink / raw)
To: openbmc
From: Manjunath A Kumatagi <mkumatag@in.ibm.com>
---
rest-dbus | 29 ++++++++++++++++++-----------
setup.py | 2 +-
2 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/rest-dbus b/rest-dbus
index d756dc8..8d759f6 100644
--- a/rest-dbus
+++ b/rest-dbus
@@ -13,17 +13,22 @@ busses = {
'system': dbus.SystemBus,
}
+
class DBusRestException(Exception):
+
def __init__(self, message, code=403):
self.code = code
super(DBusRestException, self).__init__(message)
-
+
+
class DBusRestResponse(object):
def render(self, handler):
raise NotImplemented()
+
class DBusRestJSONResponse(DBusRestResponse):
+
def __init__(self, data):
self.data = data
@@ -33,6 +38,7 @@ class DBusRestJSONResponse(DBusRestResponse):
handler.end_headers()
handler.wfile.write(json.dumps(self.data, indent=2, sort_keys=True))
+
class DBusRestResourceResponse(DBusRestResponse):
mime_map = {
'html': 'text/html',
@@ -42,12 +48,12 @@ class DBusRestResourceResponse(DBusRestResponse):
'gif': 'image/gif',
}
resource_base = os.path.join(sys.prefix, 'share',
- os.path.basename(__file__), 'resources')
+ os.path.basename(__file__), 'resources')
def __init__(self, name):
(_, ext) = os.path.splitext(name)
self.content_type = self.mime_map.get(ext[1:],
- 'application/octet-stream')
+ 'application/octet-stream')
try:
self.data = open(os.path.join(self.resource_base, name)).read()
except IOError:
@@ -56,11 +62,13 @@ class DBusRestResourceResponse(DBusRestResponse):
def render(self, handler):
handler.send_response(200)
handler.send_header('Content-Type',
- self.content_type + '; charset=utf-8')
+ self.content_type + '; charset=utf-8')
handler.end_headers()
handler.wfile.write(self.data)
+
class DBusRestErrorResonse(DBusRestResponse):
+
def __init__(self, ex):
self.ex = ex
@@ -80,7 +88,7 @@ class DBusRestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def handle_root(self):
return DBusRestJSONResponse({
'status': 'ok',
- 'busses': [ {'name': x} for x in busses.keys() ],
+ 'busses': [{'name': x} for x in busses.keys()],
})
def handle_bus(self):
@@ -88,7 +96,7 @@ class DBusRestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
objects.sort()
return DBusRestJSONResponse({
'status': 'ok',
- 'objects': [ {'name': x} for x in objects ],
+ 'objects': [{'name': x} for x in objects],
})
def get_object_or_404(self, bus_name, obj_path):
@@ -100,7 +108,7 @@ class DBusRestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def handle_service(self, bus_name):
data = IntrospectionParser(bus_name, self.bus).introspect()
- objects = [ { 'path': x } for x in data.iterkeys() ]
+ objects = [{'path': x} for x in data.iterkeys()]
return DBusRestJSONResponse({
'status': 'ok',
@@ -141,8 +149,7 @@ class DBusRestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
methods = []
signals = []
base_uri = ('/bus/' + self.bus_name + '/' + obj.requested_bus_name +
- obj.object_path + '/' + interface_name);
-
+ obj.object_path + '/' + interface_name)
def parse_method(node):
args = []
@@ -237,7 +244,7 @@ class DBusRestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
if not parts:
return self.handle_object(obj)
-
+
interface_name = parts.pop(0)
if not parts:
return self.handle_interface(obj, interface_name)
@@ -322,7 +329,7 @@ class DBusRestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
if not parts:
raise DBusRestException("Not Found", 404)
-
+
interface_name = parts.pop(0)
if not parts:
raise DBusRestException("Not Found", 404)
diff --git a/setup.py b/setup.py
index 33d8567..2c35fc4 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
from distutils.core import setup
from os import listdir
-resources = [ 'resources/%s' %(x) for x in listdir('resources') ]
+resources = ['resources/%s' % (x) for x in listdir('resources')]
setup(name='rest-dbus',
version='1.0',
scripts=['rest-dbus'],
--
2.6.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH rest-dbus] Fix pep8 errors
2016-02-07 4:30 ` OpenBMC Patches
@ 2016-02-08 7:27 ` Stewart Smith
2016-02-08 16:53 ` Manjunath A Kumatagi
0 siblings, 1 reply; 4+ messages in thread
From: Stewart Smith @ 2016-02-08 7:27 UTC (permalink / raw)
To: OpenBMC Patches, openbmc
OpenBMC Patches <openbmc-patches@stwcx.xyz> writes:
> From: Manjunath A Kumatagi <mkumatag@in.ibm.com>
Looks okay, I think commit message should mention that this is just a
whitespace fix though.
--
Stewart Smith
OPAL Architect, IBM.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH rest-dbus] Fix pep8 errors
2016-02-08 7:27 ` Stewart Smith
@ 2016-02-08 16:53 ` Manjunath A Kumatagi
0 siblings, 0 replies; 4+ messages in thread
From: Manjunath A Kumatagi @ 2016-02-08 16:53 UTC (permalink / raw)
To: Stewart Smith; +Cc: OpenBMC Patches, openbmc
[-- Attachment #1.1: Type: text/plain, Size: 760 bytes --]
Mentioned comment in the PR.
Thanks,
Manjunath.
From: Stewart Smith <stewart@linux.vnet.ibm.com>
To: OpenBMC Patches <openbmc-patches@stwcx.xyz>,
openbmc@lists.ozlabs.org
Date: 02/08/2016 12:58 PM
Subject: Re: [PATCH rest-dbus] Fix pep8 errors
Sent by: "openbmc" <openbmc-bounces
+mkumatag=in.ibm.com@lists.ozlabs.org>
OpenBMC Patches <openbmc-patches@stwcx.xyz> writes:
> From: Manjunath A Kumatagi <mkumatag@in.ibm.com>
Looks okay, I think commit message should mention that this is just a
whitespace fix though.
--
Stewart Smith
OPAL Architect, IBM.
_______________________________________________
openbmc mailing list
openbmc@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/openbmc
[-- Attachment #1.2: Type: text/html, Size: 1783 bytes --]
[-- Attachment #2: graycol.gif --]
[-- Type: image/gif, Size: 105 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-08 17:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-07 4:30 [PATCH rest-dbus] Fix pep8 errors OpenBMC Patches
2016-02-07 4:30 ` OpenBMC Patches
2016-02-08 7:27 ` Stewart Smith
2016-02-08 16:53 ` Manjunath A Kumatagi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.