Skip to content

Commit

Permalink
Merge pull request #23822 from davidlange6/printMig_180718T4_FWCore_G…
Browse files Browse the repository at this point in the history
…uiBrowsers

Print function migration for FWCore_GuiBrowsers
  • Loading branch information
cmsbuild committed Jul 19, 2018
2 parents ced2630 + d3e37d3 commit 6a7d03e
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 54 deletions.
9 changes: 5 additions & 4 deletions FWCore/GuiBrowsers/python/DOTExport.py
@@ -1,3 +1,4 @@
from __future__ import print_function
import sys
import os
import logging
Expand Down Expand Up @@ -483,7 +484,7 @@ def export(self,data,filename,filetype):
dot = self.dotIndenter(dot)
self.write_output(dot,filename,filetype)
else:
print "WARNING: Empty image. Not saved."
print("WARNING: Empty image. Not saved.")


def get_png_size(self,filename):
Expand All @@ -502,7 +503,7 @@ def write_output(self,dot,filename,filetype):
dotfile.write(dot)
dotfile.close()
elif filetype=='stdout':
print result
print(result)
elif filetype=='pdf':
dot_p = subprocess.Popen(['dot','-Tps2'],stdin=subprocess.PIPE,stdout=subprocess.PIPE)
ps2 = dot_p.communicate(dot)[0]
Expand All @@ -526,7 +527,7 @@ def write_output(self,dot,filename,filetype):
mapfile.close()
filesize = self.get_png_size('%s.png'%filename)
if max(filesize) > self.options['png_max_size']:
print "png image is too large (%s pixels/%s max pixels), deleting" % (filesize,self.options['png_max_size'])
print("png image is too large (%s pixels/%s max pixels), deleting" % (filesize,self.options['png_max_size']))
os.remove('%s.png'%filename)
os.remove('%s.map'%filename)
elif filetype=='png':
Expand All @@ -536,7 +537,7 @@ def write_output(self,dot,filename,filetype):
raise "dot returned non-zero exit code: %s"%dot_p.returncode
filesize = self.get_png_size(filename)
if max(filesize) > self.options['png_max_size']:
print "png image is too large (%s pixels/%s max pixels), deleting" % (filesize,self.options['png_max_size'])
print("png image is too large (%s pixels/%s max pixels), deleting" % (filesize,self.options['png_max_size']))
os.remove(filename)
else:
dot_p = subprocess.Popen(['dot','-T%s'%(filetype),'-o',filename],stdin=subprocess.PIPE)
Expand Down
3 changes: 2 additions & 1 deletion FWCore/GuiBrowsers/python/EnablePSetHistory.py
@@ -1,3 +1,4 @@
from __future__ import print_function
from copy import deepcopy
import inspect
import six
Expand Down Expand Up @@ -112,7 +113,7 @@ def new_dumpHistory(self,withImports=True):
if isinstance(item,(str,unicode)):
dumpHistory.append(item +"\n")
else: # isTool
print item
print(item)
dump=item.dumpPython()
if isinstance(dump,tuple):
if withImports and dump[0] not in dumpHistory:
Expand Down
@@ -1,3 +1,4 @@
from __future__ import print_function
import sys
import os.path
import logging
Expand Down Expand Up @@ -254,7 +255,7 @@ def setProcess(self,process):
for path in entry:
self._readRecursive(folder, path)
if True:
print "Creating schedule...",
print("Creating schedule...", end=' ')
self.readConnections(self.allChildren(folders["modules"]))
self._scheduleRecursive(folders["paths"])
self._scheduledObjects.reverse()
Expand All @@ -267,7 +268,7 @@ def setProcess(self,process):
folders["paths"]._configChildren.remove(scheduled_folder)
folders["paths"]._configChildren.insert(0,scheduled_folder)
scheduled_folder._configChildren=self._scheduledObjects
print "done"
print("done")
else:
self._scheduledObjects=self._allObjects

Expand Down
@@ -1,4 +1,5 @@
from __future__ import absolute_import
from __future__ import print_function
import sys
import logging
import os.path
Expand Down Expand Up @@ -302,7 +303,7 @@ def readFile(self, filename):
if self.plugin().application().commandLineOptions().saveimage:
self.tab().centerView().updateConnections()
self.saveImage(self.plugin().application().commandLineOptions().saveimage)
print "Saved image to", self.plugin().application().commandLineOptions().saveimage, "."
print("Saved image to", self.plugin().application().commandLineOptions().saveimage, ".")
sys.exit(2)
return True
return False
Expand Down
3 changes: 2 additions & 1 deletion FWCore/GuiBrowsers/python/Vispa/Share/UndoEvent.py
@@ -1,3 +1,4 @@
from __future__ import print_function

