]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr: use enumerate() for accessing index in a loop
authorKefu Chai <kchai@redhat.com>
Thu, 2 May 2019 14:20:16 +0000 (22:20 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 2 May 2019 15:06:28 +0000 (23:06 +0800)
for better readability

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/mgr/restful/module.py

index a2d6793eaf2d1fae8da7c61c2e50c8458172d8d4..cad8fe581e578563b852bc56afc7b351a746945f 100644 (file)
@@ -79,16 +79,16 @@ class CommandsRequest(object):
 
         # Gather the results (in parallel)
         results = []
-        for index in range(len(commands)):
+        for index, command in enumerate(commands):
             tag = '%s:%s:%d' % (__name__, self.id, index)
 
             # Store the result
             result = CommandResult(tag)
-            result.command = common.humanify_command(commands[index])
+            result.command = common.humanify_command(command)
             results.append(result)
 
             # Run the command
-            context.instance.send_command(result, 'mon', '', json.dumps(commands[index]), tag)
+            context.instance.send_command(result, 'mon', '', json.dumps(command), tag)
 
         return results