File: 0002-Update-module-and-test-to-work-with-python3.patch

package info (click to toggle)
parallax 1.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 240 kB
  • ctags: 222
  • sloc: python: 1,149; sh: 106; makefile: 11
file content (91 lines) | stat: -rw-r--r-- 3,539 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
From da32530cca991ab29ea2e6d1295ef37a324ca245 Mon Sep 17 00:00:00 2001
From: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Date: Sun, 13 Nov 2016 22:06:32 +0100
Subject: 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