From: Danny Al-Gaaf Date: Tue, 3 Mar 2015 10:23:14 +0000 (+0100) Subject: ceph_rest_api.py: fix pep8 whitespace issues X-Git-Tag: v9.0.0~219^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e13d4dfe34747d6166ec829ce0e43a1622c487e6;p=ceph.git ceph_rest_api.py: fix pep8 whitespace issues Fixes for: - E226 missing whitespace around arithmetic operator - E231 missing whitespace after ':' and ',' - E265 block comment should start with '# Signed-off-by: Danny Al-Gaaf --- diff --git a/src/pybind/ceph_rest_api.py b/src/pybind/ceph_rest_api.py index e49227d2688f..04bafe0d5243 100755 --- a/src/pybind/ceph_rest_api.py +++ b/src/pybind/ceph_rest_api.py @@ -34,11 +34,11 @@ APPNAME = '__main__' app = flask.Flask(APPNAME) LOGLEVELS = { - 'critical':logging.CRITICAL, - 'error':logging.ERROR, - 'warning':logging.WARNING, - 'info':logging.INFO, - 'debug':logging.DEBUG, + 'critical': logging.CRITICAL, + 'error': logging.ERROR, + 'warning': logging.WARNING, + 'info': logging.INFO, + 'debug': logging.DEBUG, } @@ -61,7 +61,7 @@ def find_up_osd(app): return int(osds[-1]) -METHOD_DICT = {'r':['GET'], 'w':['PUT', 'DELETE']} +METHOD_DICT = {'r': ['GET'], 'w': ['PUT', 'DELETE']} def api_setup(app, conf, cluster, clientname, clientid, args): @@ -74,7 +74,7 @@ def api_setup(app, conf, cluster, clientname, clientid, args): signatures, module, perms, and help; stuff them away in the app.ceph_urls dict. Also save app.ceph_sigdict for help() handling. ''' - def get_command_descriptions(cluster, target=('mon','')): + def get_command_descriptions(cluster, target=('mon', '')): ret, outbuf, outs = json_command(cluster, target, prefix='get_command_descriptions', timeout=30) @@ -173,12 +173,12 @@ def api_setup(app, conf, cluster, clientname, clientid, args): for k in METHOD_DICT.iterkeys(): if k in perm: methods = METHOD_DICT[k] - urldict = {'paramsig':params, - 'help':cmddict['help'], - 'module':cmddict['module'], - 'perm':perm, - 'flavor':flavor, - 'methods':methods, + urldict = {'paramsig': params, + 'help': cmddict['help'], + 'module': cmddict['module'], + 'perm': perm, + 'flavor': flavor, + 'methods': methods, } # app.ceph_urls contains a list of urldicts (usually only one long) @@ -218,7 +218,7 @@ def generate_url_and_params(app, sig, flavor): # tack it onto the front of sig if flavor == 'tell': tellsig = parse_funcsig(['tell', - {'name':'target', 'type':'CephOsdName'}]) + {'name': 'target', 'type': 'CephOsdName'}]) sig = tellsig + sig for desc in sig: @@ -276,7 +276,7 @@ def show_human_help(prefix): # XXX There ought to be a better discovery mechanism than an HTML table s = '' - permmap = {'r':'GET', 'rw':'PUT', 'rx':'GET', 'rwx':'PUT'} + permmap = {'r': 'GET', 'rw': 'PUT', 'rx': 'GET', 'rwx': 'PUT'} line = '' for cmdsig in sorted(app.ceph_sigdict.itervalues(), cmp=descsort): concise = concise_sig(cmdsig['sig']) @@ -329,8 +329,8 @@ def make_response(fmt, output, statusmsg, errorcode): if 'json' in fmt: try: native_output = json.loads(output or '[]') - response = json.dumps({"output":native_output, - "status":statusmsg}) + response = json.dumps({"output": native_output, + "status": statusmsg}) except: return flask.make_response("Error decoding JSON from " + output, 500) @@ -339,13 +339,13 @@ def make_response(fmt, output, statusmsg, errorcode): # one is tempted to do this with xml.etree, but figuring out how # to 'un-XML' the XML-dumped output so it can be reassembled into # a piece of the tree here is beyond me right now. - #ET = xml.etree.ElementTree - #resp_elem = ET.Element('response') - #o = ET.SubElement(resp_elem, 'output') - #o.text = output - #s = ET.SubElement(resp_elem, 'status') - #s.text = statusmsg - #response = ET.tostring(resp_elem) + # ET = xml.etree.ElementTree + # resp_elem = ET.Element('response') + # o = ET.SubElement(resp_elem, 'output') + # o.text = output + # s = ET.SubElement(resp_elem, 'status') + # s.text = statusmsg + # response = ET.tostring(resp_elem) response = ''' @@ -380,7 +380,7 @@ def handler(catchall_path=None, fmt=None, target=None): if not ep.startswith(app.ceph_baseurl): return make_response(fmt, '', 'Page not found', 404) - rel_ep = ep[len(app.ceph_baseurl)+1:] + rel_ep = ep[len(app.ceph_baseurl) + 1:] # Extensions override Accept: headers override defaults if not fmt: @@ -488,7 +488,7 @@ def handler(catchall_path=None, fmt=None, target=None): response = make_response(fmt, outbuf, outs or 'OK', 200) if fmt: - contenttype = 'application/' + fmt.replace('-pretty','') + contenttype = 'application/' + fmt.replace('-pretty', '') else: contenttype = 'text/plain' response.headers['Content-Type'] = contenttype
Possible commands:MethodDescription