Fix 'print' for py3-style

This commit is contained in:
Denis Silakov 2018-10-21 09:38:13 +03:00
parent 3548d84aee
commit d8159116dd
4 changed files with 34 additions and 36 deletions

54
abf.py
View file

@ -448,7 +448,7 @@ def info_single():
for inst in res:
for param in so:
try:
print param + ':\t' + str(inst.params_dict[param])
print(param + ':\t' + str(inst.params_dict[param]))
except:
log.debug(_("Parameter %s not available:") % param)
@ -469,7 +469,7 @@ def fix_default_config():
continue
out.append(f[:-4])
print ', '.join(out)
print(', '.join(out))
res = None
while res not in out:
if res is not None:
@ -548,7 +548,7 @@ def run_mock_urpm(binary=True):
res = execute_command(cmd, print_to_stdout=True, exit_on_error=False, shell=False)
os.remove(srpm_path)
rpms = glob(os.path.join(resultsdir, '*.rpm'))
print ''
print('')
for rpm in rpms:
new_path = os.path.join(os.getcwd(), os.path.basename(rpm))
if os.path.exists(new_path):
@ -574,7 +574,7 @@ def alias():
log.info(_('No aliases found'))
return
for al_name in cfg['alias']:
print '%10s: %s' % (al_name, cfg['alias'][al_name])
print('%10s: %s' % (al_name, cfg['alias'][al_name]))
elif command_line.command == 'add':
if len(command_line.options) < 2:
log.error(_('Not enough options. Use it like "abf alias add <alias_name> opt1 [opt2 ...]"'))
@ -690,7 +690,7 @@ def search():
cl = {'groups': Group, 'users': User, 'platforms': Platform, 'projects': Project}
items = cl[st].search(models, sq)
for item in items:
print item
print(item)
def get_project_name_only(must_exist=True, name=None):
if name:
@ -925,7 +925,7 @@ def store():
exit(1)
res = models.jsn.upload_file(p, silent=True)
print res
print(res)
def copy():
log.debug(_('COPY started'))
@ -1520,24 +1520,24 @@ def _print_build_status(models, ID):
log.error(_("Can not read buildlist %(id)s: %(exception)s") % {'id': ID, 'exception': ex})
exit(3)
if command_line.short:
print repr(bl)
print(repr(bl))
else:
print '%-20s%s' %(_('Buildlist ID:'), bl.id)
print '%-20s%s' %(_('Project:'), bl.project.fullname)
print '%-20s%s' %(_('Status:'), bl.status_string)
print '%-20s%s' %(_('Container path:'), bl.container_path)
print '%-20s%s' %(_('Container status:'), bl.container_status_string)
print '%-20s%s' %(_('Build for platform:'), bl.build_for_platform)
print '%-20s%s' %(_('Save to repository:'), bl.save_to_repository)
print '%-20s%s' %(_('Build repositories:'), bl.include_repos)
print '%-20s%s' %(_('Extra repositories:'), bl.extra_repositories)
print '%-20s%s' %(_('Architecture:'), bl.arch.name)
print '%-20s%s' %(_('Created at:'), bl.created_at)
print '%-20s%s' %(_('Updated at:'), bl.updated_at)
print '%-20s%s' %(_('LOG Url:'), bl.log_url)
print('%-20s%s' %(_('Buildlist ID:'), bl.id))
print('%-20s%s' %(_('Project:'), bl.project.fullname))
print('%-20s%s' %(_('Status:'), bl.status_string))
print('%-20s%s' %(_('Container path:'), bl.container_path))
print('%-20s%s' %(_('Container status:'), bl.container_status_string))
print('%-20s%s' %(_('Build for platform:'), bl.build_for_platform))
print('%-20s%s' %(_('Save to repository:'), bl.save_to_repository))
print('%-20s%s' %(_('Build repositories:'), bl.include_repos))
print('%-20s%s' %(_('Extra repositories:'), bl.extra_repositories))
print('%-20s%s' %(_('Architecture:'), bl.arch.name))
print('%-20s%s' %(_('Created at:'), bl.created_at))
print('%-20s%s' %(_('Updated at:'), bl.updated_at))
print('%-20s%s' %(_('LOG Url:'), bl.log_url))
if bl.chroot_tree:
print '%-20s%s' %(_('Chroot Tree:'), bl.chroot_tree)
print ''
print('%-20s%s' %(_('Chroot Tree:'), bl.chroot_tree))
print('')
return [bl.status_string, bl.container_status_string]
@ -1627,7 +1627,7 @@ def locate():
print(_('error: project is not located in "%s" anymore') % path)
projects_cfg[proj]['location'] = ''
exit(1)
print path
print(path)
return
else:
if command_line.action == 'update':
@ -1707,13 +1707,13 @@ def show():
if t is None:
proj = get_project(models, must_exist=True, name=command_line.project)
for i in proj.required_fields:
print (_("%s: %s") % (i, getattr(proj, i)))
print(_("%s: %s") % (i, getattr(proj, i)))
elif t == 'buildlists':
proj = get_project(models, must_exist=True, name=command_line.project)
res = models.jsn.get_project_buildlists(proj.id, '' ,1)
for bl in res['build_lists']:
buildlist = BuildList(models, bl['id'])
print buildlist
print(buildlist)
elif t in ['build-platforms', 'build-repos']:
build_platforms = Platform.get_build_platforms(models)
@ -1725,7 +1725,7 @@ def show():
for repo in plat.repositories:
repo_names.append(str(repo))
out = (t == 'build-platforms' and platform_names) or (t == 'build-repos' and repo_names)
print ' '.join(out)
print(' '.join(out))
elif t in ['save-to-platforms', 'save-to-repos']:
proj = get_project(models, must_exist=True, name=command_line.project)
@ -1737,7 +1737,7 @@ def show():
repo_names.append(str(repo))
platform_names = list(set(platform_names))
out = (t == 'save-to-platforms' and platform_names) or (t == 'save-to-repos' and repo_names)
print ' '.join(out)
print(' '.join(out))
def clean():

