Skip to content
This repository was archived by the owner on Jan 29, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions oebakery/cmd/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from __future__ import with_statement # This isn't required in Python 2.6

from cmds import \
from .cmds import \
clear, \
add_builtin_cmds, \
add_manifest_cmds, \
Expand Down
4 changes: 2 additions & 2 deletions oebakery/cmd/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def clone_checkout(options):
oebakery.path.copy_local_conf_sample("conf")

if not oebakery.call('git config push.default tracking'):
print 'Failed to set push.default = tracking'
print('Failed to set push.default = tracking')

return ["update"]

Expand Down Expand Up @@ -100,7 +100,7 @@ def clone_bare_recursive(repository, directory, branch=None):
return
submodules = oebakery.gitmodules.parse_dot_gitmodules(buffer=gitmodules)
failed = []
for submodule in submodules.values():
for submodule in list(submodules.values()):
path = submodule['path']
url = submodule['url']
if url != './' + path: # only clone relative submodules
Expand Down
14 changes: 7 additions & 7 deletions oebakery/cmd/cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ def add_manifest_cmds():
module = "oelite.cmd"
cmds = oelite.cmd.manifest_cmds
cmd_type = "manifest"
except ImportError, e:
except ImportError as e:
logger.debug("import oelite.cmd failed", exc_info=True)
try:
import oelite.baker
except e:
print e
print(e)
return False
module = "oebakery.cmd"
cmds = ("bake", "show")
Expand All @@ -81,7 +81,7 @@ def cmds_usage():
cmd = __cmds[cmd_name]
usage += "\n %-21s "%(cmd_name)
if "description" in dir(cmd) and cmd.description:
if isinstance(cmd.description, basestring):
if isinstance(cmd.description, str):
usage += cmd.description
else:
usage += cmd.description[0]
Expand All @@ -93,12 +93,12 @@ def cmds_usage():
def cmd_parser(cmd):
try:
description = cmd.description
if description and not isinstance(description, basestring):
if description and not isinstance(description, str):
description = "\n".join(description)
# FIXME: use something like format_textblock to format to console
# width and handle the 2-space indentation here instead of
# requiring command writers to bother about it.
except AttributeError, e:
except AttributeError as e:
description = ""
try:
arguments = ""
Expand All @@ -114,7 +114,7 @@ def cmd_parser(cmd):
else:
arguments += " ?%s?*"%(arg_name)
description += "\n %-21s %s"%(arg_name, arg_descr)
except AttributeError, e:
except AttributeError as e:
arguments = ""
parser = optparse.OptionParser("""
%%prog %s [options]%s
Expand All @@ -135,7 +135,7 @@ def call(cmd, function, *args):

try:
ret = function(*args)
except Exception, e:
except Exception as e:
if hasattr(e, "print_details"):
e.print_details()
logger.exception("exception in %s.%s()", cmd.name, function.__name__)
Expand Down
2 changes: 1 addition & 1 deletion oebakery/cmd/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import oebakery
logger = oebakery.logger
import update
from . import update


# oe pull
Expand Down
8 changes: 4 additions & 4 deletions oebakery/cmd/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,14 @@ def git_update_remote(name, url, path=None):

# get push urls
remotes_push = {}
for iter_name in remotes_fetch.keys():
for iter_name in list(remotes_fetch.keys()):
iter_url = oebakery.call('git config --get remote.%s.pushurl'%iter_name,
dir=path, quiet=True)
if iter_url:
remotes_push[iter_name] = iter_url.strip()

# if remote is not found, add it and return
if not remotes_fetch.has_key(name):
if name not in remotes_fetch:
if not oebakery.call('git remote add %s %s'%(name, fetch_url),
dir=path):
logger.error("Failed to add remote %s", name)
Expand All @@ -347,7 +347,7 @@ def git_update_remote(name, url, path=None):

# if push url is different url, change it
if push_url:
if not remotes_push.has_key(name) or remotes_push[name] != push_url:
if name not in remotes_push or remotes_push[name] != push_url:
if not oebakery.call(
'git config remote.%s.pushurl %s'%(name, push_url),
dir=path):
Expand All @@ -356,7 +356,7 @@ def git_update_remote(name, url, path=None):

# if push url is currently set, but shouldn't be, remove it
else:
if remotes_push.has_key(name) and remotes_push[name] != fetch_url:
if name in remotes_push and remotes_push[name] != fetch_url:
if not oebakery.call('git config --unset remote.%s.pushurl'%(name),
dir=path):
logger.error("failed to unset pushurl for %s", name)
Expand Down
15 changes: 9 additions & 6 deletions oebakery/oe.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env python

#python2 compat
from __future__ import print_function

VERSION = "4.2.0"

# New arguments strategy: oe [bakery options] <command> [command options]
Expand Down Expand Up @@ -45,18 +48,18 @@ def module_version(module):
raise Exception()
except:
if bakery_options.debug:
print "DEBUG: bakery: importing oebakery module from source directory:", os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
print("DEBUG: bakery: importing oebakery module from source directory:", os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
sys.path.insert(
0, os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
try:
import oebakery
version = module_version(oebakery)
if version != VERSION:
print >>sys.stderr, "CRITICAL: bad oebakery module version: %s (expected: %s)"%(version, VERSION)
print("CRITICAL: bad oebakery module version: %s (expected: %s)"%(version, VERSION), file=sys.stderr)
sys.exit(1)
except ImportError, e:
print >>sys.stderr, "CRITICAL: cannot import oebakery module"
print e
except ImportError as e:
print("CRITICAL: cannot import oebakery module", file=sys.stderr)
print(e)
sys.exit(1)

# Initialize logging
Expand All @@ -76,7 +79,7 @@ def module_version(module):
oebakery.cmd.add_builtin_cmds()
oebakery.cmd.add_manifest_cmds()
usage = parser.get_usage() + "\n" + oebakery.cmd.cmds_usage()
print usage
print(usage)
sys.exit(1)

if cmd_argv[0] == "help":
Expand Down
26 changes: 13 additions & 13 deletions oebakery/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __str__(self):
return self.msg

def print_details(self):
print self.msg
print(self.msg)
if not self.details:
return ""
lines = self.parser.text.splitlines()
Expand All @@ -61,7 +61,7 @@ def print_details(self):
firstline = max(self.errlineno - 5, 0)
lastline = min(self.errlineno + 5, len(lines))
errlinepos = 0
for lineno in xrange(self.errlineno):
for lineno in range(self.errlineno):
errlinepos += len(lines[lineno]) + 1
#if isinstance(self.details, ply.lex.LexToken):
# print "this is a LexToken"
Expand All @@ -79,28 +79,28 @@ def print_details(self):
lexpos = None
linenofmtlen = len(str(lastline))
lineprintfmt = "%%s%%%dd %%s"%(linenofmtlen)
for lineno in xrange(firstline, lastline):
for lineno in range(firstline, lastline):
if lineno == self.errlineno:
if lineno:
print ""
print("")
prefix = "-> "
else:
prefix = " "
print lineprintfmt%(prefix, lineno + 1,
lines[lineno].expandtabs())
print(lineprintfmt%(prefix, lineno + 1,
lines[lineno].expandtabs()))
if lineno == self.errlineno:
if lexpos:
prefixlen = len(prefix) + linenofmtlen + 1
print "%s%s"%(" "*(prefixlen + errlinebefore),
"^"*len(self.symbol))
print("%s%s"%(" "*(prefixlen + errlinebefore),
"^"*len(self.symbol)))
else:
print ""
print("")
if self.parser.parent:
parent = self.parser.parent
print "Included from %s"%(parent.filename)
print("Included from %s"%(parent.filename))
parent = parent.parent
while parent:
print " %s"%(parent.filename)
print(" %s"%(parent.filename))
return


Expand Down Expand Up @@ -270,7 +270,7 @@ def p_simple_assignment(self, p):

def p_exp_assignment(self, p):
'''assignment : varflag EXPASSIGN STRING'''
print "EXPASSIGN %s"%(p[1][0])
print("EXPASSIGN %s"%(p[1][0]))
self.data.set_flag(p[1][0], p[1][1], self.data.expand(p[3], 1))
return

Expand Down Expand Up @@ -320,7 +320,7 @@ def parse(self, filename, require=True):
self.filename = os.path.realpath(filename)

if not os.path.exists(self.filename):
print "No such file: %s"%(filename)
print("No such file: %s"%(filename))
return None

mtime = os.path.getmtime(self.filename)
Expand Down
8 changes: 4 additions & 4 deletions oebakery/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ def chdir(dir, quiet=False):
logger.debug("chdir: %s", dir)
try:
cwd = os.getcwd()
except OSError, e:
except OSError as e:
cwd = None
if (cwd and
os.path.realpath(os.path.normpath(dir)) == os.path.normpath(cwd)):
return

if not quiet:
print '> cd', dir
print('> cd', dir)

os.chdir(dir)

Expand All @@ -67,8 +67,8 @@ def copy_local_conf_sample(confdir):
config = os.path.join(confdir, 'local.conf')
sample = os.path.join(confdir, 'local.conf.sample')
if not os.path.exists(config) and os.path.exists(sample):
print '> cp %s %s'%(sample, config)
print('> cp %s %s'%(sample, config))
try:
shutil.copyfile(sample, config)
except Exception, e:
except Exception as e:
logger.warning("failed to write config file: %s: %s", config, e)
4 changes: 2 additions & 2 deletions oebakery/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def call(cmd, dir=None, quiet=False, success_returncode=0):

if not quiet:
if dir:
print '%s> %s'%(dir, cmd)
print('%s> %s'%(dir, cmd))
else:
print '> %s'%(cmd)
print('> %s'%(cmd))

retval = None
if quiet:
Expand Down