class UndoEvent(object):
LABEL = ""
Expand Down Expand Up @@ -45,7 +46,7 @@ def isLastSavedState(self):
return False

def dump(self, prefix="undo"):
print prefix, ": ", self.LABEL, self.isLastSavedState()
print(prefix, ": ", self.LABEL, self.isLastSavedState())


class MultiUndoEvent(UndoEvent):
Expand Down
3 changes: 2 additions & 1 deletion FWCore/GuiBrowsers/python/Vispa/Views/PropertyView.py
@@ -1,3 +1,4 @@
from __future__ import print_function
import logging
import sys
import os.path
Expand Down Expand Up @@ -313,7 +314,7 @@ def valueChanged(self, property):
if result==True:
self.emit(SIGNAL('valueChanged'),property.name(), newvalue, oldValue, property.categoryName())
else:
print "valueChanged() result = ", result, type(result)
print("valueChanged() result = ", result, type(result))
property.setToolTip(result)
QMessageBox.critical(self.parent(), 'Error', result)
bad=True
Expand Down
3 changes: 2 additions & 1 deletion FWCore/GuiBrowsers/test/dotbatch.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python

from __future__ import print_function
import os
import sys
from optparse import OptionParser
Expand Down Expand Up @@ -31,7 +32,7 @@

def verbose(msg):
if options.verbose:
print msg
print(msg)

