Also add the appropriate __future__ import statement.
Signed-off-by: Julien Goodwin <jgoodwin@studio442.com.au>
[rlb@defaultvalue.org: memtest-cmd.py: remove a few preexisting
trailing spaces that were carried over; adjust commit summary]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
"""
# end of bup preamble
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
from os.path import relpath
import sys
pass
else:
for (name,st) in it:
- print name
+ print(name)
if saved_errors:
log('WARNING: %d errors encountered.\n' % len(saved_errors))
"""
# end of bup preamble
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import sys, os, glob, subprocess
from bup import options, git
assert(opt.generate and (not par2_ok or par2_exists))
action_result = 'exists' if par2_exists else 'skipped'
if opt.verbose:
- print last, action_result
+ print(last, action_result)
return code
"""
# end of bup preamble
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import sys, os, stat, fnmatch
from bup import options, git, shquote, ls, vfs
try:
yield raw_input('bup> ')
except EOFError:
- print '' # Clear the line for the terminal's next prompt
+ print() # Clear the line for the terminal's next prompt
break
else:
for line in sys.stdin:
elif cmd == 'pwd':
if len(pwd) == 1:
sys.stdout.write('/')
- print '/'.join(name for name, item in pwd)
+ print('/'.join(name for name, item in pwd))
elif cmd == 'cat':
for parm in words[1:]:
res = vfs.resolve(repo, parm, parent=pwd)
"""
# end of bup preamble
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import sys, stat, time, os, errno, re
from bup import metadata, options, git, index, drecurse, hlinkdb
line += ent.sha.encode('hex') + ' '
if opt.long:
line += "%7s %7s " % (oct(ent.mode), oct(ent.gitmode))
- print line + (name or './')
+ print(line + (name or './'))
if opt.check and (opt['print'] or opt.status or opt.modified or opt.update):
log('check: starting final check.\n')
"""
# end of bup preamble
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import sys, os
from bup import git, options
continue
if len(opt.find) == 40:
if ix.exists(bin):
- print name, find
+ print(name, find)
else:
# slow, exhaustive search
for _i in ix:
i = str(_i).encode('hex')
if i.startswith(find):
- print name, i
+ print(name, i)
qprogress('Searching: %d\r' % count)
count += 1
"""
# end of bup preamble
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import sys, struct, math
from bup import options, git, _helpers
expected = prefix * total / (1<<64)
diff = count - expected
maxdiff = max(maxdiff, abs(diff))
- print '%d of %d (%.3f%%) ' % (maxdiff, len(ix), maxdiff*100.0/len(ix))
+ print('%d of %d (%.3f%%) ' % (maxdiff, len(ix), maxdiff*100.0/len(ix)))
sys.stdout.flush()
assert(count+1 == len(ix))
pm = _helpers.bitmatch(last, i)
longmatch = max(longmatch, pm)
last = i
- print longmatch
+ print(longmatch)
log('%d matching prefix bits\n' % longmatch)
doublings = math.log(len(mi), 2)
bpd = longmatch / doublings
"""
# end of bup preamble
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import sys, re, struct, time, resource
from bup import git, bloom, midx, options, _helpers
int((now - last) * 1000)]
fmt = '%9s ' + ('%10s ' * len(fields))
if count >= 0:
- print fmt % tuple([count] + fields)
+ print(fmt % tuple([count] + fields))
else:
start = now
- print fmt % tuple([''] + headers)
+ print(fmt % tuple([''] + headers))
sys.stdout.flush()
-
+
# don't include time to run report() in usage counts
ru = resource.getrusage(resource.RUSAGE_SELF)
last_u = ru.ru_utime
report((c+1)*opt.number)
if bloom._total_searches:
- print ('bloom: %d objects searched in %d steps: avg %.3f steps/object'
- % (bloom._total_searches, bloom._total_steps,
- bloom._total_steps*1.0/bloom._total_searches))
+ print('bloom: %d objects searched in %d steps: avg %.3f steps/object'
+ % (bloom._total_searches, bloom._total_steps,
+ bloom._total_steps*1.0/bloom._total_searches))
if midx._total_searches:
- print ('midx: %d objects searched in %d steps: avg %.3f steps/object'
- % (midx._total_searches, midx._total_steps,
- midx._total_steps*1.0/midx._total_searches))
+ print('midx: %d objects searched in %d steps: avg %.3f steps/object'
+ % (midx._total_searches, midx._total_steps,
+ midx._total_steps*1.0/midx._total_searches))
if git._total_searches:
- print ('idx: %d objects searched in %d steps: avg %.3f steps/object'
- % (git._total_searches, git._total_steps,
- git._total_steps*1.0/git._total_searches))
-print 'Total time: %.3fs' % (time.time() - start)
+ print('idx: %d objects searched in %d steps: avg %.3f steps/object'
+ % (git._total_searches, git._total_steps,
+ git._total_steps*1.0/git._total_searches))
+print('Total time: %.3fs' % (time.time() - start))
"""
# end of bup preamble
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
from errno import EACCES
from io import BytesIO
import os, sys, stat, time, math
dir_metadata = metadata.Metadata() if root_collision else None)
if opt.tree:
- print tree.encode('hex')
+ print(tree.encode('hex'))
if opt.commit or opt.name:
msg = 'bup save\n\nGenerated by command:\n%r\n' % sys.argv
userline = '%s <%s@%s>' % (userfullname(), username(), hostname())
commit = w.new_commit(tree, oldref, userline, date, None,
userline, date, None, msg)
if opt.commit:
- print commit.encode('hex')
+ print(commit.encode('hex'))
msr.close()
w.close() # must close before we can update the ref
"""
# end of bup preamble
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import os, sys
from bup import git, options
if not extra:
for t in tags:
- print t
+ print(t)
sys.exit(0)
elif len(extra) < 2:
o.fatal('no commit ref or hash given.')
# This code is covered under the terms of the GNU Library General
# Public License as described in the bup LICENSE file.
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import sys, stat, errno
from bup import metadata, options, xstat
raise
if metadata.verbose >= 0:
if not first_path:
- print
+ print()
if atime_resolution != 1:
m.atime = (m.atime / atime_resolution) * atime_resolution
if mtime_resolution != 1:
m.mtime = (m.mtime / mtime_resolution) * mtime_resolution
if ctime_resolution != 1:
m.ctime = (m.ctime / ctime_resolution) * ctime_resolution
- print metadata.detailed_str(m, active_fields)
+ print(metadata.detailed_str(m, active_fields))
first_path = False
if saved_errors:
# This code is covered under the terms of the GNU Library General
# Public License as described in the bup LICENSE file.
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
from copy import deepcopy
from errno import EACCES, EINVAL, ENOTTY, ENOSYS, EOPNOTSUPP
from io import BytesIO
m = from_path(p, statinfo=st, archive_path=safe_path,
save_symlinks=save_symlinks)
if verbose:
- print >> sys.stderr, m.path
+ print(m.path, file=sys.stderr)
m.write(output_file, include_path=write_paths)
else:
start_dir = os.getcwd()
m = from_path(p, statinfo=st, archive_path=safe_path,
save_symlinks=save_symlinks)
if verbose:
- print >> sys.stderr, m.path
+ print(m.path, file=sys.stderr)
m.write(output_file, include_path=write_paths)
os.chdir(dirlist_dir)
finally:
first_item = True
for meta in _ArchiveIterator(file):
if not first_item:
- print
- print detailed_str(meta)
+ print()
+ print(detailed_str(meta))
first_item = False
elif verbose > 0:
for meta in _ArchiveIterator(file):
- print summary_str(meta)
+ print(summary_str(meta))
elif verbose == 0:
for meta in _ArchiveIterator(file):
if not meta.path:
- print >> sys.stderr, \
- 'bup: no metadata path, but asked to only display path', \
- '(increase verbosity?)'
+ print('bup: no metadata path, but asked to only display path'
+ '(increase verbosity?)')
sys.exit(1)
- print meta.path
+ print(meta.path)
def start_extract(file, create_symlinks=True):
if not meta: # Hit end record.
break
if verbose:
- print >> sys.stderr, meta.path
+ print(meta.path, file=sys.stderr)
xpath = _clean_up_extract_path(meta.path)
if not xpath:
add_error(Exception('skipping risky path "%s"' % meta.path))
all_dirs.append(meta)
else:
if verbose:
- print >> sys.stderr, meta.path
+ print(meta.path, file=sys.stderr)
meta.apply_to_path(path=xpath,
restore_numeric_ids=restore_numeric_ids)
all_dirs.sort(key = lambda x : len(x.path), reverse=True)
# Don't need to check xpath -- won't be in all_dirs if not OK.
xpath = _clean_up_extract_path(dir.path)
if verbose:
- print >> sys.stderr, dir.path
+ print(dir.path, file=sys.stderr)
dir.apply_to_path(path=xpath, restore_numeric_ids=restore_numeric_ids)
else:
meta.path = xpath
if verbose:
- print >> sys.stderr, '+', meta.path
+ print('+', meta.path, file=sys.stderr)
_set_up_path(meta, create_symlinks=create_symlinks)
if os.path.isdir(meta.path):
all_dirs.append(meta)
else:
if verbose:
- print >> sys.stderr, '=', meta.path
+ print('=', meta.path, file=sys.stderr)
meta.apply_to_path(restore_numeric_ids=restore_numeric_ids)
all_dirs.sort(key = lambda x : len(x.path), reverse=True)
for dir in all_dirs:
# Don't need to check xpath -- won't be in all_dirs if not OK.
xpath = _clean_up_extract_path(dir.path)
if verbose:
- print >> sys.stderr, '=', xpath
+ print('=', xpath, file=sys.stderr)
# Shouldn't have to check for risky paths here (omitted above).
dir.apply_to_path(path=dir.path,
restore_numeric_ids=restore_numeric_ids)
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import os, time
from wvtest import *
def dump(m):
for e in list(m):
- print '%s%s %s' % (e.is_valid() and ' ' or 'M',
+ print('%s%s %s' % (e.is_valid() and ' ' or 'M',
e.is_fake() and 'F' or ' ',
- e.name)
+ e.name))
def fake_validate(*l):
for i in l:
fake_validate(r1)
dump(r1)
- print [hex(e.flags) for e in r1]
+ print([hex(e.flags) for e in r1])
WVPASSEQ([e.name for e in r1 if e.is_valid()], r1all)
WVPASSEQ([e.name for e in r1 if not e.is_valid()], [])
WVPASSEQ([e.name for e in index.merge(r2, r1, r3) if not e.is_valid()],
| set(['/a/b/n/2', '/a/c/n/3'])
dump(index.merge(r2, r1, r3))
for e in index.merge(r2, r1, r3):
- print e.name, hex(e.flags), e.ctime
+ print(e.name, hex(e.flags), e.ctime)
eiv = e.name in expect_invalid
er = e.name in expect_real
WVPASSEQ(eiv, not e.is_valid())
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import errno, glob, grp, pwd, stat, tempfile, subprocess
from wvtest import *
def ex(*cmd):
try:
cmd_str = ' '.join(cmd)
- print >> sys.stderr, cmd_str
+ print(cmd_str, file=sys.stderr)
rc = subprocess.call(cmd)
if rc < 0:
- print >> sys.stderr, 'terminated by signal', - rc
+ print('terminated by signal', - rc, file=sys.stderr)
sys.exit(1)
elif rc > 0:
- print >> sys.stderr, 'returned exit status', rc
+ print('returned exit status', rc, file=sys.stderr)
sys.exit(1)
except OSError as e:
- print >> sys.stderr, 'subprocess call failed:', e
+ print('subprocess call failed:', e, file=sys.stderr)
sys.exit(1)
os.chmod(path, 0o000)
metadata.from_path(path, archive_path=path, save_symlinks=True)
if metadata.get_linux_file_attr:
- print >> sys.stderr, 'saved_errors:', helpers.saved_errors
+ print('saved_errors:', helpers.saved_errors, file=sys.stderr)
WVPASS(len(helpers.saved_errors) == 1)
errmsg = _first_err()
WVPASS(errmsg.startswith('read Linux attr'))
WVPASSEQ(m.path, path)
os.chmod(parent, 0o000)
m.apply_to_path(path)
- print >> sys.stderr, 'saved_errors:', helpers.saved_errors
+ print('saved_errors:', helpers.saved_errors, file=sys.stderr)
expected_errors = ['utime: ']
if m.linux_attr and _linux_attr_supported(tmpdir):
expected_errors.append('Linux chattr: ')