You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gump.apache.org by aj...@apache.org on 2020/11/30 21:45:39 UTC
svn commit: r1883964 [3/3] - in /gump/live: ./ bin/ cron/
python/gump/actor/document/ python/gump/actor/document/text/
python/gump/actor/document/xdocs/ python/gump/actor/mvnrepoproxy/
python/gump/actor/notify/ python/gump/actor/repository/ python/gump...
Modified: gump/live/python/gump/test/sync.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/test/sync.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/test/sync.py (original)
+++ gump/live/python/gump/test/sync.py Mon Nov 30 21:45:38 2020
@@ -42,19 +42,19 @@ class SyncTestSuite(UnitTestSuite):
"""
self.tearDown()
os.makedirs(self.source_subdir1)
- myfile = file(self.source_alphatxt, 'w+')
+ myfile = open(self.source_alphatxt, 'w+')
myfile.write('Hello World')
myfile.close()
# Sat, 20 May 2000 12:07:40 +0000
- sometime=[2000,5,20,12,7,40,5,141,-1]
+ sometime=(2000,5,20,12,7,40,5,141,-1)
epoch_sometime = time.mktime(sometime)
os.utime(self.source_alphatxt, (epoch_sometime, epoch_sometime))
def tearDown(self):
if os.path.exists(self.source):
- log.debug('attempting to remove directory [%s]' % (`self.source`))
+ log.debug('attempting to remove directory [%s]' % (repr(self.source)))
shutil.rmtree(self.source)
if os.path.exists(self.destination):
- log.debug('attempting to remove directory [%s]' % (`self.destination`))
+ log.debug('attempting to remove directory [%s]' % (repr(self.destination)))
shutil.rmtree(self.destination)
def testSimpleSync(self):
@@ -72,32 +72,32 @@ class SyncTestSuite(UnitTestSuite):
mySync.execute()
try:
result = os.stat(self.destination)
- except Exception, details:
+ except Exception as details:
self.raiseIssue(['destination directory was not created', self.destination])
try:
result = os.stat(self.destination_subdir1)
- except Exception, details:
+ except Exception as details:
self.raiseIssue(['destination_subdir1 directory was not created', self.destination_subdir1])
result_source = None
result_destination = None
try:
result_source = os.stat(self.source_alphatxt)
- except Exception, details:
+ except Exception as details:
self.raiseIssue(['file was not created', self.source_alphatxt])
try:
result_destination = os.stat(self.destination_alphatxt)
- except Exception, details:
+ except Exception as details:
self.raiseIssue(['file was not created', self.destination_alphatxt])
- log.debug("size of file [%s] is %i" % (`self.destination_alphatxt`,
+ log.debug("size of file [%s] is %i" % (repr(self.destination_alphatxt),
result_destination[stat.ST_SIZE]))
log.debug("modification date of file [%s] is %s" %
- (`self.destination_alphatxt`,
+ (repr(self.destination_alphatxt),
time.ctime(result_destination[stat.ST_MTIME])))
self.assertTrue("modtime is equal for [%s] compared to [%s]"
- %(`self.source_alphatxt`,`self.destination_alphatxt`),
+ %(repr(self.source_alphatxt),repr(self.destination_alphatxt)),
result_source[stat.ST_MTIME]==result_destination[stat.ST_MTIME])
self.assertTrue("size is equal for [%s] compared to [%s]"
- %(`self.source_alphatxt`,`self.destination_alphatxt`),
+ %(repr(self.source_alphatxt),repr(self.destination_alphatxt)),
result_source[stat.ST_SIZE]==result_destination[stat.ST_SIZE])
def testRemoveJunkDestinationFile(self):
"""
@@ -118,7 +118,7 @@ class SyncTestSuite(UnitTestSuite):
destination_junktxt = os.path.join(self.destination_subdir1,
'junk.txt')
shutil.copy2(self.destination_alphatxt, destination_junktxt)
- sometime=[2000,5,20,12,7,45,5,141,-1]
+ sometime=(2000,5,20,12,7,45,5,141,-1)
epoch_sometime = time.mktime(sometime)
os.utime(self.destination_alphatxt, (epoch_sometime, epoch_sometime))
mySync.execute()
@@ -128,19 +128,19 @@ class SyncTestSuite(UnitTestSuite):
result_destination = None
try:
result_source = os.stat(self.source_alphatxt)
- except Exception, details:
+ except Exception as details:
self.raiseIssue(['file was not created', self.source_alphatxt])
try:
result_destination = os.stat(self.destination_alphatxt)
- except Exception, details:
+ except Exception as details:
self.raiseIssue(['file was not created', self.destination_alphatxt])
- log.debug("size of file [%s] is %i" % (`self.destination_alphatxt`,
+ log.debug("size of file [%s] is %i" % (repr(self.destination_alphatxt),
result_destination[stat.ST_SIZE]))
log.debug("modification date of file [%s] is %s" %
- (`self.destination_alphatxt`,
+ (repr(self.destination_alphatxt),
time.ctime(result_destination[stat.ST_MTIME])))
self.assertTrue("modtime is equal for [%s] compared to [%s]"
- %(`self.source_alphatxt`,`self.destination_alphatxt`),
+ %(repr(self.source_alphatxt),repr(self.destination_alphatxt)),
result_source[stat.ST_MTIME]==result_destination[stat.ST_MTIME])
def testDestinationFileBecomesDirectory(self):
"""
@@ -171,19 +171,19 @@ class SyncTestSuite(UnitTestSuite):
result_destination = None
try:
result_source = os.stat(self.source_alphatxt)
- except Exception, details:
+ except Exception as details:
self.raiseIssue(['file was not created', self.source_alphatxt])
try:
result_destination = os.stat(self.destination_alphatxt)
- except Exception, details:
+ except Exception as details:
self.raiseIssue(['file was not created', self.destination_alphatxt])
- log.debug("size of file [%s] is %i" % (`self.destination_alphatxt`,
+ log.debug("size of file [%s] is %i" % (repr(self.destination_alphatxt),
result_destination[stat.ST_SIZE]))
log.debug("modification date of file [%s] is %s" %
- (`self.destination_alphatxt`,
+ (repr(self.destination_alphatxt),
time.ctime(result_destination[stat.ST_MTIME])))
self.assertTrue("modtime is equal for [%s] compared to [%s]"
- %(`self.source_alphatxt`,`self.destination_alphatxt`),
+ %(repr(self.source_alphatxt),repr(self.destination_alphatxt)),
result_source[stat.ST_MTIME]==result_destination[stat.ST_MTIME])
def testOriginFileBecomesDirectory(self):
"""
@@ -203,7 +203,7 @@ class SyncTestSuite(UnitTestSuite):
junk_subdir = os.path.join(self.source_alphatxt, "junk.dir")
os.makedirs(junk_subdir)
junk_source_file1 = os.path.join(self.source_alphatxt, "junk.txt")
- myfile = file(junk_source_file1, 'w+')
+ myfile = open(junk_source_file1, 'w+')
myfile.write('Hello World')
myfile.close()
junk_source_file2 = os.path.join(junk_subdir, "junk.txt")
@@ -248,11 +248,11 @@ class SyncTestSuite(UnitTestSuite):
betatxt = "beta.txt"
source_betatxt = os.path.join(self.source_subdir1, betatxt)
destination_betatxt = os.path.join(self.destination_subdir1, betatxt)
- myfile = file(source_betatxt, 'w+')
+ myfile = open(source_betatxt, 'w+')
myfile.write('Hello World')
myfile.close()
# Sat, 20 May 2000 12:07:40 +0000
- sometime=[2000,5,20,12,7,40,5,141,-1]
+ sometime=(2000,5,20,12,7,40,5,141,-1)
epoch_sometime = time.mktime(sometime)
os.utime(source_betatxt, (epoch_sometime, epoch_sometime))
myCopy = Copy(self.source, self.destination)
@@ -296,15 +296,15 @@ class SyncTestSuite(UnitTestSuite):
result_dest = None
try:
result_source = os.stat(inode_source)
- except Exception, details:
+ except Exception as details:
self.raiseIssue(['could not stat ', inode_source])
try:
result_dest = os.stat(inode_dest)
- except Exception, details:
+ except Exception as details:
self.raiseIssue(['could not stat ', inode_dest])
self.assertTrue("modtime is equal for [%s] compared to [%s]"
- %(`inode_source`,`inode_dest`),
+ %(repr(inode_source),repr(inode_dest)),
result_source[stat.ST_MTIME]==result_dest[stat.ST_MTIME])
self.assertTrue("size is equal for [%s] compared to [%s]"
- %(`inode_source`,`inode_dest`),
+ %(repr(inode_source),repr(inode_dest)),
result_source[stat.ST_SIZE]==result_dest[stat.ST_SIZE])
Modified: gump/live/python/gump/test/syndicator.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/test/syndicator.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/test/syndicator.py (original)
+++ gump/live/python/gump/test/syndicator.py Mon Nov 30 21:45:38 2020
@@ -22,7 +22,7 @@
import os
import logging
-import types, StringIO
+import types, io
from gump import log
import gump.core.config
@@ -49,7 +49,9 @@ class SyndicatorTestSuite(UnitTestSuite)
self.rss=RSSSyndicator(self.run)
+ self.rss.prepareRun()
self.atom=AtomSyndicator(self.run)
+ self.atom.prepareRun()
def testRSSSyndicateModule(self):
self.rss.syndicateModule(self.module1)
Modified: gump/live/python/gump/test/testExample.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/test/testExample.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/test/testExample.py (original)
+++ gump/live/python/gump/test/testExample.py Mon Nov 30 21:45:38 2020
@@ -41,8 +41,8 @@ class ExampleTestCase(TestCase):
# you can do anything inside a test
# use the assertXXX methods on TestCase
# to check conditions
- self.assert_( True )
- self.assertEquals( type({}), type({}) )
+ self.assertTrue( True )
+ self.assertEqual( type({}), type({}) )
# this is used by testrunner.py to determine what tests to run
def test_suite():
Modified: gump/live/python/gump/test/threads.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/test/threads.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/test/threads.py (original)
+++ gump/live/python/gump/test/threads.py Mon Nov 30 21:45:38 2020
@@ -28,11 +28,11 @@ class TestWork:
self.stuff=stuff
def __str__(self):
- return 'Work:'+`self.stuff`
+ return 'Work:'+repr(self.stuff)
class TestWorker(WorkerThread):
def performWork(self,work):
- print 'Thread ' + self.getName() + ' performs ' + str(work)
+ print('Thread ' + self.getName() + ' performs ' + str(work))
time.sleep(2)
@@ -47,7 +47,7 @@ class ThreadingTestSuite(UnitTestSuite):
work=workList.getWork()
while work:
- print 'Get Work : ' + str(work)
+ print('Get Work : ' + str(work))
work=workList.getWork()
def testThreadWorkers1(self):
Modified: gump/live/python/gump/test/timing.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/test/timing.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/test/timing.py (original)
+++ gump/live/python/gump/test/timing.py Mon Nov 30 21:45:38 2020
@@ -105,11 +105,11 @@ class TimingTestSuite(UnitTestSuite):
#set.dump()
set.getTotalTimes()
- self.assertGreater('Time passes', range1.getStart(), range1.getEnd())
- self.assertGreater('Time passes', range2.getStart(), range2.getEnd())
- self.assertGreater('Time passes', range1.getEnd(), range2.getEnd())
+ self.assertLesser('Time passes', range1.getStart(), range1.getEnd())
+ self.assertLesser('Time passes', range2.getStart(), range2.getEnd())
+ self.assertLesser('Time passes', range1.getEnd(), range2.getEnd())
- self.assertGreater('Time passes', set.getStart(), set.getEnd())
+ self.assertLesser('Time passes', set.getStart(), set.getEnd())
def testUTCTimes(self):
stamp1=TimeStamp('S1')
@@ -118,5 +118,5 @@ class TimingTestSuite(UnitTestSuite):
t1=stamp1.getUtc()
t2=stamp2.getUtc()
- self.assertIn('UTC', 'UTC', t1)
- self.assertIn('UTC', 'UTC', t2)
+ self.assertInSequence('UTC', 'UTC', t1)
+ self.assertInSequence('UTC', 'UTC', t2)
Modified: gump/live/python/gump/test/unicode.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/test/unicode.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/test/unicode.py (original)
+++ gump/live/python/gump/test/unicode.py Mon Nov 30 21:45:38 2020
@@ -20,7 +20,7 @@
import os
import logging
-import types, StringIO
+import types, io
from xml.sax.saxutils import escape
from gump import log
Modified: gump/live/python/gump/test/updater.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/test/updater.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/test/updater.py (original)
+++ gump/live/python/gump/test/updater.py Mon Nov 30 21:45:38 2020
@@ -20,7 +20,7 @@
import os
import logging
-import types, StringIO
+import types, io
from gump import log
import gump.core.config
Modified: gump/live/python/gump/test/utils.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/test/utils.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/test/utils.py (original)
+++ gump/live/python/gump/test/utils.py Mon Nov 30 21:45:38 2020
@@ -62,7 +62,7 @@ class UtilsTestSuite(UnitTestSuite):
def testBeanAttributes(self):
attrs=getBeanAttributes(TestBean())
- self.assertNotEmpty('Ought be some', attrs)
+ self.assertNotEmptyDictionary('Ought be some', attrs)
self.assertNotNone('Ought be one called X', attrs['X'])
def testRandomStuff(self):
Modified: gump/live/python/gump/test/xdocs.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/test/xdocs.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/test/xdocs.py (original)
+++ gump/live/python/gump/test/xdocs.py Mon Nov 30 21:45:38 2020
@@ -20,7 +20,7 @@
import os
import logging
-import types, StringIO
+import types, io
from gump.core.gumpinit import gumpinit
from gump.actor.document.xdocs.xdoc import *
@@ -41,7 +41,7 @@ class XDocsTestSuite(UnitTestSuite):
#print data
def createXDoc(self,title,xhtml):
- stream=StringIO.StringIO()
+ stream=io.StringIO()
doc1=XDocDocument('Test 1', stream, XDocConfig(xhtml))
Modified: gump/live/python/gump/test/xref.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/test/xref.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/test/xref.py (original)
+++ gump/live/python/gump/test/xref.py Mon Nov 30 21:45:38 2020
@@ -20,7 +20,7 @@
import os
import logging
-import types, StringIO
+import types, io
from gump import log
import gump.core.config
Modified: gump/live/python/gump/tool/guru/xref.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/tool/guru/xref.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/tool/guru/xref.py (original)
+++ gump/live/python/gump/tool/guru/xref.py Mon Nov 30 21:45:38 2020
@@ -57,7 +57,7 @@ class XRefGuru:
for module in self.workspace.getModules():
repository=module.getRepository()
if repository:
- if not self.repositoryToModule.has_key(repository):
+ if not repository in self.repositoryToModule:
self.repositoryToModule[repository]=[]
# Store
@@ -68,10 +68,10 @@ class XRefGuru:
for project in module.getProjects():
if project.hasPackageNames():
for packageName in project.getPackageNames():
- if not self.packageToModule.has_key(packageName):
+ if not packageName in self.packageToModule:
self.packageToModule[packageName]=[]
- if not self.packageToProject.has_key(packageName):
+ if not packageName in self.packageToProject:
self.packageToProject[packageName]=[]
# Store
@@ -86,7 +86,7 @@ class XRefGuru:
moduleDescription=module.getDescription()
if moduleDescription:
- if not self.descriptionToModule.has_key(moduleDescription):
+ if not moduleDescription in self.descriptionToModule:
self.descriptionToModule[moduleDescription]=[]
if not module in self.descriptionToModule[moduleDescription]:
@@ -96,7 +96,7 @@ class XRefGuru:
projectDescription=project.getDescription()
if projectDescription:
- if not self.descriptionToProject.has_key(projectDescription):
+ if not projectDescription in self.descriptionToProject:
self.descriptionToProject[projectDescription]=[]
if not project in self.descriptionToProject[projectDescription]:
@@ -112,11 +112,11 @@ class XRefGuru:
outputId=output.getId() or 'No Identifier'
# Create a list to hold multiple (if needed)
- if not self.outputToProject.has_key(outputName):
+ if not outputName in self.outputToProject:
self.outputToProject[outputName]=[]
# Create a list to hold multiple (if needed)
- if not self.outputIdToProject.has_key(outputId):
+ if not outputId in self.outputIdToProject:
self.outputIdToProject[outputId]=[]
# Store the Project
@@ -133,7 +133,7 @@ class XRefGuru:
# print project.getName() + ' : Metadata Location = ' + metadataLocation + "\n";
if metadataLocation:
- if not self.descriptorLocationToProject.has_key(metadataLocation):
+ if not metadataLocation in self.descriptorLocationToProject:
self.descriptorLocationToProject[metadataLocation]=[]
if not project in self.descriptorLocationToProject[metadataLocation]:
Modified: gump/live/python/gump/tool/integration/cvs.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/tool/integration/cvs.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/tool/integration/cvs.py (original)
+++ gump/live/python/gump/tool/integration/cvs.py Mon Nov 30 21:45:38 2020
@@ -78,7 +78,7 @@ def loginToRepositoryOnDemand(repository
# log into the cvs repository
if str(repository.getMethod())=='pserver':
newpass=mangle(repository.getPassword())
- if not root in logins or logins[root]<>newpass:
+ if not root in logins or logins[root]!=newpass:
log.info('Provide login for CVS repository: ' + repository.getName() + ' @ ' + root)
# Open with append...
Modified: gump/live/python/gump/tool/performance/deps.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/tool/performance/deps.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/tool/performance/deps.py (original)
+++ gump/live/python/gump/tool/performance/deps.py Mon Nov 30 21:45:38 2020
@@ -44,7 +44,7 @@ def deps(run,runs=1):
documenter=XDocDocumenter(run,gtest,'http://someplace')
for r in range(runs):
- print 'Perform run # ' + `r`
+ print('Perform run # ' + repr(r))
for project in run.getWorkspace().getProjects():
project.getDirectDependencies()
project.getDirectDependees()
Modified: gump/live/python/gump/tool/performance/gurus.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/tool/performance/gurus.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/tool/performance/gurus.py (original)
+++ gump/live/python/gump/tool/performance/gurus.py Mon Nov 30 21:45:38 2020
@@ -34,7 +34,7 @@ from gump.core.loader.loader import Work
def gurus(run,runs=1):
for r in range(runs):
- print 'Perform run # ' + `r`
+ print('Perform run # ' + repr(r))
log.info('Generate Statistic Guru')
stats=StatisticsGuru(run.getWorkspace())
log.info('Generate XRef Guru')
Modified: gump/live/python/gump/tool/performance/xdocs.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/tool/performance/xdocs.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/tool/performance/xdocs.py (original)
+++ gump/live/python/gump/tool/performance/xdocs.py Mon Nov 30 21:45:38 2020
@@ -44,7 +44,7 @@ def document(run,runs=1):
documenter=XDocDocumenter(run,gtest,'http://someplace')
for r in range(runs):
- print 'Perform run # ' + `r`
+ print('Perform run # ' + repr(r))
documenter.document()
def xrun():
Modified: gump/live/python/gump/tool/shared/comparator.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/tool/shared/comparator.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/tool/shared/comparator.py (original)
+++ gump/live/python/gump/tool/shared/comparator.py Mon Nov 30 21:45:38 2020
@@ -42,6 +42,8 @@ def compareObjects(o1,o2):
#
# Module Comparisons
#
+def comparison(a,b):
+ return int(a > b) - int(a < b)
def compareModulesByElapsed(module1,module2):
elapsed1=module1.getElapsedSecs()
@@ -49,28 +51,28 @@ def compareModulesByElapsed(module1,modu
c = 0
if elapsed1 > elapsed2: c = -1
if elapsed1 < elapsed2: c = 1
- if not c: c=cmp(module1,module2)
+ if not c: c=comparison(module1,module2)
return c
def compareModulesByProjectCount(module1,module2):
count1=len(module1.getProjects())
count2=len(module2.getProjects())
c = count2 - count1
- if not c: c=cmp(module1,module2)
+ if not c: c=comparison(module1,module2)
return c
def compareModulesByDependencyCount(module1,module2):
count1=module1.getFullDependencyCount()
count2=module2.getFullDependencyCount()
c= count2 - count1
- if not c: c=cmp(module1,module2)
+ if not c: c=comparison(module1,module2)
return c
def compareModulesByDependeeCount(module1,module2):
count1=module1.getFullDependeeCount()
count2=module2.getFullDependeeCount()
c= count2 - count1
- if not c: c=cmp(module1,module2)
+ if not c: c=comparison(module1,module2)
return c
def compareModulesByFOGFactor(module1,module2):
@@ -78,7 +80,7 @@ def compareModulesByFOGFactor(module1,mo
fog2=module2.getFOGFactor()
# Allow comparison to 2 decimal places, by *100
c= int(round((fog2 - fog1)*100,0))
- if not c: c=cmp(module1,module2)
+ if not c: c=comparison(module1,module2)
return c
def compareModulesByLastModified(module1,module2):
@@ -96,35 +98,35 @@ def compareProjectsByElapsed(project1,pr
c = 0
if elapsed1 > elapsed2: c = -1
if elapsed1 < elapsed2: c = 1
- if not c: c=cmp(project1,project2)
+ if not c: c=comparison(project1,project2)
return c
def compareProjectsByDependencyCount(project1,project2):
count1=project1.getDependencyCount()
count2=project2.getDependencyCount()
c= count2 - count1
- if not c: c=cmp(project1,project2)
+ if not c: c=comparison(project1,project2)
return c
def compareProjectsByDependeeCount(project1,project2):
count1=project1.getDependeeCount()
count2=project2.getDependeeCount()
c= count2 - count1
- if not c: c=cmp(project1,project2)
+ if not c: c=comparison(project1,project2)
return c
def compareProjectsByFullDependeeCount(project1,project2):
count1=project1.getFullDependeeCount()
count2=project2.getFullDependeeCount()
c= count2 - count1
- if not c: c=cmp(project1,project2)
+ if not c: c=comparison(project1,project2)
return c
def compareProjectsByFullDependencyCount(project1,project2):
count1=project1.getFullDependencyCount()
count2=project2.getFullDependencyCount()
c= count2 - count1
- if not c: c=cmp(project1,project2)
+ if not c: c=comparison(project1,project2)
return c
def compareProjectsByFOGFactor(project1,project2):
@@ -132,7 +134,7 @@ def compareProjectsByFOGFactor(project1,
fog2=project2.getFOGFactor()
# Allow comparison to 2 decimal places, by *100
c= int(round((fog2 - fog1)*100,0))
- if not c: c=cmp(project1,project2)
+ if not c: c=comparison(project1,project2)
return c
def compareProjectsByLastModified(project1,project2):
@@ -144,27 +146,27 @@ def compareProjectsBySequenceInState(pro
seq1=project1.getStats().sequenceInState
seq2=project2.getStats().sequenceInState
c= int(round(seq2 - seq1,0))
- if not c: c=cmp(project1,project2)
+ if not c: c=comparison(project1,project2)
return c
def compareProjectsByDependencyDepth(project1,project2):
dep1=project1.getDependencyDepth()
dep2=project2.getDependencyDepth()
c= int(round(dep2 - dep1,0))
- if not c: c=cmp(project1,project2)
+ if not c: c=comparison(project1,project2)
return c
def compareProjectsByTotalDependencyDepth(project1,project2):
tot1=project1.getTotalDependencyDepth()
tot2=project2.getTotalDependencyDepth()
c= int(round(tot2 - tot1,0))
- if not c: c=cmp(project1,project2)
+ if not c: c=comparison(project1,project2)
return c
def compareProjectsByAffected(project1,project2):
aff1=project1.countAffectedProjects()
aff2=project2.countAffectedProjects()
c= int(round(aff2 - aff1,0))
- if not c: c=cmp(project1,project2)
+ if not c: c=comparison(project1,project2)
return c
Modified: gump/live/python/gump/tool/svg/depdiag.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/tool/svg/depdiag.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/tool/svg/depdiag.py (original)
+++ gump/live/python/gump/tool/svg/depdiag.py Mon Nov 30 21:45:38 2020
@@ -91,13 +91,13 @@ class DependencyMatrix:
self.insertProject(project)
# Now re-order the rows, sorting by FOG
- for rowNo in self.depths.keys():
+ for rowNo in list(self.depths.keys()):
row=self.depths[rowNo]
newRow=createOrderedList(row,compareNodesByProjectFOGFactor)
self.depths[rowNo]=newRow
# Now fix the (x,y) for all nodes (based of this sort)
- for rowNo in self.depths.keys():
+ for rowNo in list(self.depths.keys()):
colNo=0
for node in self.depths[rowNo]:
node.setRowCol(rowNo,colNo)
@@ -106,7 +106,7 @@ class DependencyMatrix:
# Insert into lists
def insertProject(self,project):
depth=project.getDependencyDepth()
- if not self.depths.has_key(depth):
+ if depth not in self.depths:
self.depths[depth]=[]
# Context
@@ -139,10 +139,10 @@ class DependencyMatrix:
return row in self.getRows()
def getRows(self):
- return self.depths.keys()
+ return list(self.depths.keys())
def getNodes(self):
- return self.nodes.values()
+ return list(self.nodes.values())
def getNodeForProject(self,project):
return self.nodes[project]
@@ -150,14 +150,14 @@ class DependencyMatrix:
def dump(self, indent=0, output=sys.stdout):
""" Display the contents of this object """
- output.write(getIndent(indent)+'Extent : ' + `self.getExtent()` + '\n')
+ output.write(getIndent(indent)+'Extent : ' + repr(self.getExtent()) + '\n')
# Now re-order the rows, sorting by FOG
- for rowNo in self.depths.keys():
+ for rowNo in list(self.depths.keys()):
row=self.depths[rowNo]
- output.write(getIndent(indent)+'Row [Depth]: ' + `rowNo` + '\n')
+ output.write(getIndent(indent)+'Row [Depth]: ' + repr(rowNo) + '\n')
for value in row:
- output.write(getIndent(indent+1)+'Row : ' + `value` + '\n')
+ output.write(getIndent(indent+1)+'Row : ' + repr(value) + '\n')
class DependencyDiagram:
""" The interface to a chainable context """
@@ -213,10 +213,10 @@ class DependencyDiagram:
#print 'NODE (ROW,COL) : ' + `(row, col)`
(x,y) = context.realPoint(row,centeredCol)
(x1,y1) = context.realPoint(row,col)
- if y1 <> y:
- print 'Cols:',cols,'Row Cols',rowColumns,' COLS:', col,' -> ',centeredCol
- print '(X,Y) : ' + `(x, y)`
- print '(X1,Y1) : ' + `(x1, y1)`
+ if y1 != y:
+ print('Cols:',cols,'Row Cols',rowColumns,' COLS:', col,' -> ',centeredCol)
+ print('(X,Y) : ' + repr((x, y)))
+ print('(X1,Y1) : ' + repr((x1, y1)))
node.setPoint(Point(x,y))
node.setRowCol(row,centeredCol)
@@ -287,7 +287,7 @@ class DependencyDiagram:
(x,y) = context.realPoint(row+0.27,col-0.27)
#print 'TEXT %s,%s' % (x,y)
- svg.addText(x,y,project.getName() + ' (' + `project.getFOGFactor()` + ')', \
+ svg.addText(x,y,project.getName() + ' (' + repr(project.getFOGFactor()) + ')', \
{ 'fill':'red', \
'comment':project.getName() } )
@@ -329,7 +329,7 @@ if __name__=='__main__':
svg=diagram.generateDiagram()
svgName=project.getName()+'.svg'
svg.serializeToFile(svgName)
- print "Generated : " + svgName
+ print("Generated : " + svgName)
#
log.info('Dependency Generation complete.')
Modified: gump/live/python/gump/tool/svg/drawing.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/tool/svg/drawing.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/tool/svg/drawing.py (original)
+++ gump/live/python/gump/tool/svg/drawing.py Mon Nov 30 21:45:38 2020
@@ -41,11 +41,11 @@ class Point:
def dump(self, indent=0, output=sys.stdout):
""" Display the contents of this object """
output.write(getIndent(indent)+'Point : ' \
- + `self.x` + ',' \
- + `self.y` + '\n')
+ + repr(self.x) + ',' \
+ + repr(self.y) + '\n')
def __str__(self):
- return '(' + `self.x` + ',' + `self.y` + ')'
+ return '(' + repr(self.x) + ',' + repr(self.y) + ')'
class Rect:
""" A rectangle """
@@ -70,14 +70,14 @@ class Rect:
def dump(self, indent=0, output=sys.stdout):
""" Display the contents of this object """
output.write(getIndent(indent)+'Rect : ' \
- + `self.x` + ',' \
- + `self.y` + ' ' \
- + `self.w` + ',' \
- + `self.h` + '\n')
+ + repr(self.x) + ',' \
+ + repr(self.y) + ' ' \
+ + repr(self.w) + ',' \
+ + repr(self.h) + '\n')
def __str__(self):
- return '(' + `self.x` + ',' + `self.y` + ' ' \
- + `self.w` + ',' + `self.h` + ')'
+ return '(' + repr(self.x) + ',' + repr(self.y) + ' ' \
+ + repr(self.w) + ',' + repr(self.h) + ')'
# Scale a rectangle
def getScaledRect(scalarW,scalarH,rect):
@@ -127,18 +127,18 @@ class DrawingContext:
self.next=next
def hasNextContext(self):
- return self.next
+ return self.next # __next__
def getNextContext(self):
- return self.next
+ return self.next # __next__
def getRootContext(self):
- if self.next: return self.next.getRootContext()
+ if self.next: return self.next.getRootContext() # was __next__
return self
def enforceHasNextContext(self,operation):
if not self.hasNextContext():
- raise RuntimeError, "Missing 'next' context in " + str(operation)
+ raise RuntimeError("Missing 'next' context in " + str(operation))
def dump(self, indent=0, output=sys.stdout):
""" Display the contents of this object """
@@ -153,7 +153,7 @@ class StandardDrawingContext(DrawingCont
def getPoint(x,y):
if not self.rect.inRect(x,y):
- raise RuntimeError, "Point not in context rectangle."
+ raise RuntimeError("Point not in context rectangle.")
return (x,y)
def hasRect(self): return hasattr(self,'rect') and self.rect
@@ -167,15 +167,15 @@ class StandardDrawingContext(DrawingCont
""" Display the contents of this object """
DrawingContext.dump(self)
if self.hasRect(): self.rect.dump(indent,output)
- output.write(getIndent(indent)+'Width : ' + `self.getWidth()` + '\n')
- output.write(getIndent(indent)+'Height : ' + `self.getHeight()` + '\n')
+ output.write(getIndent(indent)+'Width : ' + repr(self.getWidth()) + '\n')
+ output.write(getIndent(indent)+'Height : ' + repr(self.getHeight()) + '\n')
class ScaledDrawingContext(StandardDrawingContext):
def __init__(self,name,context=None,rect=None,scaledWidth=1,scaledHeight=1):
StandardDrawingContext.__init__(self,name,context,rect)
- if not scaledWidth: raise RuntimeError, 'Can\'t scale with 0 width.'
- if not scaledHeight: raise RuntimeError, 'Can\'t scale with 0 height.'
+ if not scaledWidth: raise RuntimeError('Can\'t scale with 0 width.')
+ if not scaledHeight: raise RuntimeError('Can\'t scale with 0 height.')
self.scaledWidth=scaledWidth
self.scaledHeight=scaledHeight
@@ -193,17 +193,17 @@ class ScaledDrawingContext(StandardDrawi
def dump(self, indent=0, output=sys.stdout):
""" Display the contents of this object """
StandardDrawingContext.dump(self)
- output.write(getIndent(indent)+'wScaled : ' + `self.scaledWidth` + '\n')
- output.write(getIndent(indent)+'hScaled : ' + `self.scaledHeight` + '\n')
- output.write(getIndent(indent)+'wRatio : ' + `self.wRatio` + '\n')
- output.write(getIndent(indent)+'hRatio : ' + `self.hRatio` + '\n')
+ output.write(getIndent(indent)+'wScaled : ' + repr(self.scaledWidth) + '\n')
+ output.write(getIndent(indent)+'hScaled : ' + repr(self.scaledHeight) + '\n')
+ output.write(getIndent(indent)+'wRatio : ' + repr(self.wRatio) + '\n')
+ output.write(getIndent(indent)+'hRatio : ' + repr(self.hRatio) + '\n')
class ShiftedDrawingContext(StandardDrawingContext):
def __init__(self,name,context=None,shiftedX=0,shiftedY=0):
StandardDrawingContext.__init__(self,name,context)
if not (shiftedX or shiftedY):
- raise RuntimeError, 'A ShiftedDrawingContext with no shift'
+ raise RuntimeError('A ShiftedDrawingContext with no shift')
self.shiftedX=shiftedX
self.shiftedY=shiftedY
@@ -214,8 +214,8 @@ class ShiftedDrawingContext(StandardDraw
def dump(self, indent=0, output=sys.stdout):
""" Display the contents of this object """
StandardDrawingContext.dump(self)
- output.write(getIndent(indent)+'xShift : ' + `self.shiftedX` + '\n')
- output.write(getIndent(indent)+'yShift : ' + `self.shiftedY` + '\n')
+ output.write(getIndent(indent)+'xShift : ' + repr(self.shiftedX) + '\n')
+ output.write(getIndent(indent)+'yShift : ' + repr(self.shiftedY) + '\n')
class GridDrawingContext(DrawingContext):
"""
@@ -252,13 +252,13 @@ class GridDrawingContext(DrawingContext)
return (x,y)
- xrange=range(0,self.rows)
+ xrange=list(range(0,self.rows))
if not x in xrange:
- raise RuntimeError, 'X isn\'t in range [' + `x` + '] [' + `xrange` + ']'
+ raise RuntimeError('X isn\'t in range [' + repr(x) + '] [' + repr(xrange) + ']')
- yrange=range(0,self.cols)
+ yrange=list(range(0,self.cols))
if not y in yrange:
- raise RuntimeError, 'Y isn\'t in range [' + `y` + '] [' + `yrange` + ']'
+ raise RuntimeError('Y isn\'t in range [' + repr(y) + '] [' + repr(yrange) + ']')
return (x,y)
Modified: gump/live/python/gump/tool/svg/svg.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/tool/svg/svg.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/tool/svg/svg.py (original)
+++ gump/live/python/gump/tool/svg/svg.py Mon Nov 30 21:45:38 2020
@@ -252,7 +252,7 @@ class SimpleSvg:
writeSvgFooter(stream)
writeFooter(stream)
- except Exception, details:
+ except Exception as details:
log.error("Failed to serialize SVG: " + str(details), exc_info=1)
raise
Modified: gump/live/python/gump/util/__init__.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/util/__init__.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/util/__init__.py (original)
+++ gump/live/python/gump/util/__init__.py Mon Nov 30 21:45:38 2020
@@ -24,24 +24,26 @@
import logging
import os
import sys
-import types, StringIO
+import types, io
import time
-import urllib
+import urllib.request, urllib.parse, urllib.error
+
+from functools import cmp_to_key
from gump import log
from gump.core.config import default, setting
def banner():
- print " _____"
- print " | __|_ Apache_ ___"
- print " | | | | | | . |"
- print " |_____|___|_|_|_| _|"
- print " |_| ~ v. " + setting.VERSION + " ~"
- print
+ print(" _____")
+ print(" | __|_ Apache_ ___")
+ print(" | | | | | | . |")
+ print(" |_____|___|_|_|_| _|")
+ print((" |_| ~ v. " + setting.VERSION + " ~"))
+ print()
def gumpSafeName(name):
"""returns a file system safe name"""
- return urllib.quote_plus(name)
+ return urllib.parse.quote_plus(name)
def getModule(modulePath):
try:
@@ -56,7 +58,7 @@ def getModule(modulePath):
def dump(obj,indent="",visited=None):
- print indent+"Object: ["+str(obj.__class__)+"] "+str(obj)
+ print((indent+"Object: ["+str(obj.__class__)+"] "+str(obj)))
if not visited:
visited=[]
@@ -64,7 +66,7 @@ def dump(obj,indent="",visited=None):
visited.append(obj)
if not obj: return
- if isinstance(obj,types.TypeType): return
+ if isinstance(obj,type): return
if isinstance(obj,types.MethodType): return
@@ -75,36 +77,36 @@ def dump(obj,indent="",visited=None):
var=obj.__dict__[name]
# avoid nulls, metadata, and methods
- if type(var) == types.NoneType: continue
- if isinstance(var,types.TypeType): continue
+ if type(var) == type(None): continue
+ if isinstance(var,type): continue
if isinstance(var,types.MethodType): continue
if isinstance(var,list):
- print indent+" List Name:" + str(name) + ' len:' + str(len(var))
+ print((indent+" List Name:" + str(name) + ' len:' + str(len(var))))
i=0
for v in var:
i+=1
- print indent+" (" + str(i) + ") " + str(name)
+ print((indent+" (" + str(i) + ") " + str(name)))
dump(v, indent+" ", visited)
elif isinstance(var,dict):
- print " Dictionary Name:" + str(name) + " " + str(var.__class__)
- for (k,v) in var.iteritems():
- print indent+" Key:" + str(k) + " " + str(v.__class__)
+ print((" Dictionary Name:" + str(name) + " " + str(var.__class__)))
+ for (k,v) in list(var.items()):
+ print((indent+" Key:" + str(k) + " " + str(v.__class__)))
dump(v,indent+" ", visited)
elif isinstance(var,object) and not isinstance(var,str):
- print indent+" Object Name:" + str(name) + " " + str(var.__class__)
+ print((indent+" Object Name:" + str(name) + " " + str(var.__class__)))
if not 'owner' == str(name):
dump(var,indent+" ", visited)
else:
try:
- print indent+" " + str(name) + " :-> " + str(var)
+ print((indent+" " + str(name) + " :-> " + str(var)))
except:
- print indent+" " + str(name) + " :-> Unprintable (non-ASCII) Characters"
+ print((indent+" " + str(name) + " :-> Unprintable (non-ASCII) Characters"))
except:
pass
def display(obj):
- print str(obj.__class__)
+ print((str(obj.__class__)))
# iterate over the own properties
for name in obj.__dict__:
if name.startswith('__') and name.endswith('__'): continue
@@ -112,48 +114,45 @@ def display(obj):
# avoid nulls, metadata, and methods
if not var: continue
- if isinstance(var,types.TypeType): continue
+ if isinstance(var,type): continue
if isinstance(var,types.MethodType): continue
if isinstance(var,list):
- print " List Name:" + str(name) + " " + str(var.__class__)
+ print((" List Name:" + str(name) + " " + str(var.__class__)))
for v in var:
display(v)
elif isinstance(var,dict):
- print " Dictionary Name:" + str(name) + " " + str(var.__class__)
- for (k,v) in var.iteritems():
+ print((" Dictionary Name:" + str(name) + " " + str(var.__class__)))
+ for (k,v) in list(var.items()):
display(v)
else:
try:
- print " " + str(name) + " :-> " + str(var)
+ print((" " + str(name) + " :-> " + str(var)))
except:
- print " " + str(name) + " :-> Unprintable (non-ASCII) Characters"
+ print((" " + str(name) + " :-> Unprintable (non-ASCII) Characters"))
class AlphabeticDictionaryIterator:
""" Iterate over a dictionary in alphabetic key order """
def __init__(self,dict):
self.dict=dict
- self.keys=dict.keys()
+ self.keys=list(dict.keys())
self.keys.sort()
self.iter=iter(self.keys)
def __iter__(self):
return self
- def next(self):
- key=self.iter.next()
+ def __next__(self):
+ key=next(self.iter)
return self.dict[key]
def createOrderedList(disorderedList,sortfunc=None):
# Is there a better way to clone a list?
- sorted=list(disorderedList)
+ cloned=list(disorderedList)
# Sort it
if sortfunc:
- sorted.sort(sortfunc)
- else:
- sorted.sort()
- # Return it sorted
- return sorted
+ return sorted(cloned,key=cmp_to_key(sortfunc))
+ return sorted(cloned)
def printSeparator(indent=''):
printSeparatorToFile(None,indent)
@@ -219,7 +218,7 @@ def wrapLine(line,wrapLen=100, eol='\n',
def getIndent(depth=0):
indent=''
if depth < 0:
- raise ValueError, 'Can\'t have a negative indent : ' + `depth`
+ raise ValueError('Can\'t have a negative indent : ' + repr(depth))
if depth > 0:
while depth:
indent = indent + ' '
@@ -228,7 +227,7 @@ def getIndent(depth=0):
def formatException(ei):
import traceback
- sio = StringIO.StringIO()
+ sio = io.StringIO()
traceback.print_exception(ei[0], ei[1], ei[2], None, sio)
s = sio.getvalue()
sio.close()
@@ -242,7 +241,7 @@ def getBeanAttributes(bean):
if name.startswith('__') and name.endswith('__'): continue
accessor=getattr(bean,name)
# avoid metadata, non-methods, methods other than (is|get)*
- if isinstance(accessor,types.TypeType): continue
+ if isinstance(accessor,type): continue
# Ignore non-methods
if not isinstance(accessor,types.MethodType): continue
# Ignore non-callable methods (????)
@@ -315,7 +314,7 @@ def initializeGarbageCollection():
tracked = len(gc.get_objects())
log.debug('GC: Enabled %s : Tracked %s : Threshold %s' \
- % (`enabled`, `tracked`,`threshold`))
+ % (repr(enabled), repr(tracked),repr(threshold)))
gc.enable()
gc.set_threshold(10,10,10)
@@ -351,7 +350,7 @@ def invokeGarbageCollection(marker=''):
# Curiousity..
if unreachable:
- message='Objects Unreachable by GC : ' + `unreachable`
+ message='Objects Unreachable by GC : ' + repr(unreachable)
if marker:
message+=' @ '
message+=marker
Modified: gump/live/python/gump/util/domutils.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/util/domutils.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/util/domutils.py (original)
+++ gump/live/python/gump/util/domutils.py Mon Nov 30 21:45:38 2020
@@ -43,15 +43,15 @@ class NamedChildElementNodeIterator(Abst
self.name=name
self.iter=iter(element.childNodes)
- def next(self):
- nextNode=self.iter.next()
+ def __next__(self):
+ nextNode=next(self.iter)
while nextNode:
# Skip all but elements
if nextNode.nodeType == xml.dom.Node.ELEMENT_NODE:
# Skip if not names as we want
if self.name==nextNode.tagName:
return nextNode
- nextNode=self.iter.next()
+ nextNode=next(self.iter)
# Ought never get here, either return the node
# or StopIterator ought be thrown
@@ -88,7 +88,7 @@ def transferDomNameValue(target,name,val
# See what attribute we'd like to set with this
attrName=name
- if mapping and mapping.has_key(name): attrName=mapping[name]
+ if mapping and name in mapping: attrName=mapping[name]
# We have somewhere to put this value...
if hasattr(target,attrName):
@@ -103,7 +103,7 @@ def transferDomNameValue(target,name,val
value=False
elif attrType is int:
value=int(value)
- elif attrType is str or attrType is unicode:
+ elif attrType is str or attrType is str:
pass
else:
log.warn('Unknown Type %s for Attribute %s [on %s]' % (attrType, attrName, target))
@@ -160,7 +160,7 @@ def getDomChildIterator(element,name):
return NamedChildElementNodeIterator(element,name)
def dumpDom(dom):
- print dom.toprettyxml()
+ print((dom.toprettyxml()))
def hasDomAttribute(element,name):
if element.hasAttributes():
Modified: gump/live/python/gump/util/file.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/util/file.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
Binary files - no diff available.
Modified: gump/live/python/gump/util/http.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/util/http.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/util/http.py (original)
+++ gump/live/python/gump/util/http.py Mon Nov 30 21:45:38 2020
@@ -24,8 +24,8 @@ import shutil
import string
import sys
import time
-import urllib
-import urlparse
+import urllib.request, urllib.parse, urllib.error
+import urllib.parse
# python-2.3 or http://www.red-dove.com/python_logging.html
import logging
@@ -40,12 +40,12 @@ from gump.core.config import dir, switch
#
# Set the User Agent to be Gump...
#
-class GumpUrlOpener(urllib.FancyURLopener):
+class GumpUrlOpener(urllib.request.FancyURLopener):
def __init__(self, *args):
self.version = "Apache-Gump/"+setting.VERSION
- urllib.FancyURLopener.__init__(self, *args)
+ urllib.request.FancyURLopener.__init__(self, *args)
-urllib._urlopener = GumpUrlOpener()
+urllib.request._urlopener = GumpUrlOpener()
###############################################################################
# Functions
@@ -61,7 +61,7 @@ def cacheHTTP(href,cacheDir=dir.cache,op
if not os.path.exists(cacheDir): os.mkdir(cacheDir)
#the name of the cached descriptor
- quotedHref = urllib.quote_plus(href)
+ quotedHref = urllib.parse.quote_plus(href)
#the path of the cached descriptor
cachedHrefFile = cacheDir+'/'+quotedHref
@@ -80,8 +80,8 @@ def cacheHTTP(href,cacheDir=dir.cache,op
#
# urllib ought do some (timestamp oriented) caching also...
#
- urllib.urlretrieve(href, cachedHrefFile)
- except IOError, detail:
+ urllib.request.urlretrieve(href, cachedHrefFile)
+ except IOError as detail:
log.error('Failed to download ['+href+']. Details: ' + str(detail))
try:
os.remove(cachedHrefFile)
Modified: gump/live/python/gump/util/locks.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/util/locks.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/util/locks.py (original)
+++ gump/live/python/gump/util/locks.py Mon Nov 30 21:45:38 2020
@@ -40,11 +40,10 @@ def acquireLock(lockFile):
lock=open(lockFile,'w')
if failed:
- raise RuntimeError, \
- """The lock file [%s] could not be established.""" % lockFile
+ raise RuntimeError("""The lock file [%s] could not be established.""" % lockFile)
# Write this PID into a lock file
- lock.write(`os.getpid()`)
+ lock.write(repr(os.getpid()))
lock.flush()
return lock
Modified: gump/live/python/gump/util/mysql.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/util/mysql.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/util/mysql.py (original)
+++ gump/live/python/gump/util/mysql.py Mon Nov 30 21:45:38 2020
@@ -143,7 +143,7 @@ class DbHelper:
"""
escaped_encoded = ''
- if isinstance(value, types.StringTypes):
+ if isinstance(value, str):
escaped_encoded = "'"
escaped_encoded += MySQLdb.escape_string(value)\
.replace("\\","\\\\").replace("'","\\'")
@@ -173,18 +173,18 @@ class DbHelper:
cursor = self.conn.cursor()
log.debug('SQL: ' + statement)
affected = cursor.execute(statement)
- log.debug('SQL affected: ' + `affected`)
+ log.debug('SQL affected: ' + repr(affected))
if affected > 0: # might be nothing in db yet
row = cursor.fetchall()[0] # Ought be only one...
# Extract values
for column in columns:
- if row.has_key(column) and row[column]:
+ if column in row and row[column]:
settings[column] = row[column]
#print 'Extracted %s -> %s' % ( column, row[column])
- except Exception, details:
+ except Exception as details:
if cursor:
self.logWarnings(cursor)
log.error('SQL Error on [%s] : %s' % (statement, details),
@@ -219,7 +219,7 @@ class DbHelper:
Perform an SQL INSERT
"""
statement = "INSERT INTO %s.%s (" % (self.database, table_name)
- keys = settings.keys()
+ keys = list(settings.keys())
statement += ", ".join(keys)
statement += ") VALUES ("
statement += ", ".join([str(settings[key]) for key in keys])
@@ -242,8 +242,8 @@ class DbHelper:
cursor = self.conn.cursor()
log.debug('SQL: ' + statement)
affected = cursor.execute(statement)
- log.debug('SQL Affected: ' + `affected`)
- except Exception, details:
+ log.debug('SQL Affected: ' + repr(affected))
+ except Exception as details:
if cursor:
self.logWarnings(cursor)
log.error('SQL Error on [%s] : %s' % (statement, details),
@@ -260,7 +260,7 @@ class DbHelper:
generate an update statement. Note: The index is a single name.
"""
statement = "UPDATE %s.%s SET " % (self.database, table_name)
- keys = settings.keys()
+ keys = list(settings.keys())
keys.remove(column_name)
statement += ", ".join([key + '=' + str(settings[key]) for key in keys])
statement += " WHERE %s='%s'" % (column_name, entity_name)
@@ -283,8 +283,8 @@ class DbHelper:
cursor = self.conn.cursor()
log.debug('SQL: ' + statement)
affected = cursor.execute(statement)
- log.debug('SQL Affected: ' + `affected`)
- except Exception, details:
+ log.debug('SQL Affected: ' + repr(affected))
+ except Exception as details:
if cursor:
self.logWarnings(cursor)
log.error('SQL Error on [%s] : %s' % (statement, details),
@@ -320,8 +320,8 @@ class DbHelper:
cursor = self.conn.cursor()
log.debug('SQL: ' + statement)
affected = cursor.execute(statement)
- log.debug('SQL Affected: ' + `affected`)
- except Exception, details:
+ log.debug('SQL Affected: ' + repr(affected))
+ except Exception as details:
if cursor:
self.logWarnings(cursor)
log.error('SQL Error on [%s] : %s' % (statement, details),
Modified: gump/live/python/gump/util/owner.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/util/owner.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/util/owner.py (original)
+++ gump/live/python/gump/util/owner.py Mon Nov 30 21:45:38 2020
@@ -26,7 +26,7 @@ class Ownable:
"""Contains ownership """
def __init__(self,owner=None):
if self == owner:
- raise RuntimeError, "Can set owner to self on " + `self`
+ raise RuntimeError("Can set owner to self on " + repr(self))
self.owner=owner
def __del__(self):
@@ -37,7 +37,7 @@ class Ownable:
def setOwner(self,owner):
if self == owner:
- raise RuntimeError, "Can set owner to self on " + `self`
+ raise RuntimeError("Can set owner to self on " + repr(self))
self.owner=owner
def getOwner(self):
@@ -46,10 +46,10 @@ class Ownable:
def displayOwnership(self,visited=None):
if not visited: visited=[]
if self in visited:
- log.error('Circular path @ ' + `self`)
+ log.error('Circular path @ ' + repr(self))
return
visited.append(self)
- log.info(getIndent(len(visited))+`self`)
+ log.info(getIndent(len(visited))+repr(self))
if self.hasOwner():
self.getOwner().displayOwnership(visited)
return
Modified: gump/live/python/gump/util/process/command.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/util/process/command.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/util/process/command.py (original)
+++ gump/live/python/gump/util/process/command.py Mon Nov 30 21:45:38 2020
@@ -24,11 +24,8 @@ import sys
import logging
import signal
-from types import NoneType
from threading import Timer
-from string import split
-
from gump import log
from gump.core.config import *
from gump.util import *
@@ -72,7 +69,7 @@ class Parameter:
def getParameterFromString(strp):
"""Extract a Parameter Object from a String"""
- parts=split(strp,'=')
+ parts=strp.split('=')
partCount=len(parts)
if partCount==1:
pname=parts[0]
@@ -100,12 +97,12 @@ class Parameters:
self.addNamedParameter(name,value,separator,prefix)
def addNamedParameter(self,name,value=None,separator=' ',prefix=None):
- if self.dict.has_key(name):
+ if name in self.dict:
self.removeParameter(name)
self.addParameter(name,value,separator,prefix)
def addNamedParameterObject(self,param):
- if self.dict.has_key(param.name):
+ if param.name in self.dict:
self.removeParameter(param.name)
self.addParameterObject(param)
@@ -138,7 +135,7 @@ class Parameters:
line += self.getEscapedEntry(param.name)
val = param.value
- if not isinstance(val,NoneType):
+ if val is not None:
line += param.separator
line += self.getEscapedEntry(val)
@@ -160,7 +157,7 @@ class Parameters:
def dump(self,indent=''):
for param in self.list:
- print indent + ' ' + param.name + ' ' + str(param.value) + ' (' + str(param.prefix) + ')'
+ print(indent + ' ' + param.name + ' ' + str(param.value) + ' (' + str(param.prefix) + ')')
class Cmd:
"""Command Line (executable plus parameters)"""
@@ -182,22 +179,22 @@ class Cmd:
self.params.addPrefixedParameter(prefix,name,val,separator)
def addPrefixedParameters(self,prefix,params):
- for p in params.items():
+ for p in list(params.items()):
self.params.addPrefixedParameter(prefix,p.name,p.value,p.separator)
def addPrefixedNamedParameters(self,prefix,params):
- for p in params.items():
+ for p in list(params.items()):
self.params.addPrefixedNamedParameter(prefix,p.name,p.value,p.separator)
def addParameterObject(self,param):
self.params.addParameterObject(param)
def addParameters(self,params):
- for p in params.items():
+ for p in list(params.items()):
self.params.addParameter(p.name,p.value,p.separator,p.prefix)
def addNamedParameters(self,params):
- for p in params.items():
+ for p in list(params.items()):
self.params.addNamedParameter(p.name,p.value,p.separator,p.prefix)
def addEnvironment(self,name,val=None):
@@ -214,16 +211,16 @@ class Cmd:
if self.cwd:
overview += indent + '[Working Directory: ' + self.cwd + ']\n'
if self.env:
- for envKey in self.env.keys():
+ for envKey in list(self.env.keys()):
overview += indent + envKey + ': ' + self.env[envKey] + '\n'
return overview
def dump(self,indent=''):
- print self.overview(indent)
+ print(self.overview(indent))
def getCmdFromString(strcmd, name = None, cwd = None):
"""Extract a Cmd Object from a String"""
- parts = split(strcmd,' ')
+ parts = strcmd.split(' ')
cmdcmd = parts[0]
if not name: name = cmdcmd
cmd = Cmd(cmdcmd, name, cwd)
@@ -292,6 +289,6 @@ class CmdResult:
return deltaToSecs(self.end-self.start)
def dump(self,indent):
- print self.overview(indent)
+ print(self.overview(indent))
Modified: gump/live/python/gump/util/process/launcher.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/util/process/launcher.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/util/process/launcher.py (original)
+++ gump/live/python/gump/util/process/launcher.py Mon Nov 30 21:45:38 2020
@@ -25,8 +25,6 @@ import logging
import signal
import re
-from string import split
-
from gump import log
from gump.core.config import dir
from gump.util import *
@@ -76,7 +74,7 @@ def executeIntoResult(cmd,result,tmp=dir
if cmd.timeout: f.write( 'TIMEOUT: %s\n' % (cmd.timeout))
# Write ENV over-writes...
- for envKey in cmd.env.iterkeys(): f.write('%s: %s\n' % (envKey, cmd.env[envKey]))
+ for envKey in cmd.env.keys(): f.write('%s: %s\n' % (envKey, cmd.env[envKey]))
finally:
# Since we may exit via an exception, close explicitly.
if f: f.close()
@@ -175,7 +173,7 @@ def executeIntoResult(cmd,result,tmp=dir
else:
result.state = command.CMD_STATE_SUCCESS
- except Exception, details :
+ except Exception as details :
log.error('Failed to launch command. Details: ' + str(details), exc_info=1)
result.exit_code = -1
result.state = command.CMD_STATE_FAILED
@@ -211,7 +209,7 @@ def shutdownProcessAndProcessGroup(pid):
os.killpg(pgrpID,signal.SIGKILL)
else:
log.warn('No such PID' + str(pid) + '.')
- except Exception, details:
+ except Exception as details:
log.error('Failed to dispatch signal ' + str(details), exc_info=1)
@@ -223,7 +221,7 @@ def shutdownProcesses():
log.warn('Kill all child processed (anything launched by PID %s)' % (pid))
try:
os.kill(pid,signal.SIGKILL)
- except Exception, details:
+ except Exception as details:
log.error('Failed to dispatch signal ' + str(details), exc_info=1)
def runProcess(execFilename,standaloneProcess=1):
@@ -233,7 +231,7 @@ def runProcess(execFilename,standalonePr
"""
execFile = None
try:
- execFile = file(execFilename,'r')
+ execFile = open(execFilename,'r')
# Split into a dict of NAME: VALUE (from file)
execInfo = dict(re.findall('(.*?): (.*)', execFile.read()))
@@ -245,10 +243,10 @@ def runProcess(execFilename,standalonePr
cmd = execInfo['CMD']
outputFile = execInfo['OUTPUT']
cwd = None
- if execInfo.has_key('CWD'): cwd = execInfo['CWD']
+ if 'CWD' in execInfo: cwd = execInfo['CWD']
tmp = execInfo['TMP']
timeout = 0
- if execInfo.has_key('TIMEOUT'): timeout = int(execInfo['TIMEOUT'])
+ if 'TIMEOUT' in execInfo: timeout = int(execInfo['TIMEOUT'])
# Make the TMP if needed
if not os.path.exists(tmp): os.makedirs(tmp)
@@ -260,7 +258,7 @@ def runProcess(execFilename,standalonePr
os.chdir(cwdpath)
# Write ENV over-writes...
- for envKey in execInfo.iterkeys():
+ for envKey in execInfo.keys():
if not envKey in ['CMD','TMP','CWD']:
os.environ[envKey] = execInfo[envKey]
Modified: gump/live/python/gump/util/smtp.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/util/smtp.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/util/smtp.py (original)
+++ gump/live/python/gump/util/smtp.py Mon Nov 30 21:45:38 2020
@@ -23,7 +23,7 @@
from gump import log
from gump.core.config import *
from gump.util import *
-from email.Header import Header
+from email.header import Header
import smtplib, string
@@ -111,9 +111,9 @@ def mail(toaddrs,fromaddr,message,server
sent=True
else:
for failure in failures:
- log.error('Failed to send e-mail to : ' + `failure`)
+ log.error('Failed to send e-mail to : ' + repr(failure))
- except Exception, details:
+ except Exception as details:
sent=False
log.error('Failed to send e-mail: ' + str(details))
@@ -149,6 +149,6 @@ if __name__=='__main__':
mail(['ajack@trysybase.com'],default.email,email,default.mailserver)
- print sanitizeAddress('Adam Jack <aj...@trysybase.com>')
+ print((sanitizeAddress('Adam Jack <aj...@trysybase.com>')))
Modified: gump/live/python/gump/util/sync.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/util/sync.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/util/sync.py (original)
+++ gump/live/python/gump/util/sync.py Mon Nov 30 21:45:38 2020
@@ -65,7 +65,7 @@ class PathWalker(Annotatable):
# In later case control open/close.
doClose = 0
if self.output:
- if isinstance(self.output, types.StringTypes):
+ if isinstance(self.output, str):
doClose = 1
#log.debug(' changes to [' + self.output + ']')
self.outputStream = open(self.output, 'w')
@@ -77,22 +77,22 @@ class PathWalker(Annotatable):
if not os.path.exists(self.sourcedir):
log.error('Exiting sync, source directory does not exist ['
+ self.sourcedir + ']')
- raise IOError, 'source directory does not exist [' \
- + self.sourcedir + ']'
+ raise IOError('source directory does not exist [' \
+ + self.sourcedir + ']')
if not os.path.isdir(self.sourcedir):
log.error('Exiting sync, source is not a directory ['
+ self.sourcedir + ']')
- raise IOError, 'source is not a directory [' \
- + self.sourcedir + ']'
+ raise IOError('source is not a directory [' \
+ + self.sourcedir + ']')
if not os.path.exists(self.targetdir):
try:
os.makedirs(self.targetdir)
- except Exception, details:
+ except Exception as details:
log.exception('failed on ' + str(details))
- raise IOError, 'could not create directory [' \
- + self.targetdir + ']'
+ raise IOError('could not create directory [' \
+ + self.targetdir + ']')
self.copytree(self.sourcedir, self.targetdir, 1)
@@ -149,7 +149,7 @@ class PathWalker(Annotatable):
def copytree(self, src, dst, symlinks = 0):
# Only supported on some platforms.
- if 'posix' <> os.name:
+ if 'posix' != os.name:
symlinks = 0
#
@@ -197,11 +197,11 @@ class PathWalker(Annotatable):
srcname = os.path.join(src, name)
dstname = os.path.join(dst, name)
- except UnicodeDecodeError, why:
+ except UnicodeDecodeError as why:
message = 'Unicode Error. Can\'t copy [%s] in [%s] to [%s]: [%s]'\
- % (`name`, `src`, `dst`, str(why))
+ % (repr(name), repr(src), repr(dst), str(why))
log.exception(message)
- raise RuntimeError, message
+ raise RuntimeError(message)
try:
if symlinks and os.path.islink(srcname):
@@ -221,12 +221,12 @@ class PathWalker(Annotatable):
# Selectively copy file
self.maybecopy(srcname, dstname)
- except (IOError, os.error), why:
- message = "Can't copy [%s] to [%s]: [%s]" % (`srcname`,
- `dstname`,
+ except (IOError, os.error) as why:
+ message = "Can't copy [%s] to [%s]: [%s]" % (repr(srcname),
+ repr(dstname),
str(why))
log.exception(message)
- raise IOError, message
+ raise IOError(message)
def epurate(self, sourcedir, destdir, acceptablefiles, existingfiles):
"""
@@ -251,18 +251,18 @@ class PathWalker(Annotatable):
if S_ISDIR(destinationStat[ST_MODE]):
if self.isDebug():
log.debug('Attempting to remove directory [%s]'
- % (`tobedeleted`))
+ % (repr(tobedeleted)))
self.displayAction(False, ' -D ', tobedeleted)
shutil.rmtree(tobedeleted)
else:
if self.isDebug():
log.debug('Attempting to remove file [%s]'
- % (`tobedeleted`))
+ % (repr(tobedeleted)))
self.displayAction(False, ' -F ', tobedeleted)
os.remove(tobedeleted)
- except (IOError, os.error), why:
+ except (IOError, os.error) as why:
log.warning('Error removing [%s] - %s. Try again.'
- % (`tobedeleted`, why))
+ % (repr(tobedeleted), why))
self.displayAction(False, ' -X ', tobedeleted)
shutil.rmtree(tobedeleted, True)
@@ -292,7 +292,7 @@ class PathWalker(Annotatable):
os.path.isdir(fulldestfile):
if self.isDebug():
log.debug('Removing file [%s] to be replaced by directory'
- %(`fulldestfile`))
+ %(repr(fulldestfile)))
os.remove(fulldestfile)
self.displayAction(True, ' -F ', fulldestfile,
'Need a directory.')
@@ -301,7 +301,7 @@ class PathWalker(Annotatable):
os.path.isdir(fulldestfile):
if self.isDebug():
log.debug('Removing directory [%s] to be replaced by file'
- %(`fulldestfile`))
+ %(repr(fulldestfile)))
self.displayAction(True, ' -D ', fulldestfile,
'Need a file.')
shutil.rmtree(fulldestfile)
@@ -344,7 +344,7 @@ class PathWalker(Annotatable):
if performCopy:
if self.isDebug():
log.debug("Attempting copy from [%s] to [%s]"
- %(`srcname`, `dstname`))
+ %(repr(srcname), repr(dstname)))
self.displayAction(True, ' U> ', dstname, reason)
if os.path.lexists(dstname):
os.remove(dstname)
Modified: gump/live/python/gump/util/tasks.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/util/tasks.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/util/tasks.py (original)
+++ gump/live/python/gump/util/tasks.py Mon Nov 30 21:45:38 2020
@@ -51,7 +51,7 @@ class Task(Ownable):
s=''
if self.id:
- s+=`self.id`
+ s+=repr(self.id)
if s:
s+=':'
@@ -61,7 +61,7 @@ class Task(Ownable):
parent=self.getParentTask()
if parent.hasId():
s+=':'
- s+=`parent.getId()`
+ s+=repr(parent.getId())
if self.timeRange:
s+=':'
@@ -171,7 +171,7 @@ class TaskList(Ownable):
self.performed.append(task)
def __str__(self):
- return self.name+'['+`len(self.todo)`+':'+`len(self.working)`+':'+`len(self.performed)`+']'
+ return self.name+'['+repr(len(self.todo))+':'+repr(len(self.working))+':'+repr(len(self.performed))+']'
def perform(self,worker):
while self.hasTasksTodo():
Modified: gump/live/python/gump/util/threads/tools.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/util/threads/tools.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/util/threads/tools.py (original)
+++ gump/live/python/gump/util/threads/tools.py Mon Nov 30 21:45:38 2020
@@ -56,7 +56,7 @@ class WorkerThread(Thread):
self.workList=workList
def run(self):
- log.debug('Thread ' + `self` + ' started.')
+ log.debug('Thread ' + repr(self) + ' started.')
try:
work = self.getWork()
@@ -72,7 +72,7 @@ class WorkerThread(Thread):
finally:
self.done.release()
- log.debug('Thread ' + `self` + ' completed.')
+ log.debug('Thread ' + repr(self) + ' completed.')
def getWork(self):
return self.workList.getWork()
@@ -90,7 +90,7 @@ class WorkerThreadGroup:
def start(self):
for i in range(self.count):
- name = self.name + ':' + `(1+i)`
+ name = self.name + ':' + repr((1+i))
# Create a new Thread
thread = self.cls(name,self.done,self.workList)
@@ -105,6 +105,6 @@ class WorkerThreadGroup:
# Try to acquire every count
for i in range(self.count):
self.done.acquire()
- log.debug('Completed. Thread #' + `i` + '.')
+ log.debug('Completed. Thread #' + repr(i) + '.')
log.debug('All threads completed.')
Modified: gump/live/python/gump/util/timing.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/util/timing.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/util/timing.py (original)
+++ gump/live/python/gump/util/timing.py Mon Nov 30 21:45:38 2020
@@ -100,7 +100,7 @@ def deltaToSecs(delta):
Convert a delta into it's total seconds
"""
if delta < ZERO_DELTA:
- raise RuntimeError, "Can not cope with backwards deltas"
+ raise RuntimeError("Can not cope with backwards deltas")
# Convert days to seconds, and add extra seconds.
return int(round(((delta.days * 24 * 3600) + delta.seconds),0))
@@ -256,7 +256,7 @@ class TimeStamp:
def getTimestamp(self):
return self.timestamp
- def __nonzero__(self):
+ def __bool__(self):
if self.timestamp: return True
return False
@@ -265,6 +265,9 @@ class TimeStamp:
def __cmp__(self,other):
return (self.timestamp < other.timestamp)
+
+ def __lt__(self,other):
+ return (self.timestamp < other.timestamp)
class TimeStampRange(TimeStamp):
"""
@@ -284,7 +287,7 @@ class TimeStampRange(TimeStamp):
self.endTimeStamp=TimeStamp(end)
self.external=external
- def __nonzero__(self):
+ def __bool__(self):
return self.getElapsedSecs() > 0
def __str__(self):
@@ -300,7 +303,7 @@ class TimeStampRange(TimeStamp):
return self.hasTimestamp()
def getStart(self):
- return self
+ return TimeStamp(self.name,self.timestamp)
def getEnd(self):
return self.endTimeStamp
@@ -449,7 +452,7 @@ class TimeStampSet(list):
elif isinstance(entry,TimeStamp):
self.registerStamp(entry)
else:
- raise RuntimeError, 'Unknown timestamp: ' + `entry`
+ raise RuntimeError('Unknown timestamp: ' + repr(entry))
def dump(self, indent=0, output=sys.stdout):
spacing=getIndent(indent)
Modified: gump/live/python/gump/util/tools.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/util/tools.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/util/tools.py (original)
+++ gump/live/python/gump/util/tools.py Mon Nov 30 21:45:38 2020
@@ -20,7 +20,7 @@
"""
import logging
-import types, StringIO
+import types, io
import shutil
from gump import log
@@ -40,7 +40,7 @@ def listDirectoryAsWork(workable,directo
ok=result.state==gump.util.process.command.CMD_STATE_SUCCESS
if not ok:
log.error('Failed to list [' + directory + ']')
- except Exception, details:
+ except Exception as details:
ok=0
log.error('Failed to list [' + directory + '] : ' + str(details))
@@ -82,7 +82,7 @@ def catFileAsWork(workable,file,name=Non
ok=result.isOk()
if not ok:
log.error('Failed to cat [' + str(file) + ']')
- except Exception, details:
+ except Exception as details:
ok=0
log.error('Failed to cat [' + str(file) + '] : ' + str(details))
@@ -179,7 +179,7 @@ def syncDirectories(sourcedir,destdir,an
return changes
def wipeDirectoryTree(dir, recreateDir = True):
- log.info('Wipe Directory [' + `dir` + ']')
+ log.info('Wipe Directory [' + repr(dir) + ']')
if os.path.exists(dir):
try:
shutil.rmtree(dir)
@@ -221,7 +221,7 @@ def tailFile(file,lines,wrapLen=0,eol=No
finally:
if o: o.close()
- except Exception, details:
+ except Exception as details:
log.error('Failed to tail :' + file + ' : ' + str(details), exc_info=1)
return taillines
@@ -257,4 +257,4 @@ if __name__=='__main__':
# dump(log)
if len(sys.argv) > 0:
- print tailFileToString(sys.argv[1], 5 )
+ print((tailFileToString(sys.argv[1], 5 )))
Modified: gump/live/python/gump/util/work.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/util/work.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/gump/util/work.py (original)
+++ gump/live/python/gump/util/work.py Mon Nov 30 21:45:38 2020
@@ -20,7 +20,6 @@
"""
from time import localtime, strftime, tzname
-from string import lower, capitalize
from gump.core.model.state import *
from gump.util.owner import *
@@ -189,12 +188,12 @@ class WorkList(list,Ownable):
def add(self,item):
if item.hasOwner():
- raise RuntimeError, 'WorkItem already owned, can\'t add to list.'
+ raise RuntimeError('WorkItem already owned, can\'t add to list.')
# Keep unique within the scope of this list
name=item.getName()
uniquifier=1
- while self.nameIndex.has_key(name):
+ while name in self.nameIndex:
name=item.getName()+str(uniquifier)
uniquifier+=1
item.setName(name)
Modified: gump/live/python/misc/pgrp.py
URL: http://svn.apache.org/viewvc/gump/live/python/misc/pgrp.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/misc/pgrp.py (original)
+++ gump/live/python/misc/pgrp.py Mon Nov 30 21:45:38 2020
@@ -9,19 +9,19 @@ def shutdownProcessAndProcessGroup(pid):
"""
Kill this group (i.e. instigator and all child processes).
"""
- print 'Kill process group (anything launched by PID' + str(pid) + ')'
+ print(('Kill process group (anything launched by PID' + str(pid) + ')'))
try:
pgrpID=os.getpgid(pid)
if -1 != pgrpID:
- print 'Kill process group : (' + str(pgrpID) + ')'
+ print(('Kill process group : (' + str(pgrpID) + ')'))
os.killpg(pgrpID,signal.SIGHUP)
else:
- print 'No such PID' + str(pid) + '.'
- except Exception, details:
- print 'Failed to dispatch signal ' + str(details)
+ print(('No such PID' + str(pid) + '.'))
+ except Exception as details:
+ print(('Failed to dispatch signal ' + str(details)))
def hup(sig,stack):
- print "HUP : %s:%s" % ( os.getpgrp(), os.getpid() )
+ print(("HUP : %s:%s" % ( os.getpgrp(), os.getpid() )))
sys.exit(1)
if __name__=='__main__':
@@ -46,7 +46,7 @@ if __name__=='__main__':
else:
os.waitpid(forkPID,0)
- print 'Child Exit : %s' % os.getpid()
+ print(('Child Exit : %s' % os.getpid()))
# Parent gets real PID
else:
@@ -61,9 +61,9 @@ if __name__=='__main__':
# Run the command
waitcode = os.waitpid(forkPID,0)
- print 'Wait Code : %s : %s ' % ( waitcode, timer )
+ print(('Wait Code : %s : %s ' % ( waitcode, timer )))
# Stop timer (if still running)
if timer and timer.isAlive(): timer.cancel()
- print 'Exit : %s:%s' % ( os.getpgrp(), os.getpid() )
\ No newline at end of file
+ print(('Exit : %s:%s' % ( os.getpgrp(), os.getpid() )))
Modified: gump/live/python/tool/commitCheck.py
URL: http://svn.apache.org/viewvc/gump/live/python/tool/commitCheck.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/tool/commitCheck.py (original)
+++ gump/live/python/tool/commitCheck.py Mon Nov 30 21:45:38 2020
@@ -28,7 +28,7 @@ import socket
import time
import signal
import smtplib
-import StringIO
+import io
from xml.dom import minidom
LINE=' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - GUMP'
@@ -48,7 +48,7 @@ def runCommand(command,args='',dir=None,
log.write('Executing with CWD: [' + dir + ']\n')
if not os.path.exists(cwdpath): os.makedirs(dir)
os.chdir(cwdpath)
- except Exception, details :
+ except Exception as details :
# Log the problem and re-raise
log.write('Failed to create/change CWD [' + cwdpath + ']. Details: ' + str(details) + '\n')
return 0
@@ -87,7 +87,7 @@ def runCommand(command,args='',dir=None,
catFile(log,outputFile)
os.remove(outputFile)
- log.write('Exit Code : ' + `exit_code` + '\n')
+ log.write('Exit Code : ' + repr(exit_code) + '\n')
finally:
if originalCWD: os.chdir(originalCWD)
@@ -113,10 +113,10 @@ if os.path.exists(lockFile):
# :TODO: Ought we look at the contents, get the PID of the
# supposed other Gump, and determine if it is still alive
# or not?
- print """The lock file [%s] exists.
+ print("""The lock file [%s] exists.
Either Gump is still running, or it terminated very abnormally.
Please resolve this (waiting or removing the lock file) before retrying.
- """ % lockFile
+ """ % lockFile)
sys.exit(1)
# Set the signal handler to ignore hangups
@@ -130,7 +130,7 @@ except:
# Write this PID into a lock file
lock=open(lockFile,'w')
-lock.write(`os.getpid()`)
+lock.write(repr(os.getpid()))
lock.close()
# Enable a log
@@ -149,15 +149,15 @@ try:
log.write('- GUMP run on host : ' + hostname + '\n')
log.write('- GUMP run @ : ' + time.strftime('%d %b %Y %H:%M:%S', time.gmtime()) + '\n')
- log.write('- GUMP run by Python : ' + `sys.version` + '\n')
- log.write('- GUMP run on OS : ' + `os.name` + '\n')
+ log.write('- GUMP run by Python : ' + repr(sys.version) + '\n')
+ log.write('- GUMP run on OS : ' + repr(os.name) + '\n')
log.write('- GUMP run in env : \n')
#
# Add Gump to Python Path...
#
pythonPath=''
- if os.environ.has_key('PYTHONPATH'):
+ if 'PYTHONPATH' in os.environ:
pythonPath=os.environ['PYTHONPATH']
pythonPath+=os.pathsep
absGumpPython=os.path.abspath(os.path.join(os.getcwd(),'python'))
@@ -242,7 +242,7 @@ finally:
if result:
logTitle='The Apache Gump log...'
catFile(sys.stdout, logFile, logTitle)
- print "Something failed..."
+ print("Something failed...")
# bye!
sys.exit(result)
Modified: gump/live/python/tool/profileResults.py
URL: http://svn.apache.org/viewvc/gump/live/python/tool/profileResults.py?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/python/tool/profileResults.py (original)
+++ gump/live/python/tool/profileResults.py Mon Nov 30 21:45:38 2020
@@ -27,8 +27,8 @@ import pstats
SEP='--------------------------------------------------------------------'
def title(t):
- print SEP
- print t
+ print(SEP)
+ print(t)
def printStats(sort,percentage,t):
title(t)
Modified: gump/live/test/gumptest.sh
URL: http://svn.apache.org/viewvc/gump/live/test/gumptest.sh?rev=1883964&r1=1883963&r2=1883964&view=diff
==============================================================================
--- gump/live/test/gumptest.sh (original)
+++ gump/live/test/gumptest.sh Mon Nov 30 21:45:38 2020
@@ -26,11 +26,11 @@ export
# Determine the Python to use... (if not told)
#
if [ "" == "$GUMP_PYTHON" ] ; then
- export GUMP_PYTHON="`which python2.3`"
+ export GUMP_PYTHON="`which python3`"
if [ "" == "$GUMP_PYTHON" ] ; then
export GUMP_PYTHON="`which python`"
if [ "" == "$GUMP_PYTHON" ] ; then
- echo "No Python (python2.3 nor python) found in path."
+ echo "No Python (python3 nor python) found in path."
exit 1
fi
fi