diff --git a/SunGridEngine/SgeConfig.py b/SunGridEngine/SgeConfig.py index 432c8e8..a37a6d8 100755 --- a/SunGridEngine/SgeConfig.py +++ b/SunGridEngine/SgeConfig.py @@ -74,7 +74,7 @@ class SgeConfig: self.m_attrs[ matchObj.group("attrName") ] = matchObj.group("attrValue") def asFormat1String( self ): strResult = "" - for (k,v) in self.m_attrs.iteritems(): + for (k,v) in self.m_attrs.items(): #print "%s %s" % (k,v) strResult += "%s %s\n" % (k,v) #print strSgeConfigString @@ -85,7 +85,7 @@ class SgeConfig: if iNumAttrs == 0: return "NONE" iAttr = 0 - for (k,v) in self.m_attrs.iteritems(): + for (k,v) in self.m_attrs.items(): #print "%s %s" % (k,v) strResult += "%s=%s" % (k,v) if iAttr != (iNumAttrs - 1): @@ -94,7 +94,7 @@ class SgeConfig: #print strSgeConfigString return strResult def dump( self ): - for (k,v) in self.m_attrs.iteritems(): - print "['%s']='%s'" % (k,v) + for (k,v) in self.m_attrs.items(): + print("['%s']='%s'" % (k,v)) diff --git a/Util.py b/Util.py index 188e615..d3616bf 100644 --- a/Util.py +++ b/Util.py @@ -6,8 +6,8 @@ import re # import os # import signal import smtplib -from email.MIMEText import MIMEText -from HTMLParser import HTMLParser +from email.mime.text import MIMEText +from html.parser import HTMLParser def sendTextMail(strFrom, to, strSubject, text): @@ -37,7 +37,7 @@ def getHostName(): def log(message): - print time.asctime(time.localtime()) + ' : ' + message + print(time.asctime(time.localtime()) + ' : ' + message) def executeProgram(astrArguments): @@ -45,7 +45,7 @@ def executeProgram(astrArguments): popen = subprocess.Popen( astrArguments, bufsize=1, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # bufsize=1 seems to prevent deadlocks that happen 50% the time stdout, stderr = popen.communicate() # popen.wait() - result = (popen.returncode, stdout, stderr) + result = (popen.returncode, stdout.decode(), stderr) # log('executeProgram : command %s popen.pid = %d' % (astrArguments[0], popen.pid)) # os.kill(popen.pid, signal.SIGTERM) return result @@ -59,7 +59,7 @@ def executeCommand(command): # if we don't specify the optional executable argument, then the default non interactive shell will be used. On debian, the default non-interactive shell is dash, which doesn't understand the keyword 'source' that we use in many places stdout, stderr = popen.communicate() # popen.wait() - result = (popen.returncode, stdout, stderr) + result = (popen.returncode, stdout.decode(), stderr.decode()) return result @@ -99,15 +99,15 @@ def getUpsStatus(): def GetTokenList(self): return self.TokenList - import urllib2 + from urllib.request import urlopen try: url = 'http://Net Vision:public@129.20.27.119/PageMonComprehensive.html' - f = urllib2.urlopen(url) + f = urlopen(url) res = f.read() f.close() except: - print "bad read" + print("bad read") return h = MyHTMLParser() h.feed(res)