Bläddra i källkod

Merge pull request #3 from ezdev128/master

Python3 adaptation
Daniel-Constantin Mierla 8 år sedan
förälder
incheckning
c67c5a5a4c
4 ändrade filer med 15 tillägg och 15 borttagningar
  1. 3 3
      kamcli/commands/cmd_config.py
  2. 6 6
      kamcli/commands/cmd_moni.py
  3. 1 1
      kamcli/commands/cmd_ps.py
  4. 5 5
      kamcli/ioutils.py

+ 3 - 3
kamcli/commands/cmd_config.py

@@ -36,7 +36,7 @@ def config_show(ctx, sections):
 @pass_context
 def config_paths(ctx):
     """Show the patsh of configuration files for kamcli"""
-    print
-    print ctx.gconfig_paths
-    print
+    print()
+    print(ctx.gconfig_paths)
+    print()
 

+ 6 - 6
kamcli/commands/cmd_moni.py

@@ -34,8 +34,8 @@ def cli(ctx, norefresh):
         while True:
             count = count + 1
             command_ctl(ctx, 'stats.get_statistics', slist, {"func": cmd_moni_result_print})
-            print
-            print "[cycle #: " + str(count) + "; if constant make sure server is running]"
+            print()
+            print("[cycle #: " + str(count) + "; if constant make sure server is running]")
             time.sleep(2)
             clear()
 
@@ -45,11 +45,11 @@ def cli(ctx, norefresh):
 #
 def cmd_moni_result_print(ctx, response, params=None):
     ctx.vlog("formatting the response for command ps")
-    print
+    print()
     rdata = json.loads(response)
     if "result" in rdata:
         rd = rdata["result"]
-        for a,b in zip(rd[::2],rd[1::2]):
-            print '{:<40}{:<}'.format(a,b)
+        for a, b in zip(rd[::2],rd[1::2]):
+            print('{:<40}{:<}'.format(a, b))
     else:
-        print json.dumps(rdata, indent=4, separators=(',', ': '))
+        print(json.dumps(rdata, indent=4, separators=(',', ': ')))

+ 1 - 1
kamcli/commands/cmd_ps.py

@@ -28,4 +28,4 @@ def cmd_ps_result_print(ctx, response, params=None):
         for r in rdata["result"]:
             ctx.printf("%4d %5d %s", r["IDX"], r["PID"], r["DSC"])
     else:
-        print json.dumps(rdata, indent=4, separators=(',', ': '))
+        print(json.dumps(rdata, indent=4, separators=(',', ': ')))

+ 5 - 5
kamcli/ioutils.py

@@ -6,7 +6,7 @@ import json
 ioutils_tabulate_format = True
 try:
     from tabulate import tabulate
-except ImportError, e:
+except ImportError as e:
     ioutils_tabulate_format = False
     pass # module doesn't exist, deal with it.
 
@@ -33,13 +33,13 @@ def ioutils_dbres_print(ctx, oformat, ostyle, res):
 
     if oformat == 'json':
         for row in res:
-            print json.dumps(dict(row), indent=4)
-            print
+            print(json.dumps(dict(row), indent=4))
+            print()
     elif oformat == 'dict':
         for row in res:
-            print dict(row)
+            print (dict(row))
             # pprint.pprint(dict(row), indent=4)
-            print
+            print()
     elif oformat == 'table':
         allrows = res.fetchall()
         gstring = tabulate(allrows, headers=res.keys(), tablefmt=ostyle)