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/29 00:59:45 UTC
svn commit: r1883919 [3/3] - in /gump/branches/python3:
python/gump/actor/document/ python/gump/actor/document/text/
python/gump/actor/document/xdocs/ python/gump/actor/notify/
python/gump/actor/repository/ python/gump/actor/results/
python/gump/actor/...
Modified: gump/branches/python3/python/gump/tool/svg/depdiag.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/gump/tool/svg/depdiag.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/python/gump/tool/svg/depdiag.py (original)
+++ gump/branches/python3/python/gump/tool/svg/depdiag.py Sun Nov 29 00:59:43 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/branches/python3/python/gump/tool/svg/drawing.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/gump/tool/svg/drawing.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/python/gump/tool/svg/drawing.py (original)
+++ gump/branches/python3/python/gump/tool/svg/drawing.py Sun Nov 29 00:59:43 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/branches/python3/python/gump/tool/svg/svg.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/gump/tool/svg/svg.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/python/gump/tool/svg/svg.py (original)
+++ gump/branches/python3/python/gump/tool/svg/svg.py Sun Nov 29 00:59:43 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/branches/python3/python/gump/util/__init__.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/gump/util/__init__.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/python/gump/util/__init__.py (original)
+++ gump/branches/python3/python/gump/util/__init__.py Sun Nov 29 00:59:43 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/branches/python3/python/gump/util/domutils.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/gump/util/domutils.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/python/gump/util/domutils.py (original)
+++ gump/branches/python3/python/gump/util/domutils.py Sun Nov 29 00:59:43 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/branches/python3/python/gump/util/file.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/gump/util/file.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
Binary files - no diff available.
Modified: gump/branches/python3/python/gump/util/http.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/gump/util/http.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/python/gump/util/http.py (original)
+++ gump/branches/python3/python/gump/util/http.py Sun Nov 29 00:59:43 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/branches/python3/python/gump/util/locks.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/gump/util/locks.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/python/gump/util/locks.py (original)
+++ gump/branches/python3/python/gump/util/locks.py Sun Nov 29 00:59:43 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/branches/python3/python/gump/util/mysql.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/gump/util/mysql.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/python/gump/util/mysql.py (original)
+++ gump/branches/python3/python/gump/util/mysql.py Sun Nov 29 00:59:43 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/branches/python3/python/gump/util/owner.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/gump/util/owner.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/python/gump/util/owner.py (original)
+++ gump/branches/python3/python/gump/util/owner.py Sun Nov 29 00:59:43 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/branches/python3/python/gump/util/process/command.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/gump/util/process/command.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/python/gump/util/process/command.py (original)
+++ gump/branches/python3/python/gump/util/process/command.py Sun Nov 29 00:59:43 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/branches/python3/python/gump/util/process/launcher.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/gump/util/process/launcher.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/python/gump/util/process/launcher.py (original)
+++ gump/branches/python3/python/gump/util/process/launcher.py Sun Nov 29 00:59:43 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/branches/python3/python/gump/util/smtp.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/gump/util/smtp.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/python/gump/util/smtp.py (original)
+++ gump/branches/python3/python/gump/util/smtp.py Sun Nov 29 00:59:43 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/branches/python3/python/gump/util/sync.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/gump/util/sync.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/python/gump/util/sync.py (original)
+++ gump/branches/python3/python/gump/util/sync.py Sun Nov 29 00:59:43 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/branches/python3/python/gump/util/tasks.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/gump/util/tasks.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/python/gump/util/tasks.py (original)
+++ gump/branches/python3/python/gump/util/tasks.py Sun Nov 29 00:59:43 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/branches/python3/python/gump/util/threads/tools.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/gump/util/threads/tools.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/python/gump/util/threads/tools.py (original)
+++ gump/branches/python3/python/gump/util/threads/tools.py Sun Nov 29 00:59:43 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/branches/python3/python/gump/util/timing.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/gump/util/timing.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/python/gump/util/timing.py (original)
+++ gump/branches/python3/python/gump/util/timing.py Sun Nov 29 00:59:43 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/branches/python3/python/gump/util/tools.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/gump/util/tools.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/python/gump/util/tools.py (original)
+++ gump/branches/python3/python/gump/util/tools.py Sun Nov 29 00:59:43 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/branches/python3/python/gump/util/work.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/gump/util/work.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/python/gump/util/work.py (original)
+++ gump/branches/python3/python/gump/util/work.py Sun Nov 29 00:59:43 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/branches/python3/python/misc/pgrp.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/misc/pgrp.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/python/misc/pgrp.py (original)
+++ gump/branches/python3/python/misc/pgrp.py Sun Nov 29 00:59:43 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/branches/python3/python/tool/commitCheck.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/tool/commitCheck.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/python/tool/commitCheck.py (original)
+++ gump/branches/python3/python/tool/commitCheck.py Sun Nov 29 00:59:43 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/branches/python3/python/tool/profileResults.py
URL: http://svn.apache.org/viewvc/gump/branches/python3/python/tool/profileResults.py?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/python/tool/profileResults.py (original)
+++ gump/branches/python3/python/tool/profileResults.py Sun Nov 29 00:59:43 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/branches/python3/test/gumptest.sh
URL: http://svn.apache.org/viewvc/gump/branches/python3/test/gumptest.sh?rev=1883919&r1=1883918&r2=1883919&view=diff
==============================================================================
--- gump/branches/python3/test/gumptest.sh (original)
+++ gump/branches/python3/test/gumptest.sh Sun Nov 29 00:59:43 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