File: python3-conversion.patch

package info (click to toggle)
rt-app 1.0-1.2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 552 kB
  • sloc: ansic: 2,238; python: 260; sh: 129; makefile: 33
file content (170 lines) | stat: -rw-r--r-- 5,213 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
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
Index: rt-app-1.0/doc/workgen
===================================================================
--- rt-app-1.0.orig/doc/workgen
+++ rt-app-1.0/doc/workgen
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 import os
 import sys
@@ -8,12 +8,12 @@ import signal
 
 def check_unikid_json(infile, outfile, verbose=0):
     if not os.path.exists(infile):
-        print "WARN: %s does not exist", infile
+        print("WARN: %s does not exist", infile)
 
     try:
         fi = open(infile, "r")
     except IOError:
-        print "WARN: Unable to open %s", infile
+        print("WARN: Unable to open %s", infile)
         sys.exit(2)
 
     lines = fi.readlines()
@@ -22,7 +22,7 @@ def check_unikid_json(infile, outfile, v
     try:
         fo = open(outfile, "w+")
     except IOError:
-        print "WARN: Unable to open %s", f
+        print("WARN: Unable to open %s", f)
         sys.exit(2)
 
     curid = 1
@@ -59,7 +59,7 @@ def check_unikid_json(infile, outfile, v
                 newkey_id = key_id + str(curid)
 
             if verbose:
-                print "level ", refcount, " : key ", key_id, " changed into ", newkey_id
+                print("level ", refcount, " : key ", key_id, " changed into ", newkey_id)
 
             myline = myline.replace(key_id, newkey_id, 1)
             key_id = newkey_id
@@ -74,12 +74,12 @@ def check_unikid_json(infile, outfile, v
 
 def check_suspend_json(infile, outfile, verbose=0):
     if not os.path.exists(infile):
-        print "WARN: %s does not exist", infile
+        print("WARN: %s does not exist", infile)
 
     try:
         fi = open(infile, "r")
     except IOError:
-        print "WARN: Unable to open %s", infile
+        print("WARN: Unable to open %s", infile)
         sys.exit(2)
 
     lines = fi.readlines()
@@ -88,7 +88,7 @@ def check_suspend_json(infile, outfile,
     try:
         fo = open(outfile, "w+")
     except IOError:
-        print "WARN: Unable to open %s", f
+        print("WARN: Unable to open %s", f)
         sys.exit(2)
 
 
@@ -125,7 +125,7 @@ def check_suspend_json(infile, outfile,
            exception == 1:
       
             if verbose:
-                print "value ", curid, " added to suspend key"
+                print("value ", curid, " added to suspend key")
 
             if "," in myline:
                 myline = myline.replace(",", " : " + "\"" + curid + "\",", 1)
@@ -155,7 +155,7 @@ if __name__ == '__main__':
     try:
         opts, args = getopt.getopt(sys.argv[1:], "o:avd")
     except getopt.GetoptError as err:
-        print str(err) # will print something like "option -a not recognized"
+        print(str(err)) # will print something like "option -a not recognized"
         sys.exit(2)
 
     for o, a in opts:
Index: rt-app-1.0/doc/merge.py
===================================================================
--- rt-app-1.0.orig/doc/merge.py
+++ rt-app-1.0/doc/merge.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 import os
 import sys
@@ -11,7 +11,7 @@ try:
     opts, args = getopt.getopt(sys.argv[1:], "o:")
 
 except getopt.GetoptError as err:
-    print str(err) # will print something like "option -a not recognized"
+    print(str(err)) # will print something like "option -a not recognized"
     sys.exit(2)
 for o, a in opts:
     if o == "-o":
@@ -20,22 +20,22 @@ for o, a in opts:
 merged = dict()
 for f in args:
     if not os.path.exists(f):
-        print "WARN: %s does not exist", f
+        print("WARN: %s does not exist", f)
 
     fp = open(f, "r")
     d = json.load(fp)
     fp.close()
 
     for key in d:
-        print key,
-        if merged.has_key(key):
-            print "WARNING: merged already has key", key
+        print(key, end=' ')
+        if key in merged:
+            print("WARNING: merged already has key", key)
             merged[key].update(d[key])
         else:
             merged[key] = d[key]
 
-    print merged
-    print
+    print(merged)
+    print()
 
 fp = open(outfile, "w")
 json.dump(merged, fp, indent=4, sort_keys=True)
Index: rt-app-1.0/doc/tune_json.py
===================================================================
--- rt-app-1.0.orig/doc/tune_json.py
+++ rt-app-1.0/doc/tune_json.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 import argparse
 import collections
@@ -56,7 +56,7 @@ def load_json_file(filename):
     try:
         f = open(filename, 'r')
     except:
-        print 'ERROR: Unable to open %s' %filename
+        print('ERROR: Unable to open %s' %filename)
         sys.exit(2)
 
     comment_re = re.compile(
@@ -100,7 +100,7 @@ if __name__ == '__main__':
     args = parser.parse_args()
 
     if not os.path.isfile(args.infile):
-        print 'ERROR: input file %s does not exist\n' %args.infile
+        print('ERROR: input file %s does not exist\n' %args.infile)
         parser.print_help()
         sys.exit(2)
 
@@ -109,7 +109,7 @@ if __name__ == '__main__':
     if args.key:
         target = find_dict_by_key(doc, args.key)
         if not target:
-            print 'ERROR: key id %s is not found' %args.key
+            print('ERROR: key id %s is not found' %args.key)
             sys.exit(2)
 
     if args.instance > 0: