]> code.ossystems Code Review - meta-freescale.git/blob
e30273d530b343e6081af89d107eae022307f925
[meta-freescale.git] /
1 From 8ba82a1ef77e60bd614cca1e583e1a0c25b4f281 Mon Sep 17 00:00:00 2001
2 From: Jose Fonseca <jfonseca@vmware.com>
3 Date: Sun, 28 Apr 2019 14:14:44 +0100
4 Subject: [PATCH 3/4] scripts: Tie Python 2 -> 3 conversion loose ends.
5
6 Upstream-Status: Backport [https://github.com/apitrace/apitrace/commit/247e1fa87f4e87b8914662e44a8ecef4d444cc90]
7
8 (cherry picked from commit 247e1fa87f4e87b8914662e44a8ecef4d444cc90)
9 Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>
10 ---
11  retrace/glstate_params.py    |  2 +-
12  scripts/convert.py           |  2 +-
13  scripts/highlight.py         |  3 ++-
14  scripts/jsondiff.py          |  2 +-
15  scripts/jsonextractimages.py |  2 +-
16  scripts/leaks.py             |  4 ++--
17  scripts/profileshader.py     |  2 +-
18  scripts/retracediff.py       |  2 +-
19  scripts/snapdiff.py          |  2 +-
20  scripts/tracecheck.py        |  2 +-
21  scripts/tracediff.py         | 10 +++++-----
22  scripts/unpickle.py          | 19 ++++++++++---------
23  12 files changed, 27 insertions(+), 25 deletions(-)
24
25 diff --git a/retrace/glstate_params.py b/retrace/glstate_params.py
26 index bc90f66b..55f2dbc9 100755
27 --- a/retrace/glstate_params.py
28 +++ b/retrace/glstate_params.py
29 @@ -1,4 +1,4 @@
30 -#!/usr/bin/env python
31 +#!/usr/bin/env python3
32  ##########################################################################
33  #
34  # Copyright 2011 Jose Fonseca
35 diff --git a/scripts/convert.py b/scripts/convert.py
36 index 83df70ce..1f285a8c 100755
37 --- a/scripts/convert.py
38 +++ b/scripts/convert.py
39 @@ -1,4 +1,4 @@
40 -#!/usr/bin/env python
41 +#!/usr/bin/env python3
42  ##########################################################################
43  #
44  # Copyright 2012 VMware Inc.
45 diff --git a/scripts/highlight.py b/scripts/highlight.py
46 index ed3b54d4..e494abf4 100644
47 --- a/scripts/highlight.py
48 +++ b/scripts/highlight.py
49 @@ -221,7 +221,8 @@ def LessHighlighter():
50          try:
51              less = subprocess.Popen(
52                  args = ['less', '-FRXn'],
53 -                stdin = subprocess.PIPE
54 +                stdin = subprocess.PIPE,
55 +                universal_newlines = True
56              )
57          except OSError:
58              return ColorHighlighter()
59 diff --git a/scripts/jsondiff.py b/scripts/jsondiff.py
60 index 25c4840e..d7a18e21 100755
61 --- a/scripts/jsondiff.py
62 +++ b/scripts/jsondiff.py
63 @@ -1,4 +1,4 @@
64 -#!/usr/bin/env python
65 +#!/usr/bin/env python3
66  ##########################################################################
67  #
68  # Copyright 2015 VMware, Inc.
69 diff --git a/scripts/jsonextractimages.py b/scripts/jsonextractimages.py
70 index 917ee7e4..785e32db 100755
71 --- a/scripts/jsonextractimages.py
72 +++ b/scripts/jsonextractimages.py
73 @@ -1,4 +1,4 @@
74 -#!/usr/bin/env python
75 +#!/usr/bin/env python3
76  ##########################################################################
77  #
78  # Copyright 2012 Jose Fonseca
79 diff --git a/scripts/leaks.py b/scripts/leaks.py
80 index 325af1e2..706e60a9 100755
81 --- a/scripts/leaks.py
82 +++ b/scripts/leaks.py
83 @@ -1,4 +1,4 @@
84 -#!/usr/bin/env python
85 +#!/usr/bin/env python3
86  ##########################################################################
87  #
88  # Copyright 2014-2016 VMware, Inc.
89 @@ -39,7 +39,7 @@ class LeakDetector(unpickle.Unpickler):
90      def __init__(self, apitrace, trace):
91  
92          cmd = [apitrace, 'pickle', '--symbolic', trace]
93 -        p = subprocess.Popen(args = cmd, stdout = subprocess.PIPE)
94 +        p = subprocess.Popen(args = cmd, stdout=subprocess.PIPE)
95  
96          unpickle.Unpickler.__init__(self, p.stdout)
97  
98 diff --git a/scripts/profileshader.py b/scripts/profileshader.py
99 index 5c2a58fb..c6c1c935 100755
100 --- a/scripts/profileshader.py
101 +++ b/scripts/profileshader.py
102 @@ -1,4 +1,4 @@
103 -#!/usr/bin/env python
104 +#!/usr/bin/env python3
105  ##########################################################################
106  #
107  # Copyright 2012-2013 VMware, Inc.
108 diff --git a/scripts/retracediff.py b/scripts/retracediff.py
109 index 8105f536..967f3a93 100755
110 --- a/scripts/retracediff.py
111 +++ b/scripts/retracediff.py
112 @@ -1,4 +1,4 @@
113 -#!/usr/bin/env python
114 +#!/usr/bin/env python3
115  ##########################################################################
116  #
117  # Copyright 2011 Jose Fonseca
118 diff --git a/scripts/snapdiff.py b/scripts/snapdiff.py
119 index b0d5f757..58fefe88 100755
120 --- a/scripts/snapdiff.py
121 +++ b/scripts/snapdiff.py
122 @@ -1,4 +1,4 @@
123 -#!/usr/bin/env python
124 +#!/usr/bin/env python3
125  ##########################################################################
126  #
127  # Copyright 2011 Jose Fonseca
128 diff --git a/scripts/tracecheck.py b/scripts/tracecheck.py
129 index 3a2ec452..38167e89 100755
130 --- a/scripts/tracecheck.py
131 +++ b/scripts/tracecheck.py
132 @@ -1,4 +1,4 @@
133 -#!/usr/bin/env python
134 +#!/usr/bin/env python3
135  ##########################################################################
136  #
137  # Copyright 2011 VMware, Inc.
138 diff --git a/scripts/tracediff.py b/scripts/tracediff.py
139 index 0cd9c8c6..88e389a3 100755
140 --- a/scripts/tracediff.py
141 +++ b/scripts/tracediff.py
142 @@ -1,4 +1,4 @@
143 -#!/usr/bin/env python
144 +#!/usr/bin/env python3
145  ##########################################################################
146  #
147  # Copyright 2011 Jose Fonseca
148 @@ -173,7 +173,7 @@ class ExternalDiffer(Differ):
149              try:
150                  less = subprocess.Popen(
151                      args = ['less', '-FRXn'],
152 -                    stdin = subprocess.PIPE
153 +                    stdin = subprocess.PIPE,
154                  )
155              except OSError:
156                  pass
157 @@ -214,7 +214,7 @@ ignoredFunctionNames = set([
158  
159  
160  class Blob:
161 -    '''Data-less proxy for bytearrays, to save memory.'''
162 +    '''Data-less proxy for bytes, to save memory.'''
163  
164      def __init__(self, size, hash):
165          self.size = size
166 @@ -233,7 +233,7 @@ class Blob:
167  class BlobReplacer(Rebuilder):
168      '''Replace blobs with proxys.'''
169  
170 -    def visitByteArray(self, obj):
171 +    def visitBytes(self, obj):
172          return Blob(len(obj), hash(str(obj)))
173  
174      def visitCall(self, call):
175 @@ -287,7 +287,7 @@ class PythonDiffer(Differ):
176                  '--calls=' + calls,
177                  trace
178              ],
179 -            stdout = subprocess.PIPE,
180 +            stdout=subprocess.PIPE,
181          )
182  
183          parser = Loader(p.stdout)
184 diff --git a/scripts/unpickle.py b/scripts/unpickle.py
185 index 86891d29..822b8ea8 100755
186 --- a/scripts/unpickle.py
187 +++ b/scripts/unpickle.py
188 @@ -1,4 +1,4 @@
189 -#!/usr/bin/env python
190 +#!/usr/bin/env python3
191  ##########################################################################
192  #
193  # Copyright 2012 Jose Fonseca
194 @@ -34,6 +34,7 @@ Run as:
195  
196  
197  import itertools
198 +import operator
199  import optparse
200  import sys
201  import time
202 @@ -55,7 +56,7 @@ CALL_FLAG_MARKER_PUSH       = (1 << 9)
203  CALL_FLAG_MARKER_POP        = (1 << 10)
204  
205  
206 -class Pointer(long):
207 +class Pointer(int):
208  
209      def __str__(self):
210          if self == 0:
211 @@ -79,7 +80,7 @@ class Visitor:
212          self.dispatch[tuple] = self.visitTuple
213          self.dispatch[list] = self.visitList
214          self.dispatch[dict] = self.visitDict
215 -        self.dispatch[bytearray] = self.visitByteArray
216 +        self.dispatch[bytes] = self.visitBytes
217          self.dispatch[Pointer] = self.visitPointer
218  
219      def visit(self, obj):
220 @@ -119,7 +120,7 @@ class Visitor:
221      def visitDict(self, obj):
222          return self.visitIterable(obj)
223  
224 -    def visitByteArray(self, obj):
225 +    def visitBytes(self, obj):
226          raise NotImplementedError
227  
228      def visitPointer(self, obj):
229 @@ -153,7 +154,7 @@ class Dumper(Visitor):
230      def visitDict(self, obj):
231          return '{' + self.visitItems(iter(obj.items())) + '}'
232  
233 -    def visitByteArray(self, obj):
234 +    def visitBytes(self, obj):
235          return 'blob(%u)' % len(obj)
236  
237  
238 @@ -169,7 +170,7 @@ class Hasher(Visitor):
239      def visitIterable(self, obj):
240          return tuple(map(self.visit, obj))
241  
242 -    def visitByteArray(self, obj):
243 +    def visitBytes(self, obj):
244          return str(obj)
245  
246  
247 @@ -193,7 +194,7 @@ class Rebuilder(Visitor):
248          else:
249              return obj
250  
251 -    def visitByteArray(self, obj):
252 +    def visitBytes(self, obj):
253          return obj
254  
255  
256 @@ -269,7 +270,7 @@ class Counter(Unpickler):
257          Unpickler.parse(self)
258  
259          functionFrequencies = list(self.functionFrequencies.items())
260 -        functionFrequencies.sort(lambda (name1, freq1), (name2, freq2): cmp(freq1, freq2))
261 +        functionFrequencies.sort(key=operator.itemgetter(1))
262          for name, frequency in functionFrequencies:
263              sys.stdout.write('%8u %s\n' % (frequency, name))
264  
265 @@ -311,7 +312,7 @@ def main():
266          msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
267  
268      startTime = time.time()
269 -    parser = Counter(sys.stdin, options.verbose)
270 +    parser = Counter(sys.stdin.buffer, options.verbose)
271      parser.parse()
272      stopTime = time.time()
273      duration = stopTime - startTime
274 -- 
275 2.17.1
276