summaryrefslogtreecommitdiff
path: root/games-util/xboxdrv/files/xboxdrv-0.8.8-Updating-python-code-to-python3.patch
blob: 139336affd9021f092a56175801eb4b88dedc13c (plain)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
From e37d3558a1a8a36fbc5d693c53893127a288fd02 Mon Sep 17 00:00:00 2001
From: Ingo Ruhnke <grumbel@gmail.com>
Date: Sun, 24 Nov 2019 18:36:25 +0100
Subject: [PATCH 3/3] Updating python code to python3

---
 examples/responsecurve-generator.py | 14 ++++-----
 runxboxdrv/runxboxdrv               | 46 ++++++++++++++---------------
 xboxdrvctl                          |  8 ++---
 3 files changed, 34 insertions(+), 34 deletions(-)

diff --git examples/responsecurve-generator.py examples/responsecurve-generator.py
index c74e34d..942463b 100755
--- a/examples/responsecurve-generator.py
+++ b/examples/responsecurve-generator.py
@@ -1,14 +1,14 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 import sys
 import string
 
 if len(sys.argv) != 3:
-    print "Usage:", sys.argv[0], "STEPS", "EQUATION"
-    print "Simple generator for generating responsecurve data from equations."
-    print ""
-    print "Example:"
-    print "   ", sys.argv[0], "6 i**2"
+    print("Usage:", sys.argv[0], "STEPS", "EQUATION")
+    print("Simple generator for generating responsecurve data from equations.")
+    print("")
+    print("Example:")
+    print("   ", sys.argv[0], "6 i**2")
 else:
     steps = int(sys.argv[1])
     equation = sys.argv[2]
@@ -19,6 +19,6 @@ else:
     left.reverse()
     left = left[0:-1]
     
-    print string.join([str(x) for x in (left + right)], ":")
+    print(string.join([str(x) for x in (left + right)], ":"))
     
 # EOF #
diff --git runxboxdrv/runxboxdrv runxboxdrv/runxboxdrv
index 360c836..6983496 100755
--- a/runxboxdrv/runxboxdrv
+++ b/runxboxdrv/runxboxdrv
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #  This program is free software: you can redistribute it and/or modify
 #  it under the terms of the GNU General Public License as published by
 #  the Free Software Foundation, either version 3 of the License, or
