107107from PySide .QtCore import *
108108from PySide .QtGui import *
109109from PySide .QtSql import *
110+ pyside_version_1 = True
110111from decimal import *
111112from ctypes import *
112113from multiprocessing import Process , Array , Value , Event
@@ -1526,6 +1527,19 @@ def BranchDataPrep(query):
15261527 " (" + dsoname (query .value (15 )) + ")" )
15271528 return data
15281529
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+
15291543# Branch data model
15301544
15311545class BranchModel (TreeModel ):
@@ -1553,7 +1567,11 @@ def __init__(self, glb, event_id, where_clause, parent=None):
15531567 " AND evsel_id = " + str (self .event_id ) +
15541568 " ORDER BY samples.id"
15551569 " 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 )
15571575 self .fetcher .done .connect (self .Update )
15581576 self .fetcher .Fetch (glb_chunk_sz )
15591577
@@ -2079,14 +2097,6 @@ def IsSelectable(db, table, sql = ""):
20792097 return False
20802098 return True
20812099
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-
20902100# SQL table data model item
20912101
20922102class SQLTableItem ():
@@ -2110,7 +2120,7 @@ def __init__(self, glb, sql, column_headers, parent=None):
21102120 self .more = True
21112121 self .populated = 0
21122122 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 )
21142124 self .fetcher .done .connect (self .Update )
21152125 self .fetcher .Fetch (glb_chunk_sz )
21162126
@@ -2154,6 +2164,12 @@ def columnCount(self, parent=None):
21542164 def columnHeader (self , column ):
21552165 return self .column_headers [column ]
21562166
2167+ def SQLTableDataPrep (self , query , count ):
2168+ data = []
2169+ for i in xrange (count ):
2170+ data .append (query .value (i ))
2171+ return data
2172+
21572173# SQL automatic table data model
21582174
21592175class SQLAutoTableModel (SQLTableModel ):
@@ -2182,8 +2198,32 @@ def __init__(self, glb, table_name, parent=None):
21822198 QueryExec (query , "SELECT column_name FROM information_schema.columns WHERE table_schema = '" + schema + "' and table_name = '" + select_table_name + "'" )
21832199 while query .next ():
21842200 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
21852206 super (SQLAutoTableModel , self ).__init__ (glb , sql , column_headers , parent )
21862207
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+
21872227# Base class for custom ResizeColumnsToContents
21882228
21892229class ResizeColumnsToContentsBase (QObject ):
0 commit comments