class PluginImpl(object):
...
def download_repomd(self):
" May throw if repomd.xml does not exists at server "
with open(os.devnull, 'w') as FNULL:
return check_output([
"wget", self.mtdt_url + "repomd.xml", "-O-"
], stderr=FNULL).decode("utf-8")
...
def _sync(self, url, input_file, target):
" this is exception safe (unless something unexpected will happen) "
# if file that will be synced does not exists, this should be aborted
if not os.path.isfile(input_file):
check_output(["touch", input_file])
try:
zsync = Popen(["zsync", url, "-i", input_file, "-o",
target], stdout=PIPE, stderr=PIPE)
outputs = zsync.communicate()
if self._print_log:
print(outputs[1].decode("utf-8"))
print(outputs[0].decode("utf-8"))
except CalledProcessError as ex:
# print(str(ex), file=sys.stderr)
# reverse rewriting existing if there was any
try:
check_output(["mv", target + ".zs-old", target])
except:
pass
else:
# cleanup
check_output(["rm", "-rf", target + ".zs-old",
input_file if input_file != target else ""])
return zsync.returncode
P.S. мопед не мой