@@ -409,7 +409,7 @@ class ProcessManager(object):
 	"""
 	# Since reap() modifies __procs, we have to iterate over a copy
 	# of the keys in it.  Thus, do not remove the .keys() call.
-	for procid in self.__procs.keys():
+	for procid in list(self.__procs.keys()):
 	    self.reap(procid)
 
 
@@ -445,7 +445,7 @@ import os, sys
 import os.path
 import fcntl
 import time
-import ConfigParser
+import configparser
 from subprocess import check_call, Popen, PIPE
 from signal import SIGINT, SIGKILL
 from optparse import OptionParser
@@ -482,7 +482,7 @@ class RunXBoxDrv(object):
 
     @staticmethod
     def runCommandAndGetOutput(command):
-        print command
+        print(command)
         callcommand = Popen(command, shell=True, stdout=PIPE)
         outputcommand = callcommand.communicate()
         return outputcommand[0].split("\n")
@@ -517,7 +517,7 @@ class RunXBoxDrv(object):
         if RunXBoxDrv.which(RunXBoxDrv.sudo_command) is None:
             raise Exception("Cannot find %s!" % RunXBoxDrv.sudo_command)
         commandline = "%s %s" % (RunXBoxDrv.sudo_command, command)
-        print commandline
+        print(commandline)
         callcommand = Popen(commandline, shell=True, stdout=PIPE)
         outputcommand = callcommand.communicate()
         return outputcommand[0]
@@ -525,14 +525,14 @@ class RunXBoxDrv(object):
     @staticmethod
     def killExistingXBoxDrv(sig, signame):
         for line in RunXBoxDrv.runCommandAndGetOutput("ps"):
-            print line
+            print(line)
             fields = line.split()
             if len(fields) < 4:
                 continue
             pid = fields[0]
             process = fields[3]
             if process.find(XBOXDRVNAME) != -1:
-                print "Using %s on existing %s" % (signame, XBOXDRVNAME)
+                print("Using %s on existing %s" % (signame, XBOXDRVNAME))
                 os.kill(int(pid), sig)
                 return True
         return False
@@ -542,7 +542,7 @@ class RunXBoxDrv(object):
         loadedmodules = []
         unloadedmodules = []
         for line in RunXBoxDrv.runCommandAndGetOutput("lsmod"):
-            print line            
+            print(line)            
             fields = line.split()
             if len(fields) < 3:
                 continue
@@ -555,17 +555,17 @@ class RunXBoxDrv(object):
                     unloadedmodules.append(modulename)
         for modulename in MODULELOAD:
             if modulename in loadedmodules:
-                print "%s already loaded!" % modulename
+                print("%s already loaded!" % modulename)
             else:
-                print "Loading %s!" % modulename
-                print RunXBoxDrv.runCommandAsRoot("modprobe %s" % modulename)
+                print("Loading %s!" % modulename)
+                print(RunXBoxDrv.runCommandAsRoot("modprobe %s" % modulename))
 
         for modulename in MODULEUNLOAD:
             if modulename in unloadedmodules:
-                print "Unloading %s!" % modulename
-                print RunXBoxDrv.runCommandAsRoot("rmmod %s" % modulename)
+                print("Unloading %s!" % modulename)
+                print(RunXBoxDrv.runCommandAsRoot("rmmod %s" % modulename))
             else:
-                print "%s already unloaded!" % modulename
+                print("%s already unloaded!" % modulename)
 
 
     @staticmethod
@@ -579,11 +579,11 @@ class RunXBoxDrv(object):
             raise Exception("Cannot find one of: %s!" % str(UINPUT_LOCATIONS))
 
         if not os.access(location, os.W_OK):
-            print "Trying to change permissions of: %s" % location
-            print RunXBoxDrv.runCommandAsRoot("chmod 0660 %s" % location)
+            print("Trying to change permissions of: %s" % location)
+            print(RunXBoxDrv.runCommandAsRoot("chmod 0660 %s" % location))
 
         if os.access(location, os.W_OK):
-            print "%s is writable!" % location
+            print("%s is writable!" % location)
         else:
             raise Exception("Could not set write permissions on %s" % location)
 
@@ -614,36 +614,36 @@ class RunXBoxDrv(object):
         out = ""
         while out.lower().find(LOADEDTEXT) == -1:
             out = RunXBoxDrv.getNext(myProc)
-            print out
+            print(out)
         
     def process(self):
         commandlist = [self.xboxdrvpath]
 
         if self.configfile:
              commandlist = commandlist + ["--config=%s" % self.configfile]
-        print commandlist        
+        print(commandlist)        
         myProc = Process(commandlist)
         with_timeout(1, self.checkLoaded, myProc)        
         if len(self.appandparams) == 0:
             print("WARNING: No path to application specified!")
         else:
-            print(self.appandparams)
+            print((self.appandparams))
             check_call(self.appandparams)
-        print "Sending SIGINT"
+        print("Sending SIGINT")
         myProc.kill(SIGINT)
         try:
             with_timeout(1, myProc.wait)
             sys.exit(0)
         except Timeout:
             pass
-        print "Sending SIGINT again"
+        print("Sending SIGINT again")
         myProc.kill(SIGINT)
         try:
             with_timeout(1, myProc.wait)
             sys.exit(0)
         except Timeout:
             pass
-        print "Killing"
+        print("Killing")
         myProc.terminate()
 
 def main():
diff --git xboxdrvctl xboxdrvctl
index 4807a11..57177dc 100755
--- a/xboxdrvctl
+++ b/xboxdrvctl
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
 
 ##  Xbox360 USB Gamepad Userspace Driver
 ##  Copyright (C) 2011 Ingo Ruhnke <grumbel@gmail.com>
@@ -71,7 +71,7 @@ elif options.bus == "auto":
     except dbus.exceptions.DBusException:
 				bus = dbus.SystemBus()
 else:
-    print "Error: invalid argument to --bus. Must be 'auto', 'session, or 'system'"
+    print("Error: invalid argument to --bus. Must be 'auto', 'session, or 'system'")
     exit()
 
 if options.status:
@@ -82,7 +82,7 @@ elif options.shutdown:
     daemon.Shutdown()
 else:
     if (options.led or options.rumble or options.config) and options.slot == None:
-        print "Error: --slot argument required"
+        print("Error: --slot argument required")
         exit()
     else:
         if options.slot != None:
@@ -94,7 +94,7 @@ else:
             if options.rumble:
                 m = re.match('^(\d+):(\d+)$', options.rumble)
                 if not m:
-                    print "Error: invalid argument to --rumble"
+                    print("Error: invalid argument to --rumble")
                     exit()
                 else:
                     left  = int(m.group(1))
-- 
2.29.0.rc1