Fix log action on download and upload (class Gateway)

pull/3/head
remittor 3 years ago
parent 2bc71b18fe
commit a56bf32a39

@ -327,6 +327,8 @@ class Gateway():
return True return True
def download(self, fn_remote, fn_local, verbose = 1): def download(self, fn_remote, fn_local, verbose = 1):
if verbose and self.verbose:
print('Download file: "{}" ....'.format(fn_remote))
if self.use_ssh: if self.use_ssh:
ssh = self.get_ssh(self.verbose) ssh = self.get_ssh(self.verbose)
channel, fileinfo = ssh.scp_recv2(fn_remote) channel, fileinfo = ssh.scp_recv2(fn_remote)
@ -344,8 +346,6 @@ class Gateway():
else: else:
ftp = self.get_ftp(self.verbose) ftp = self.get_ftp(self.verbose)
file = open(fn_local, 'wb') file = open(fn_local, 'wb')
if verbose and self.verbose:
print('Download file: "{}" ....'.format(fn_remote))
ftp.retrbinary('RETR ' + fn_remote, file.write) ftp.retrbinary('RETR ' + fn_remote, file.write)
file.close() file.close()
return True return True
@ -355,6 +355,8 @@ class Gateway():
file = open(fn_local, 'rb') file = open(fn_local, 'rb')
except Exception: except Exception:
die('File "{}" not found.'.format(fn_local)) die('File "{}" not found.'.format(fn_local))
if verbose and self.verbose:
print('Upload file: "{}" ....'.format(fn_local))
if self.use_ssh: if self.use_ssh:
ssh = self.get_ssh(self.verbose) ssh = self.get_ssh(self.verbose)
finfo = os.stat(fn_local) finfo = os.stat(fn_local)
@ -366,8 +368,6 @@ class Gateway():
#except ssh2.exceptions.SCPProtocolError as e: #except ssh2.exceptions.SCPProtocolError as e:
else: else:
ftp = self.get_ftp(self.verbose) ftp = self.get_ftp(self.verbose)
if verbose and self.verbose:
print('Upload file: "{}" ....'.format(fn_local))
ftp.storbinary('STOR ' + fn_remote, file) ftp.storbinary('STOR ' + fn_remote, file)
file.close() file.close()
return True return True

Loading…
Cancel
Save