py3: use print as a function

This commit is contained in:
Frédéric Péters 2020-04-18 14:44:29 +02:00
parent feb24c1958
commit d8546b580d
5 changed files with 34 additions and 34 deletions

View File

@ -77,15 +77,15 @@ if __name__ == '__main__':
if blacklisted:
continue
t0 = time.time()
print '='*60
print module
print '='*60
print('='*60)
print(module)
print('='*60)
sys.stdout.flush()
results[module] = build_module(config, module)
print '\n'
print '(%1.2f seconds)' % (time.time()-t0)
print '\n'
print('\n')
print('(%1.2f seconds)' % (time.time()-t0))
print('\n')
sys.stdout.flush()
for module in sorted(results.keys()):
print '%-40s %s' % (module, results[module])
print('%-40s %s' % (module, results[module]))

View File

@ -41,7 +41,7 @@ def smart_cleaning(files_path):
def clean(method):
print "+ Cleanning %s" % method
print("+ Cleanning %s" % method)
if method == "all":
shutil.rmtree(settings.ORIGIN_PATH)
shutil.rmtree(settings.PBUILDER_RESULT)
@ -157,14 +157,14 @@ def prepare_build(dist, project, cmd_options, new):
if debian_branch == "debian" and "debian-%s" % dist in branches:
debian_branch = "debian-" + dist
if not 'origin/%s' % debian_branch in output("git branch -r -l"):
print '!!! WARNING: cannot build for dist %s, no debian directory found' % dist
print('!!! WARNING: cannot build for dist %s, no debian directory found' % dist)
return
print "!!! WARNING obsolete: using a branch for debian/ packaging"
print "+ Updating Debian branch for %s" % dist
print("!!! WARNING obsolete: using a branch for debian/ packaging")
print("+ Updating Debian branch for %s" % dist)
call("git checkout --quiet %s" % debian_branch)
call("git pull")
else:
print "+ Building from %s debian folder" % debian_folder
print("+ Building from %s debian folder" % debian_folder)
for r in cmd_options.repositories:
repo = r.split(':')
if repo[0] == dist:
@ -183,7 +183,7 @@ def prepare_build(dist, project, cmd_options, new):
origin_archive = os.path.join(settings.ORIGIN_PATH,
"%s_%s.orig.tar.bz2" % (package['source_name'], project['version']))
if not os.path.exists(origin_archive):
print "+ Generating origin tarball ..."
print("+ Generating origin tarball ...")
os.chdir(project['git_path'])
call("git checkout --quiet %s" % build_branch)
if os.path.exists('setup.py'):
@ -274,10 +274,10 @@ def prepare_build(dist, project, cmd_options, new):
build_branch.replace('/', '_'))
)
if os.path.exists(build_file):
print "+ Already built for %s !" % dist
print("+ Already built for %s !" % dist)
return package
print "+ Preparing Debian build (%s %s) ..." % (package['source_name'], package['version'])
print("+ Preparing Debian build (%s %s) ..." % (package['source_name'], package['version']))
if debian_branch:
call("git checkout --quiet %s" % debian_branch)
os.chdir(project['build_dir'])
@ -319,21 +319,21 @@ def build_project(dist, arch, project, package, new):
project['build_branch'].replace('/', '_'),
arch)
)
print 'SOURCE_BUILD:', source_build
print('SOURCE_BUILD:', source_build)
if os.path.exists(source_build):
source_opt = '-b'
else:
source_opt = '-sa'
if new == 0 and os.path.exists(bin_build):
print "+ Already build !"
print("+ Already build !")
return
os.chdir(project_build_path)
print "+ Building %s %s %s %s" % \
(project['name'], project['version'], dist, arch)
print("+ Building %s %s %s %s" % \
(project['name'], project['version'], dist, arch))
call('DIST=%s ARCH=%s pdebuild --use-pdebuild-internal --architecture %s --debbuildopts "%s"' % \
(dist, arch, arch, source_opt))
print "+ Lock build"
print("+ Lock build")
touch(bin_build)
if not os.path.exists(source_build):
touch(source_build)
@ -343,10 +343,10 @@ def send_packages(dist, arch, project, package, last_tag):
project['name'], package['version'],
package['repository'], arch, project['build_branch'].replace('/', '_')))
if os.path.exists(stamp_file):
print '+ Already uploaded'
print('+ Already uploaded')
return
print "+ Sending package..."
print("+ Sending package...")
pbuilder_project_result = os.path.join(settings.PBUILDER_RESULT,
'%s-%s' % (dist, arch))
os.chdir(pbuilder_project_result)
@ -357,14 +357,14 @@ def send_packages(dist, arch, project, package, last_tag):
arch)
)
print "+ Updating repository ..."
print("+ Updating repository ...")
call('ssh root@%s "/etc/cron.hourly/process-incoming"' % \
settings.REPOSITORY_URL)
old_version = tuple(int(d) for d in last_tag.split('.'))
new_version = tuple(int(d) for d in project['current_tag'].split('.'))
if new_version > old_version and \
project['current_tag'] == project['version']:
print "New tag detected : %s" % project['current_tag']
print("New tag detected : %s" % project['current_tag'])
if settings.MANUAL_TESTING_REPOSITORIES.has_key(package['source_name']):
package_repos = settings.MANUAL_TESTING_REPOSITORIES[package['source_name']]
else:
@ -373,7 +373,7 @@ def send_packages(dist, arch, project, package, last_tag):
packages = " ".join(packages)
if package_repos.has_key(dist) and package['copy_in_testing']:
for repo in package_repos[dist]:
print "+ Copy %s packages to %s repository (%s)" % (package['source_name'], repo, dist)
print("+ Copy %s packages to %s repository (%s)" % (package['source_name'], repo, dist))
call('ssh root@%s "/usr/bin/reprepro -b /var/vhosts/deb.entrouvert.org copy %s %s %s"'\
% (settings.REPOSITORY_URL, repo,
package['repository'], packages))
@ -406,7 +406,7 @@ def setup_git_tree(project_name, options):
subprocess.check_call(['git', 'checkout', '--quiet', options.branch])
subprocess.check_call(['git', 'reset', '--hard', 'origin/%s' % options.branch])
except subprocess.CalledProcessError as e:
print >> sys.stderr, e
print(e, file=sys.stderr)
shutil.rmtree(git_project_path)
return setup_git_tree(project_name, options)
else:
@ -426,7 +426,7 @@ def setup_git_tree(project_name, options):
subprocess.check_call(['git', 'submodule', 'update'])
except subprocess.CalledProcessError as e:
if existing_tree:
print >> sys.stderr, e
print(e, file=sys.stderr)
shutil.rmtree(git_project_path)
return setup_git_tree(project_name, options)
raise
@ -482,7 +482,7 @@ def main():
new = 0
if options.force and not new:
print "+ Warning force a new build"
print("+ Warning force a new build")
new = 1
for dist in options.distrib:
@ -493,7 +493,7 @@ def main():
for arch in options.architectures:
build_project(dist, arch, project, package, new)
send_packages(dist, arch, project, package, last_tag)
print "+ Add a build file to lock new build for %s" % dist
print("+ Add a build file to lock new build for %s" % dist)
touch(os.path.join(project['lock_path'],
"%s_%s_%s_%s.build" % (project['name'],
package['version'],

View File

@ -3,7 +3,7 @@ import os
VERSION = '7'
def init():
print "+ Init EO Builder"
print("+ Init EO Builder")
if not os.path.exists(settings.GIT_PATH):
os.makedirs(settings.GIT_PATH, 0755)
if not os.path.exists(settings.ORIGIN_PATH):

View File

@ -102,4 +102,4 @@ if __name__ == '__main__':
path = sys.argv[3]
else:
path = os.getcwd()
print '\n'.join(changelog_from_git(project, version_suffix, path))
print('\n'.join(changelog_from_git(project, version_suffix, path)))

View File

@ -99,7 +99,7 @@ def cat(file_path):
return content
def touch(fname):
print 'TOUCH:', fname
print('TOUCH:', fname)
with open(fname, 'a'):
os.utime(fname, None)
@ -116,7 +116,7 @@ def call(cmd):
shebang = open('setup.py').readline()
if shebang.startswith('#!'):
cmd = shebang[2:].strip() + ' ' + cmd.split(' ', 1)[1]
print 'CALL:', cmd
print('CALL:', cmd)
rcode = subprocess.call(cmd, shell=True)
if rcode != 0:
error(cmd)
@ -140,6 +140,6 @@ def output(cmd, print_output=False, exit_on_error=True):
if exit_on_error:
error(cmd)
if print_output:
print output
print(output)
return output