[Python-modules-commits] [parallax] 02/03: Update module and test to work with python3

Valentin Vidic vvidic-guest at moszumanska.debian.org
Mon Nov 14 16:02:44 UTC 2016


This is an automated email from the git hooks/post-receive script.

vvidic-guest pushed a commit to branch master
in repository parallax.

commit da32530cca991ab29ea2e6d1295ef37a324ca245
Author: Valentin Vidic <Valentin.Vidic at CARNet.hr>
Date:   Sun Nov 13 22:06:32 2016 +0100

    Update module and test to work with python3
    
    Bug: https://github.com/krig/parallax/pull/4
---
 parallax/manager.py |  2 ++
 test/test_api.py    | 14 +++++++-------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/parallax/manager.py b/parallax/manager.py
index ed58d5d..153a369 100644
--- a/parallax/manager.py
+++ b/parallax/manager.py
@@ -8,6 +8,7 @@ import signal
 import sys
 import threading
 import copy
+import fcntl
 
 try:
     import queue
@@ -247,6 +248,7 @@ class IOMap(object):
 
         # Setup the wakeup file descriptor to avoid hanging on lost signals.
         wakeup_readfd, wakeup_writefd = os.pipe()
+        fcntl.fcntl(wakeup_writefd, fcntl.F_SETFL, os.O_NONBLOCK)
         self.register_read(wakeup_readfd, self.wakeup_handler)
         # TODO: remove test when we stop supporting Python <2.5
         if hasattr(signal, 'set_wakeup_fd'):
diff --git a/test/test_api.py b/test/test_api.py
index 1f75b86..9f03210 100644
--- a/test/test_api.py
+++ b/test/test_api.py
@@ -11,7 +11,7 @@ import shutil
 basedir, bin = os.path.split(os.path.dirname(os.path.abspath(sys.argv[0])))
 sys.path.insert(0, "%s" % basedir)
 
-print basedir
+print(basedir)
 
 import parallax as para
 
@@ -28,7 +28,7 @@ class CallTest(unittest.TestCase):
     def testSimpleCall(self):
         opts = para.Options()
         opts.default_user = g_user
-        for host, result in para.call(g_hosts, "ls -l /", opts).iteritems():
+        for host, result in para.call(g_hosts, "ls -l /", opts).items():
             if isinstance(result, para.Error):
                 raise result
             rc, out, err = result
@@ -38,17 +38,17 @@ class CallTest(unittest.TestCase):
     def testUptime(self):
         opts = para.Options()
         opts.default_user = g_user
-        for host, result in para.call(g_hosts, "uptime", opts).iteritems():
+        for host, result in para.call(g_hosts, "uptime", opts).items():
             if isinstance(result, para.Error):
                 raise result
             rc, out, err = result
             self.assertEqual(rc, 0)
-            self.assert_(out.find("load average") != -1)
+            self.assert_(out.decode("utf8").find("load average") != -1)
 
     def testFailingCall(self):
         opts = para.Options()
         opts.default_user = g_user
-        for host, result in para.call(g_hosts, "touch /foofoo/barbar/jfikjfdj", opts).iteritems():
+        for host, result in para.call(g_hosts, "touch /foofoo/barbar/jfikjfdj", opts).items():
             self.assert_(isinstance(result, para.Error))
             self.assert_(str(result).find('with error code') != -1)
 
@@ -65,14 +65,14 @@ class CopySlurpTest(unittest.TestCase):
         opts.default_user = g_user
         opts.localdir = self.tmpDir
         by_host = para.copy(g_hosts, "/etc/hosts", "/tmp/para.test", opts)
-        for host, result in by_host.iteritems():
+        for host, result in by_host.items():
             if isinstance(result, para.Error):
                 raise result
             rc, _, _ = result
             self.assertEqual(rc, 0)
 
         by_host = para.slurp(g_hosts, "/tmp/para.test", "para.test", opts)
-        for host, result in by_host.iteritems():
+        for host, result in by_host.items():
             if isinstance(result, para.Error):
                 raise result
             rc, _, _, path = result

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/parallax.git



More information about the Python-modules-commits mailing list