View file

@ -91,7 +91,7 @@ class AbfJson(object):
res = json.loads(response_string)
except ValueError, ex:
self.log.error(_("Internal server error: it has returned non-json data. "))
print response_string
print(response_string)
exit(1)
m = None
if 'message' in res and res['message'] not in AbfJson.good_messages:
@ -191,7 +191,7 @@ class AbfJson(object):
res = self.process_response(res)
# print 'RAW OUTPUT', res
# print('RAW OUTPUT', res)
return res

View file

@ -11,9 +11,9 @@ import fcntl
#
# cfg = Config()
# cfg['aaa']['bbb'] = 'ccc'
# print cfg['aaa']['bbb']
# print cfg['aaa'].pop('bbb')
# print cfg.pop('aaa')
# print(cfg['aaa']['bbb'])
# print(cfg['aaa'].pop('bbb'))
# print(cfg.pop('aaa'))
#####################################################
VERSION = 4

View file

@ -404,7 +404,7 @@ def execute_command(command, shell=False, cwd=None, timeout=0, raiseExc=True, pr
def logOutput(fds, start=0, timeout=0, print_to_stdout=False):
done = 0
output = ''
#print 'NEW CALL epoll', fds[0].fileno(), fds[1].fileno()
#print('NEW CALL epoll', fds[0].fileno(), fds[1].fileno())
# set all fds to nonblocking
for fd in fds:
@ -422,16 +422,14 @@ def logOutput(fds, start=0, timeout=0, print_to_stdout=False):
events = epoll.poll(1)
for fileno, event in events:
if event & select.EPOLLIN:
#print (fileno, event)
#print(fileno, event)
if fileno == fds[0].fileno():
r = fds[0].read()
#print r
output += r
if print_to_stdout:
sys.stdout.write(r)
else:
r = fds[1].read()
#print r
output += r
if print_to_stdout:
sys.stdout.write(r)