本文整理汇总了Python中synctool_lib.verbose函数的典型用法代码示例。如果您正苦于以下问题:Python verbose函数的具体用法?Python verbose怎么用?Python verbose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了verbose函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: overlay_callback
def overlay_callback(obj):
'''compare files and run post-script if needed'''
verbose('checking %s' % obj.print_src())
if obj.compare_files():
run_post(obj.src_path, obj.dest_path)
示例2: single_files
def single_files(filename):
'''check/update a single file'''
'''returns (True, path_in_synctree) if file is different'''
if not filename:
stderr('missing filename')
return (False, None)
(obj, err) = synctool_overlay.find_terse(synctool_overlay.OV_OVERLAY, filename)
if err == synctool_overlay.OV_FOUND_MULTIPLE:
# multiple source possible
# possibilities have already been printed
sys.exit(1)
if err == synctool_overlay.OV_NOT_FOUND:
stderr('%s is not in the overlay tree' % filename)
return (False, None)
verbose('checking against %s' % obj.print_src())
changed = obj.compare_files()
if not changed:
stdout('%s is up to date' % filename)
terse(synctool_lib.TERSE_OK, filename)
unix_out('# %s is up to date\n' % obj.print_dest())
return (changed, obj.src_path)
示例3: run_remote_copy
def run_remote_copy(nodes, files):
"""copy files[] to nodes[]"""
if not synctool_param.SCP_CMD:
stderr(
"%s: error: scp_cmd has not been defined in %s" % (os.path.basename(sys.argv[0]), synctool_param.CONF_FILE)
)
sys.exit(-1)
scp_cmd_arr = shlex.split(synctool_param.SCP_CMD)
if SCP_OPTIONS:
scp_cmd_arr.extend(shlex.split(SCP_OPTIONS))
for node in nodes:
if node == synctool_param.NODENAME:
verbose("skipping node %s" % node)
nodes.remove(node)
break
scp_cmd_arr.extend(files)
files_str = string.join(files) # this is used only for printing
synctool_lib.run_parallel(master_scp, worker_scp, (nodes, scp_cmd_arr, files_str), len(nodes))
示例4: get_latest_version_and_checksum
def get_latest_version_and_checksum():
'''get latest version and checksum by downloading the LATEST.txt versioning file'''
verbose('accessing URL %s' % VERSION_CHECKING_URL)
try:
opener = urllib.FancyURLopener({})
f = opener.open(VERSION_CHECKING_URL)
data = f.read()
f.close()
except:
stderr('error accessing the file at %s' % VERSION_CHECKING_URL)
return None
if data[0] == '<':
stderr('error accessing the file at %s' % VERSION_CHECKING_URL)
return None
data = string.strip(data)
# format of the data in LATEST.txt is:
# <version> <MD5 checksum>
arr = string.split(data)
if len(arr) != 2:
return None
return (arr[0], arr[1])
示例5: master_ping
def master_ping(rank, nodes):
nodename = NODESET.get_nodename_from_interface(nodes[rank])
if nodename == synctool_param.NODENAME:
print '%s: up' % nodename
return
verbose('pinging %s' % nodename)
unix_out('%s %s' % (synctool_param.PING_CMD, nodes[rank]))
示例6: master_pkg
def master_pkg(rank, args):
# the master node only displays what we're running
(nodes, ssh_cmd_arr, pkg_cmd_arr) = args
node = nodes[rank]
nodename = NODESET.get_nodename_from_interface(node)
verbose('running synctool-pkg on node %s' % nodename)
unix_out('%s %s %s' % (string.join(ssh_cmd_arr), node, string.join(pkg_cmd_arr)))
示例7: hard_delete_file
def hard_delete_file(self):
file = self.dest_path
unix_out('rm -f %s' % file)
if not synctool_lib.DRY_RUN:
verbose(' os.unlink(%s)' % file)
try:
os.unlink(file)
except OSError, reason:
stderr('failed to delete %s : %s' % (file, reason))
示例8: set_permissions
def set_permissions(self):
file = self.dest_path
mode = self.src_statbuf.mode
unix_out('chmod 0%o %s' % (mode & 07777, file))
if not synctool_lib.DRY_RUN:
verbose(' os.chmod(%s, %04o)' % (file, mode & 07777))
try:
os.chmod(file, mode & 07777)
except OSError, reason:
stderr('failed to chmod %04o %s : %s' % (mode & 07777, file, reason))
示例9: set_owner
def set_owner(self):
file = self.dest_path
uid = self.src_statbuf.uid
gid = self.src_statbuf.gid
unix_out("chown %s.%s %s" % (self.src_ascii_uid(), self.src_ascii_gid(), file))
if not synctool_lib.DRY_RUN:
verbose(" os.chown(%s, %d, %d)" % (file, uid, gid))
try:
os.chown(file, uid, gid)
except OSError, reason:
stderr("failed to chown %s.%s %s : %s" % (self.src_ascii_uid(), self.src_ascii_gid(), file, reason))
示例10: master_synctool
def master_synctool(rank, args):
# the master node only displays what we're running
(nodes, rsync_cmd_arr, ssh_cmd_arr, synctool_cmd_arr) = args
node = nodes[rank]
nodename = NODESET.get_nodename_from_interface(node)
if rsync_cmd_arr != None:
verbose('running rsync $masterdir/ to node %s' % nodename)
unix_out('%s %s:%s/' % (string.join(rsync_cmd_arr), node, synctool_param.MASTERDIR))
verbose('running synctool on node %s' % nodename)
unix_out('%s %s %s' % (string.join(ssh_cmd_arr), node, string.join(synctool_cmd_arr)))
示例11: mkdir_basepath
def mkdir_basepath(self):
'''call mkdir -p if the destination directory does not exist yet'''
if synctool_lib.DRY_RUN:
return
# check if the directory exists
basedir = os.path.dirname(self.dest_path)
stat = synctool_stat.SyncStat(basedir)
if not stat.exists():
# create the directory
verbose('making directory %s' % synctool_lib.prettypath(basedir))
unix_out('mkdir -p %s' % basedir)
synctool_lib.mkdir_p(basedir)
示例12: copy_file
def copy_file(self):
self.mkdir_basepath()
src = self.src_path
dest = self.dest_path
if self.dest_isFile():
unix_out('cp %s %s.saved' % (dest, dest))
unix_out('umask 077')
unix_out('cp %s %s' % (src, dest))
if not synctool_lib.DRY_RUN:
old_umask = os.umask(077)
if synctool_param.BACKUP_COPIES:
if self.dest_isFile():
verbose(' saving %s as %s.saved' % (dest, dest))
try:
shutil.copy2(dest, '%s.saved' % dest)
except:
stderr('failed to save %s as %s.saved' % (dest, dest))
verbose(' cp %s %s' % (src, dest))
try:
shutil.copy2(src, dest) # copy file and stats
except:
stderr('failed to copy %s to %s' % (self.print_src(), dest))
os.umask(old_umask)
else:
if self.dest_isFile() and synctool_param.BACKUP_COPIES:
verbose(' saving %s as %s.saved' % (dest, dest))
verbose(dryrun_msg(' cp %s %s' % (src, dest)))
示例13: master_ssh
def master_ssh(rank, args):
(nodes, ssh_cmd_arr, remote_cmd_arr) = args
node = nodes[rank]
cmd_str = string.join(remote_cmd_arr)
if node == synctool_param.NODENAME:
verbose('running %s' % cmd_str)
unix_out(cmd_str)
else:
verbose('running %s to %s %s' % (os.path.basename(ssh_cmd_arr[0]),
NODESET.get_nodename_from_interface(node), cmd_str))
unix_out('%s %s %s' % (string.join(ssh_cmd_arr), node, cmd_str))
示例14: save_dir
def save_dir(self):
if not synctool_param.BACKUP_COPIES:
return
path = self.dest_path
unix_out('mv %s %s.saved' % (path, path))
if not synctool_lib.DRY_RUN:
verbose('moving %s to %s.saved' % (path, path))
try:
os.rename(path, '%s.saved' % path)
except OSError, reason:
stderr('failed to move directory to %s.saved : %s' % (path, reason))
示例15: erase_saved
def erase_saved(self):
dest = self.dest_path
stat_saved_path = synctool_stat.SyncStat('%s.saved' % dest)
if synctool_lib.ERASE_SAVED and stat_saved_path.exists() and not stat_saved_path.isDir():
terse(synctool_lib.TERSE_DELETE, '%s.saved' % dest)
unix_out('rm %s.saved' % dest)
if synctool_lib.DRY_RUN:
stdout(dryrun_msg('erase %s.saved' % dest, 'erase'))
else:
stdout('erase %s.saved' % dest)
verbose(' os.unlink(%s.saved)' % dest)
try:
os.unlink('%s.saved' % dest)
except OSError, reason:
stderr('failed to delete %s : %s' % (dest, reason))