Apply some 2to3 transforms that don't cause issues in 2.6
(Bitbake rev: d39ab776e7ceaefc8361150151cf0892dcb70d9c) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
This commit is contained in:
parent
5b216c8000
commit
1180bab54e
|
@ -140,7 +140,7 @@ def exec_func(func, d, dirs = None):
|
|||
so = os.popen("tee \"%s\"" % logfile, "w")
|
||||
else:
|
||||
so = file(logfile, 'w')
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
bb.msg.error(bb.msg.domain.Build, "opening log file: %s" % e)
|
||||
pass
|
||||
|
||||
|
@ -285,7 +285,7 @@ def exec_task(task, d):
|
|||
event.fire(TaskStarted(task, localdata), localdata)
|
||||
exec_func(task, localdata)
|
||||
event.fire(TaskSucceeded(task, localdata), localdata)
|
||||
except FuncFailed, message:
|
||||
except FuncFailed as message:
|
||||
# Try to extract the optional logfile
|
||||
try:
|
||||
(msg, logfile) = message
|
||||
|
|
|
@ -82,9 +82,9 @@ class Cache:
|
|||
p = pickle.Unpickler(file(self.cachefile, "rb"))
|
||||
self.depends_cache, version_data = p.load()
|
||||
if version_data['CACHE_VER'] != __cache_version__:
|
||||
raise ValueError, 'Cache Version Mismatch'
|
||||
raise ValueError('Cache Version Mismatch')
|
||||
if version_data['BITBAKE_VER'] != bb.__version__:
|
||||
raise ValueError, 'Bitbake Version Mismatch'
|
||||
raise ValueError('Bitbake Version Mismatch')
|
||||
except EOFError:
|
||||
bb.msg.note(1, bb.msg.domain.Cache, "Truncated cache found, rebuilding...")
|
||||
self.depends_cache = {}
|
||||
|
|
|
@ -54,8 +54,8 @@ def createDaemon(function, logfile):
|
|||
# and inherits the parent's process group ID. This step is required
|
||||
# to insure that the next call to os.setsid is successful.
|
||||
pid = os.fork()
|
||||
except OSError, e:
|
||||
raise Exception, "%s [%d]" % (e.strerror, e.errno)
|
||||
except OSError as e:
|
||||
raise Exception("%s [%d]" % (e.strerror, e.errno))
|
||||
|
||||
if (pid == 0): # The first child.
|
||||
# To become the session leader of this new session and the process group
|
||||
|
@ -102,8 +102,8 @@ def createDaemon(function, logfile):
|
|||
# longer a session leader, preventing the daemon from ever acquiring
|
||||
# a controlling terminal.
|
||||
pid = os.fork() # Fork a second child.
|
||||
except OSError, e:
|
||||
raise Exception, "%s [%d]" % (e.strerror, e.errno)
|
||||
except OSError as e:
|
||||
raise Exception("%s [%d]" % (e.strerror, e.errno))
|
||||
|
||||
if (pid == 0): # The second child.
|
||||
# We probably don't want the file mode creation mask inherited from
|
||||
|
|
|
@ -193,7 +193,7 @@ def emit_var(var, o=sys.__stdout__, d = init(), all=False):
|
|||
if all:
|
||||
o.write('# %s=%s\n' % (var, oval))
|
||||
|
||||
if type(val) is not types.StringType:
|
||||
if not isinstance(val, types.StringType):
|
||||
return 0
|
||||
|
||||
if (var.find("-") != -1 or var.find(".") != -1 or var.find('{') != -1 or var.find('}') != -1 or var.find('+') != -1) and not all:
|
||||
|
|
|
@ -66,10 +66,10 @@ class DataSmart:
|
|||
code = match.group()[3:-1]
|
||||
codeobj = compile(code.strip(), varname or "<expansion>", "eval")
|
||||
s = utils.better_eval(codeobj, {"d": self})
|
||||
if type(s) == types.IntType: s = str(s)
|
||||
if isinstance(s, types.IntType): s = str(s)
|
||||
return s
|
||||
|
||||
if type(s) is not types.StringType: # sanity check
|
||||
if not isinstance(s, types.StringType): # sanity check
|
||||
return s
|
||||
|
||||
if varname and varname in self.expand_cache:
|
||||
|
@ -81,7 +81,7 @@ class DataSmart:
|
|||
s = __expand_var_regexp__.sub(var_sub, s)
|
||||
s = __expand_python_regexp__.sub(python_sub, s)
|
||||
if s == olds: break
|
||||
if type(s) is not types.StringType: # sanity check
|
||||
if not isinstance(s, types.StringType): # sanity check
|
||||
bb.msg.error(bb.msg.domain.Data, 'expansion of %s returned non-string %s' % (olds, s))
|
||||
except KeyboardInterrupt:
|
||||
raise
|
||||
|
@ -118,7 +118,7 @@ class DataSmart:
|
|||
l = len(o)+1
|
||||
|
||||
# see if one should even try
|
||||
if not self._seen_overrides.has_key(o):
|
||||
if o not in self._seen_overrides:
|
||||
continue
|
||||
|
||||
vars = self._seen_overrides[o]
|
||||
|
@ -130,7 +130,7 @@ class DataSmart:
|
|||
bb.msg.note(1, bb.msg.domain.Data, "Untracked delVar")
|
||||
|
||||
# now on to the appends and prepends
|
||||
if self._special_values.has_key("_append"):
|
||||
if "_append" in self._special_values:
|
||||
appends = self._special_values['_append'] or []
|
||||
for append in appends:
|
||||
for (a, o) in self.getVarFlag(append, '_append') or []:
|
||||
|
@ -145,7 +145,7 @@ class DataSmart:
|
|||
self.setVar(append, sval)
|
||||
|
||||
|
||||
if self._special_values.has_key("_prepend"):
|
||||
if "_prepend" in self._special_values:
|
||||
prepends = self._special_values['_prepend'] or []
|
||||
|
||||
for prepend in prepends:
|
||||
|
@ -215,7 +215,7 @@ class DataSmart:
|
|||
# more cookies for the cookie monster
|
||||
if '_' in var:
|
||||
override = var[var.rfind('_')+1:]
|
||||
if not self._seen_overrides.has_key(override):
|
||||
if override not in self._seen_overrides:
|
||||
self._seen_overrides[override] = set()
|
||||
self._seen_overrides[override].add( var )
|
||||
|
||||
|
@ -246,7 +246,7 @@ class DataSmart:
|
|||
dest.extend(src)
|
||||
self.setVarFlag(newkey, i, dest)
|
||||
|
||||
if self._special_values.has_key(i) and key in self._special_values[i]:
|
||||
if i in self._special_values and key in self._special_values[i]:
|
||||
self._special_values[i].remove(key)
|
||||
self._special_values[i].add(newkey)
|
||||
|
||||
|
|
|
@ -37,12 +37,12 @@ class SkipPackage(Exception):
|
|||
|
||||
__mtime_cache = {}
|
||||
def cached_mtime(f):
|
||||
if not __mtime_cache.has_key(f):
|
||||
if f not in __mtime_cache:
|
||||
__mtime_cache[f] = os.stat(f)[8]
|
||||
return __mtime_cache[f]
|
||||
|
||||
def cached_mtime_noerror(f):
|
||||
if not __mtime_cache.has_key(f):
|
||||
if f not in __mtime_cache:
|
||||
try:
|
||||
__mtime_cache[f] = os.stat(f)[8]
|
||||
except OSError:
|
||||
|
|
|
@ -90,7 +90,7 @@ def get_statements(filename, absolsute_filename, base_name):
|
|||
statements = ast.StatementGroup()
|
||||
|
||||
lineno = 0
|
||||
while 1:
|
||||
while True:
|
||||
lineno = lineno + 1
|
||||
s = file.readline()
|
||||
if not s: break
|
||||
|
|
|
@ -89,7 +89,7 @@ def handle(fn, data, include):
|
|||
|
||||
statements = ast.StatementGroup()
|
||||
lineno = 0
|
||||
while 1:
|
||||
while True:
|
||||
lineno = lineno + 1
|
||||
s = f.readline()
|
||||
if not s: break
|
||||
|
|
|
@ -113,7 +113,7 @@ class PersistData:
|
|||
try:
|
||||
self.connection.execute(*query)
|
||||
return
|
||||
except sqlite3.OperationalError, e:
|
||||
except sqlite3.OperationalError as e:
|
||||
if 'database is locked' in str(e):
|
||||
continue
|
||||
raise
|
||||
|
|
|
@ -109,8 +109,7 @@ class RunQueueSchedulerSpeed(RunQueueScheduler):
|
|||
|
||||
self.rq = runqueue
|
||||
|
||||
sortweight = deepcopy(self.rq.runq_weight)
|
||||
sortweight.sort()
|
||||
sortweight = sorted(deepcopy(self.rq.runq_weight))
|
||||
copyweight = deepcopy(self.rq.runq_weight)
|
||||
self.prio_map = []
|
||||
|
||||
|
@ -307,7 +306,7 @@ class RunQueue:
|
|||
weight[listid] = 1
|
||||
task_done[listid] = True
|
||||
|
||||
while 1:
|
||||
while True:
|
||||
next_points = []
|
||||
for listid in endpoints:
|
||||
for revdep in self.runq_depends[listid]:
|
||||
|
@ -948,7 +947,7 @@ class RunQueue:
|
|||
try:
|
||||
pipein, pipeout = os.pipe()
|
||||
pid = os.fork()
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
bb.msg.fatal(bb.msg.domain.RunQueue, "fork failed: %d (%s)" % (e.errno, e.strerror))
|
||||
if pid == 0:
|
||||
os.close(pipein)
|
||||
|
|
|
@ -115,7 +115,7 @@ class BitBakeServer():
|
|||
|
||||
def register_idle_function(self, function, data):
|
||||
"""Register a function to be called while the server is idle"""
|
||||
assert callable(function)
|
||||
assert hasattr(function, '__call__')
|
||||
self._idlefuns[function] = data
|
||||
|
||||
def idle_commands(self, delay):
|
||||
|
|
|
@ -112,7 +112,7 @@ class BitBakeServer(SimpleXMLRPCServer):
|
|||
|
||||
def register_idle_function(self, function, data):
|
||||
"""Register a function to be called while the server is idle"""
|
||||
assert callable(function)
|
||||
assert hasattr(function, '__call__')
|
||||
self._idlefuns[function] = data
|
||||
|
||||
def serve_forever(self):
|
||||
|
|
|
@ -539,7 +539,7 @@ class TaskData:
|
|||
Resolve all unresolved build and runtime targets
|
||||
"""
|
||||
bb.msg.note(1, bb.msg.domain.TaskData, "Resolving any missing task queue dependencies")
|
||||
while 1:
|
||||
while True:
|
||||
added = 0
|
||||
for target in self.get_unresolved_build_targets(dataCache):
|
||||
try:
|
||||
|
|
|
@ -385,7 +385,7 @@ class BuildManager (gobject.GObject):
|
|||
build_directory])
|
||||
server.runCommand(["buildTargets", [conf.image], "rootfs"])
|
||||
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
class BuildManagerTreeView (gtk.TreeView):
|
||||
|
|
|
@ -63,7 +63,7 @@ class RunningBuild (gobject.GObject):
|
|||
# for the message.
|
||||
if hasattr(event, 'pid'):
|
||||
pid = event.pid
|
||||
if self.pids_to_task.has_key(pid):
|
||||
if pid in self.pids_to_task:
|
||||
(package, task) = self.pids_to_task[pid]
|
||||
parent = self.tasks_to_iter[(package, task)]
|
||||
|
||||
|
@ -98,7 +98,7 @@ class RunningBuild (gobject.GObject):
|
|||
# Check if we already have this package in our model. If so then
|
||||
# that can be the parent for the task. Otherwise we create a new
|
||||
# top level for the package.
|
||||
if (self.tasks_to_iter.has_key ((package, None))):
|
||||
if ((package, None) in self.tasks_to_iter):
|
||||
parent = self.tasks_to_iter[(package, None)]
|
||||
else:
|
||||
parent = self.model.append (None, (None,
|
||||
|
|
|
@ -207,7 +207,7 @@ def init(server, eventHandler):
|
|||
if ret != True:
|
||||
print("Couldn't run command! %s" % ret)
|
||||
return
|
||||
except xmlrpclib.Fault, x:
|
||||
except xmlrpclib.Fault as x:
|
||||
print("XMLRPC Fault getting commandline:\n %s" % x)
|
||||
return
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ def init (server, eventHandler):
|
|||
if ret != True:
|
||||
print("Couldn't get default commandline! %s" % ret)
|
||||
return 1
|
||||
except xmlrpclib.Fault, x:
|
||||
except xmlrpclib.Fault as x:
|
||||
print("XMLRPC Fault getting commandline:\n %s" % x)
|
||||
return 1
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ def init(server, eventHandler):
|
|||
if ret != True:
|
||||
print("Couldn't get default commandline! %s" % ret)
|
||||
return 1
|
||||
except xmlrpclib.Fault, x:
|
||||
except xmlrpclib.Fault as x:
|
||||
print("XMLRPC Fault getting commandline:\n %s" % x)
|
||||
return 1
|
||||
|
||||
|
|
|
@ -234,7 +234,7 @@ class NCursesUI:
|
|||
if ret != True:
|
||||
print("Couldn't get default commandlind! %s" % ret)
|
||||
return
|
||||
except xmlrpclib.Fault, x:
|
||||
except xmlrpclib.Fault as x:
|
||||
print("XMLRPC Fault getting commandline:\n %s" % x)
|
||||
return
|
||||
|
||||
|
|
|
@ -104,10 +104,10 @@ class MetaDataLoader(gobject.GObject):
|
|||
gobject.idle_add (MetaDataLoader.emit_success_signal,
|
||||
self.loader)
|
||||
|
||||
except MetaDataLoader.LoaderThread.LoaderImportException, e:
|
||||
except MetaDataLoader.LoaderThread.LoaderImportException as e:
|
||||
gobject.idle_add (MetaDataLoader.emit_error_signal, self.loader,
|
||||
"Repository metadata corrupt")
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
gobject.idle_add (MetaDataLoader.emit_error_signal, self.loader,
|
||||
"Unable to download repository metadata")
|
||||
print(e)
|
||||
|
|
|
@ -72,9 +72,9 @@ def vercmp_part(a, b):
|
|||
if ca == None and cb == None:
|
||||
return 0
|
||||
|
||||
if type(ca) is types.StringType:
|
||||
if isinstance(ca, types.StringType):
|
||||
sa = ca in separators
|
||||
if type(cb) is types.StringType:
|
||||
if isinstance(cb, types.StringType):
|
||||
sb = cb in separators
|
||||
if sa and not sb:
|
||||
return -1
|
||||
|
@ -306,7 +306,7 @@ def better_compile(text, file, realfile, mode = "exec"):
|
|||
"""
|
||||
try:
|
||||
return compile(text, file, mode)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
# split the text into lines again
|
||||
body = text.split('\n')
|
||||
bb.msg.error(bb.msg.domain.Util, "Error in compiling python function in: ", realfile)
|
||||
|
@ -385,7 +385,7 @@ def lockfile(name):
|
|||
return lf
|
||||
# File no longer exists or changed, retry
|
||||
lf.close
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
continue
|
||||
|
||||
def unlockfile(lf):
|
||||
|
@ -546,7 +546,7 @@ def mkdirhier(dir):
|
|||
try:
|
||||
os.makedirs(dir)
|
||||
bb.msg.debug(2, bb.msg.domain.Util, "created " + dir)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
if e.errno != errno.EEXIST:
|
||||
raise e
|
||||
|
||||
|
@ -561,7 +561,7 @@ def movefile(src, dest, newmtime = None, sstat = None):
|
|||
try:
|
||||
if not sstat:
|
||||
sstat = os.lstat(src)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print("movefile: Stating source file failed...", e)
|
||||
return None
|
||||
|
||||
|
@ -577,7 +577,7 @@ def movefile(src, dest, newmtime = None, sstat = None):
|
|||
try:
|
||||
os.unlink(dest)
|
||||
destexists = 0
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
if stat.S_ISLNK(sstat[stat.ST_MODE]):
|
||||
|
@ -589,7 +589,7 @@ def movefile(src, dest, newmtime = None, sstat = None):
|
|||
#os.lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID])
|
||||
os.unlink(src)
|
||||
return os.lstat(dest)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print("movefile: failed to properly create symlink:", dest, "->", target, e)
|
||||
return None
|
||||
|
||||
|
@ -598,7 +598,7 @@ def movefile(src, dest, newmtime = None, sstat = None):
|
|||
try:
|
||||
os.rename(src, dest)
|
||||
renamefailed = 0
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if e[0] != errno.EXDEV:
|
||||
# Some random error.
|
||||
print("movefile: Failed to move", src, "to", dest, e)
|
||||
|
@ -612,7 +612,7 @@ def movefile(src, dest, newmtime = None, sstat = None):
|
|||
shutil.copyfile(src, dest + "#new")
|
||||
os.rename(dest + "#new", dest)
|
||||
didcopy = 1
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print('movefile: copy', src, '->', dest, 'failed.', e)
|
||||
return None
|
||||
else:
|
||||
|
@ -626,7 +626,7 @@ def movefile(src, dest, newmtime = None, sstat = None):
|
|||
os.lchown(dest, sstat[stat.ST_UID], sstat[stat.ST_GID])
|
||||
os.chmod(dest, stat.S_IMODE(sstat[stat.ST_MODE])) # Sticky is reset on chown
|
||||
os.unlink(src)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print("movefile: Failed to chown/chmod/unlink", dest, e)
|
||||
return None
|
||||
|
||||
|
@ -647,7 +647,7 @@ def copyfile(src, dest, newmtime = None, sstat = None):
|
|||
try:
|
||||
if not sstat:
|
||||
sstat = os.lstat(src)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print("copyfile: Stating source file failed...", e)
|
||||
return False
|
||||
|
||||
|
@ -663,7 +663,7 @@ def copyfile(src, dest, newmtime = None, sstat = None):
|
|||
try:
|
||||
os.unlink(dest)
|
||||
destexists = 0
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
if stat.S_ISLNK(sstat[stat.ST_MODE]):
|
||||
|
@ -674,7 +674,7 @@ def copyfile(src, dest, newmtime = None, sstat = None):
|
|||
os.symlink(target, dest)
|
||||
#os.lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID])
|
||||
return os.lstat(dest)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print("copyfile: failed to properly create symlink:", dest, "->", target, e)
|
||||
return False
|
||||
|
||||
|
@ -682,7 +682,7 @@ def copyfile(src, dest, newmtime = None, sstat = None):
|
|||
try: # For safety copy then move it over.
|
||||
shutil.copyfile(src, dest + "#new")
|
||||
os.rename(dest + "#new", dest)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print('copyfile: copy', src, '->', dest, 'failed.', e)
|
||||
return False
|
||||
else:
|
||||
|
@ -694,7 +694,7 @@ def copyfile(src, dest, newmtime = None, sstat = None):
|
|||
try:
|
||||
os.lchown(dest, sstat[stat.ST_UID], sstat[stat.ST_GID])
|
||||
os.chmod(dest, stat.S_IMODE(sstat[stat.ST_MODE])) # Sticky is reset on chown
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print("copyfile: Failed to chown/chmod/unlink", dest, e)
|
||||
return False
|
||||
|
||||
|
|
Loading…
Reference in New Issue