107
107
from PySide .QtCore import *
108
108
from PySide .QtGui import *
109
109
from PySide .QtSql import *
110
+ pyside_version_1 = True
110
111
from decimal import *
111
112
from ctypes import *
112
113
from multiprocessing import Process , Array , Value , Event
@@ -1526,6 +1527,19 @@ def BranchDataPrep(query):
1526
1527
" (" + dsoname (query .value (15 )) + ")" )
1527
1528
return data
1528
1529
1530
+ def BranchDataPrepWA (query ):
1531
+ data = []
1532
+ data .append (query .value (0 ))
1533
+ # Workaround pyside failing to handle large integers (i.e. time) in python3 by converting to a string
1534
+ data .append ("{:>19}" .format (query .value (1 )))
1535
+ for i in xrange (2 , 8 ):
1536
+ data .append (query .value (i ))
1537
+ data .append (tohex (query .value (8 )).rjust (16 ) + " " + query .value (9 ) + offstr (query .value (10 )) +
1538
+ " (" + dsoname (query .value (11 )) + ")" + " -> " +
1539
+ tohex (query .value (12 )) + " " + query .value (13 ) + offstr (query .value (14 )) +
1540
+ " (" + dsoname (query .value (15 )) + ")" )
1541
+ return data
1542
+
1529
1543
# Branch data model
1530
1544
1531
1545
class BranchModel (TreeModel ):
@@ -1553,7 +1567,11 @@ def __init__(self, glb, event_id, where_clause, parent=None):
1553
1567
" AND evsel_id = " + str (self .event_id ) +
1554
1568
" ORDER BY samples.id"
1555
1569
" LIMIT " + str (glb_chunk_sz ))
1556
- self .fetcher = SQLFetcher (glb , sql , BranchDataPrep , self .AddSample )
1570
+ if pyside_version_1 and sys .version_info [0 ] == 3 :
1571
+ prep = BranchDataPrepWA
1572
+ else :
1573
+ prep = BranchDataPrep
1574
+ self .fetcher = SQLFetcher (glb , sql , prep , self .AddSample )
1557
1575
self .fetcher .done .connect (self .Update )
1558
1576
self .fetcher .Fetch (glb_chunk_sz )
1559
1577
@@ -2079,14 +2097,6 @@ def IsSelectable(db, table, sql = ""):
2079
2097
return False
2080
2098
return True
2081
2099
2082
- # SQL data preparation
2083
-
2084
- def SQLTableDataPrep (query , count ):
2085
- data = []
2086
- for i in xrange (count ):
2087
- data .append (query .value (i ))
2088
- return data
2089
-
2090
2100
# SQL table data model item
2091
2101
2092
2102
class SQLTableItem ():
@@ -2110,7 +2120,7 @@ def __init__(self, glb, sql, column_headers, parent=None):
2110
2120
self .more = True
2111
2121
self .populated = 0
2112
2122
self .column_headers = column_headers
2113
- self .fetcher = SQLFetcher (glb , sql , lambda x , y = len (column_headers ): SQLTableDataPrep (x , y ), self .AddSample )
2123
+ self .fetcher = SQLFetcher (glb , sql , lambda x , y = len (column_headers ): self . SQLTableDataPrep (x , y ), self .AddSample )
2114
2124
self .fetcher .done .connect (self .Update )
2115
2125
self .fetcher .Fetch (glb_chunk_sz )
2116
2126
@@ -2154,6 +2164,12 @@ def columnCount(self, parent=None):
2154
2164
def columnHeader (self , column ):
2155
2165
return self .column_headers [column ]
2156
2166
2167
+ def SQLTableDataPrep (self , query , count ):
2168
+ data = []
2169
+ for i in xrange (count ):
2170
+ data .append (query .value (i ))
2171
+ return data
2172
+
2157
2173
# SQL automatic table data model
2158
2174
2159
2175
class SQLAutoTableModel (SQLTableModel ):
@@ -2182,8 +2198,32 @@ def __init__(self, glb, table_name, parent=None):
2182
2198
QueryExec (query , "SELECT column_name FROM information_schema.columns WHERE table_schema = '" + schema + "' and table_name = '" + select_table_name + "'" )
2183
2199
while query .next ():
2184
2200
column_headers .append (query .value (0 ))
2201
+ if pyside_version_1 and sys .version_info [0 ] == 3 :
2202
+ if table_name == "samples_view" :
2203
+ self .SQLTableDataPrep = self .samples_view_DataPrep
2204
+ if table_name == "samples" :
2205
+ self .SQLTableDataPrep = self .samples_DataPrep
2185
2206
super (SQLAutoTableModel , self ).__init__ (glb , sql , column_headers , parent )
2186
2207
2208
+ def samples_view_DataPrep (self , query , count ):
2209
+ data = []
2210
+ data .append (query .value (0 ))
2211
+ # Workaround pyside failing to handle large integers (i.e. time) in python3 by converting to a string
2212
+ data .append ("{:>19}" .format (query .value (1 )))
2213
+ for i in xrange (2 , count ):
2214
+ data .append (query .value (i ))
2215
+ return data
2216
+
2217
+ def samples_DataPrep (self , query , count ):
2218
+ data = []
2219
+ for i in xrange (9 ):
2220
+ data .append (query .value (i ))
2221
+ # Workaround pyside failing to handle large integers (i.e. time) in python3 by converting to a string
2222
+ data .append ("{:>19}" .format (query .value (9 )))
2223
+ for i in xrange (10 , count ):
2224
+ data .append (query .value (i ))
2225
+ return data
2226
+
2187
2227
# Base class for custom ResizeColumnsToContents
2188
2228
2189
2229
class ResizeColumnsToContentsBase (QObject ):
0 commit comments