Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.pd("File info json: {}".format(self.__remote_json))
return const.ENoError
rdir, rfile = posixpath.split(remotefile)
self.pd("__get_file_info(): rdir : {} | rfile: {}".format(rdir, rfile))
if rdir and rfile:
pars = {
'method' : 'list',
'path' : rdir,
'by' : 'name', # sort in case we can use binary-search, etc in the futrue.
'order' : 'asc' }
return self.__get(pcsurl + 'file', pars, self.__get_file_info_act, remotefile, **kwargs)
else:
perr("Invalid remotefile '{}' specified.".format(remotefile))
return const.EArgument
def __multi_process(self, worker, iterator, process = "dl / ul"):
if not self.__check_prompt_multiprocess():
return const.EArgument
self.__warn_multi_processes(process)
# patch the printer
restoremp = set_mp_print()
with UPool(self.processes) as pool:
try:
# http://stackoverflow.com/a/35134329/404271
# On Python 2.x, Ctrl-C won't work if we use pool.map(), wait() or get()
ar = pool.map_async(worker, iterator)
#results = ar.get(const.TenYearInSeconds)
results = ar.get(const.FortyNineDaysInSeconds)
restoremp()
return self.__filter_multi_results(results)
except pickle.PicklingError as pe:
errmsg = ("Exception:\n{}\n"
"--------------------------------\n"
"Error: Your Python 'multiprocess' library is probably "
if args[0].upper() == 'L':
try:
with io.open(args[1:], 'r', encoding = 'utf-8') as f:
contents = f.read()
digests = filter(None, contents.split())
for d in digests:
self.__slice_md5s.append(d)
except IOError as ex:
perr("Exception occured while reading file '{}'.\n{}".format(
localfile, formatex(ex)))
else:
for arg in args:
self.__slice_md5s.append(arg)
else:
perr("You MUST provide the MD5s hex strings through arguments or a file.")
return const.EArgument
original_verify = self.__verify
if not localfile or localfile == '*' or localfile == '/dev/null':
self.__current_file = '/dev/null' # Force no verify
self.__verify = False
else:
self.__current_file = localfile
self.__current_file_size = getfilesize(localfile)
result = self.__combine_file(get_pcs_path(remotefile))
self.__verify = original_verify
return result