@@ -485,16 +485,20 @@ def createTempFile(self):
485
485
return tmpFileName
486
486
487
487
def _runSubProcess (self , filename , tmp = False ):
488
- dir , name = os .path .split (unicode (filename ))
488
+ dir = QFileInfo (filename ).path ()
489
+ file = QFileInfo (filename ).fileName ()
490
+ name = QFileInfo (filename ).baseName ()
489
491
if dir not in sys .path :
490
492
sys .path .append (dir )
493
+ if name in sys .modules :
494
+ reload (sys .modules [name ])
491
495
try :
492
496
## set creationflags for running command without shell window
493
497
if sys .platform .startswith ('win' ):
494
- p = subprocess .Popen (['python' , str (filename )], shell = False , stdin = subprocess .PIPE ,
498
+ p = subprocess .Popen (['python' , unicode (filename )], shell = False , stdin = subprocess .PIPE ,
495
499
stderr = subprocess .PIPE , stdout = subprocess .PIPE , creationflags = 0x08000000 )
496
500
else :
497
- p = subprocess .Popen (['python' , str (filename )], shell = False , stdin = subprocess .PIPE ,
501
+ p = subprocess .Popen (['python' , unicode (filename )], shell = False , stdin = subprocess .PIPE ,
498
502
stderr = subprocess .PIPE , stdout = subprocess .PIPE )
499
503
out , _traceback = p .communicate ()
500
504
@@ -511,18 +515,18 @@ def _runSubProcess(self, filename, tmp=False):
511
515
raise e
512
516
if tmp :
513
517
tmpFileTr = QCoreApplication .translate ('PythonConsole' , ' [Temporary file saved in ' )
514
- name = name + tmpFileTr + dir + ']'
518
+ file = file + tmpFileTr + dir + ']'
515
519
if _traceback :
516
- msgTraceTr = QCoreApplication .translate ('PythonConsole' , '## Script error: %1' ).arg (name )
520
+ msgTraceTr = QCoreApplication .translate ('PythonConsole' , '## Script error: %1' ).arg (file )
517
521
print "## %s" % datetime .datetime .now ()
518
- print msgTraceTr
522
+ print unicode ( msgTraceTr )
519
523
sys .stderr .write (_traceback )
520
524
p .stderr .close ()
521
525
else :
522
526
msgSuccessTr = QCoreApplication .translate ('PythonConsole' ,
523
- '## Script executed successfully: %1' ).arg (name )
527
+ '## Script executed successfully: %1' ).arg (file )
524
528
print "## %s" % datetime .datetime .now ()
525
- print msgSuccessTr
529
+ print unicode ( msgSuccessTr )
526
530
sys .stdout .write (out )
527
531
p .stdout .close ()
528
532
del p
@@ -602,7 +606,9 @@ def syntaxCheck(self, filename=None, fromContextMenu=True):
602
606
#source = open(filename, 'r').read() + '\n'
603
607
if type (source ) == type (u"" ):
604
608
source = source .encode ('utf-8' )
605
- compile (source , str (filename ), 'exec' )
609
+ if type (filename ) == type (u"" ):
610
+ filename = filename .encode ('utf-8' )
611
+ compile (source , filename , 'exec' )
606
612
except SyntaxError , detail :
607
613
s = traceback .format_exception_only (SyntaxError , detail )
608
614
fn = detail .filename
@@ -1126,6 +1132,8 @@ def listObject(self, tab):
1126
1132
else :
1127
1133
classItem .setText (0 , name )
1128
1134
classItem .setToolTip (0 , name )
1135
+ if sys .platform .startswith ('win' ):
1136
+ classItem .setSizeHint (0 , QSize (18 , 18 ))
1129
1137
classItem .setText (1 , str (class_data .lineno ))
1130
1138
iconClass = QgsApplication .getThemeIcon ("console/iconClassTreeWidgetConsole.png" )
1131
1139
classItem .setIcon (0 , iconClass )
@@ -1137,6 +1145,8 @@ def listObject(self, tab):
1137
1145
methodItem .setToolTip (0 , meth )
1138
1146
iconMeth = QgsApplication .getThemeIcon ("console/iconMethodTreeWidgetConsole.png" )
1139
1147
methodItem .setIcon (0 , iconMeth )
1148
+ if sys .platform .startswith ('win' ):
1149
+ methodItem .setSizeHint (0 , QSize (18 , 18 ))
1140
1150
classItem .addChild (methodItem )
1141
1151
dictObject [meth ] = lineno
1142
1152
self .parent .listClassMethod .addTopLevelItem (classItem )
@@ -1149,6 +1159,8 @@ def listObject(self, tab):
1149
1159
funcItem .setToolTip (0 , func_name )
1150
1160
iconFunc = QgsApplication .getThemeIcon ("console/iconFunctionTreeWidgetConsole.png" )
1151
1161
funcItem .setIcon (0 , iconFunc )
1162
+ if sys .platform .startswith ('win' ):
1163
+ funcItem .setSizeHint (0 , QSize (18 , 18 ))
1152
1164
dictObject [func_name ] = data .lineno
1153
1165
self .parent .listClassMethod .addTopLevelItem (funcItem )
1154
1166
if found :
0 commit comments