presets = {
'tag':{'endpath':False,'source':False,'legend':False},
Expand Down
3 changes: 2 additions & 1 deletion FWCore/GuiBrowsers/test/htmlbatch.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python

from __future__ import print_function
import os
import sys
from optparse import OptionParser
Expand All @@ -23,7 +24,7 @@

def verbose(msg):
if options.verbose:
print msg
print(msg)

parser = OptionParser(usage="Usage: %prog [options] file0_cfg.py file1_cfg.py...")

Expand Down
13 changes: 7 additions & 6 deletions FWCore/GuiBrowsers/test/testAll.py
@@ -1,4 +1,5 @@
#! /usr/bin/env python
from __future__ import print_function
import unittest
import os.path
import sys
Expand All @@ -13,16 +14,16 @@
for dir in dirs:
dirList = [os.path.abspath(os.path.join(dir, f)) for f in os.listdir(dir)]
dirs += [d for d in dirList if os.path.isdir(d) and not os.path.basename(d).startswith(".")]
print "scanning directories:"
print("scanning directories:")
for dir in dirs:
print os.path.basename(dir)
print(os.path.basename(dir))
sys.path.append(dir)
tests += [f[: - 3] for f in os.listdir(dir) if f.startswith("test") and f.endswith(".py")]
print "---"
print "running tests:"
print("---")
print("running tests:")
for test in sorted(tests):
print test
print "---"
print(test)
print("---")
for test in sorted(tests):
exec("from " + str(test) + " import *")
unittest.main()
13 changes: 7 additions & 6 deletions FWCore/GuiBrowsers/test/testGui.py
@@ -1,4 +1,5 @@
#! /usr/bin/env python
from __future__ import print_function
import unittest
import os.path
import sys
Expand All @@ -9,16 +10,16 @@
if __name__ == "__main__":
tests = []
dirs = [os.path.abspath(os.path.join(os.path.dirname(__file__),"Gui"))]
print "scanning directories:"
print("scanning directories:")
for dir in dirs:
print os.path.basename(dir)
print(os.path.basename(dir))
sys.path.append(dir)
tests += [f[: - 3] for f in os.listdir(dir) if f.startswith("test") and f.endswith(".py")]
print "---"
print "running tests:"
print("---")
print("running tests:")
for test in sorted(tests):
print test
print "---"
print(test)
print("---")
for test in sorted(tests):
exec("from " + str(test) + " import *")
unittest.main()
13 changes: 7 additions & 6 deletions FWCore/GuiBrowsers/test/testMain.py
@@ -1,4 +1,5 @@
#! /usr/bin/env python
from __future__ import print_function
import unittest
import os.path
import sys
Expand All @@ -9,16 +10,16 @@
if __name__ == "__main__":
tests = []
dirs = [os.path.abspath(os.path.join(os.path.dirname(__file__),"Main"))]
print "scanning directories:"
print("scanning directories:")
for dir in dirs:
print os.path.basename(dir)
print(os.path.basename(dir))
sys.path.append(dir)
tests += [f[: - 3] for f in os.listdir(dir) if f.startswith("test") and f.endswith(".py")]
print "---"
print "running tests:"
print("---")
print("running tests:")
for test in sorted(tests):
print test
print "---"
print(test)
print("---")
for test in sorted(tests):
exec("from " + str(test) + " import *")
unittest.main()
13 changes: 7 additions & 6 deletions FWCore/GuiBrowsers/test/testPluginConfigEditor.py
@@ -1,4 +1,5 @@
#! /usr/bin/env python
from __future__ import print_function
import unittest
import os.path
import sys
Expand All @@ -9,16 +10,16 @@
if __name__ == "__main__":
tests = []
dirs = [os.path.abspath(os.path.join(os.path.dirname(__file__),"Plugins","ConfigEditor"))]
print "scanning directories:"
print("scanning directories:")
for dir in dirs:
print os.path.basename(dir)
print(os.path.basename(dir))
sys.path.append(dir)
tests += [f[: - 3] for f in os.listdir(dir) if f.startswith("test") and f.endswith(".py")]
print "---"
print "running tests:"
print("---")
print("running tests:")
for test in sorted(tests):
print test
print "---"
print(test)
print("---")
for test in sorted(tests):
exec("from " + str(test) + " import *")
unittest.main()
13 changes: 7 additions & 6 deletions FWCore/GuiBrowsers/test/testPluginEdmBrowser.py
@@ -1,4 +1,5 @@
#! /usr/bin/env python
from __future__ import print_function
import unittest
import os.path
import sys
Expand All @@ -9,16 +10,16 @@
if __name__ == "__main__":
tests = []
dirs = [os.path.abspath(os.path.join(os.path.dirname(__file__),"Plugins","EdmBrowser"))]
print "scanning directories:"
print("scanning directories:")
for dir in dirs:
print os.path.basename(dir)
print(os.path.basename(dir))
sys.path.append(dir)
tests += [f[: - 3] for f in os.listdir(dir) if f.startswith("test") and f.endswith(".py")]
print "---"
print "running tests:"
print("---")
print("running tests:")
for test in sorted(tests):
print test
print "---"
print(test)
print("---")
for test in sorted(tests):
exec("from " + str(test) + " import *")
unittest.main()
13 changes: 7 additions & 6 deletions FWCore/GuiBrowsers/test/testShare.py
@@ -1,4 +1,5 @@
#! /usr/bin/env python
from __future__ import print_function
import unittest
import os.path
import sys
Expand All @@ -9,16 +10,16 @@
if __name__ == "__main__":
tests = []
dirs = [os.path.abspath(os.path.join(os.path.dirname(__file__),"Share"))]
print "scanning directories:"
print("scanning directories:")
for dir in dirs:
print os.path.basename(dir)
print(os.path.basename(dir))
sys.path.append(dir)
tests += [f[: - 3] for f in os.listdir(dir) if f.startswith("test") and f.endswith(".py")]
print "---"
print "running tests:"
print("---")
print("running tests:")
for test in sorted(tests):
print test
print "---"
print(test)
print("---")
for test in sorted(tests):
exec("from " + str(test) + " import *")
unittest.main()
13 changes: 7 additions & 6 deletions FWCore/GuiBrowsers/test/testViews.py
@@ -1,4 +1,5 @@
#! /usr/bin/env python
from __future__ import print_function
import unittest
import os.path
import sys
Expand All @@ -9,16 +10,16 @@
if __name__ == "__main__":
tests = []
dirs = [os.path.abspath(os.path.join(os.path.dirname(__file__),"Views"))]
print "scanning directories:"
print("scanning directories:")
for dir in dirs:
print os.path.basename(dir)
print(os.path.basename(dir))
sys.path.append(dir)
tests += [f[: - 3] for f in os.listdir(dir) if f.startswith("test") and f.endswith(".py")]
print "---"
print "running tests:"
print("---")
print("running tests:")
for test in sorted(tests):
print test
print "---"
print(test)
print("---")
for test in sorted(tests):
exec("from " + str(test) + " import *")
unittest.main()

0 comments on commit 6a7d03e

Please sign in to comment.