brynq-sdk-ftp 1.0.0__tar.gz → 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {brynq_sdk_ftp-1.0.0 → brynq_sdk_ftp-2.0.0}/PKG-INFO +1 -1
- {brynq_sdk_ftp-1.0.0 → brynq_sdk_ftp-2.0.0}/brynq_sdk_ftp.egg-info/PKG-INFO +1 -1
- {brynq_sdk_ftp-1.0.0 → brynq_sdk_ftp-2.0.0}/brynq_sdk_ftp.egg-info/SOURCES.txt +0 -3
- {brynq_sdk_ftp-1.0.0 → brynq_sdk_ftp-2.0.0}/brynq_sdk_ftp.egg-info/requires.txt +1 -1
- brynq_sdk_ftp-2.0.0/brynq_sdk_ftp.egg-info/top_level.txt +1 -0
- {brynq_sdk_ftp-1.0.0 → brynq_sdk_ftp-2.0.0}/setup.py +4 -5
- brynq_sdk_ftp-1.0.0/brynq_sdk/ftp/__init__.py +0 -2
- brynq_sdk_ftp-1.0.0/brynq_sdk/ftp/ftps.py +0 -227
- brynq_sdk_ftp-1.0.0/brynq_sdk/ftp/sftp.py +0 -141
- brynq_sdk_ftp-1.0.0/brynq_sdk_ftp.egg-info/top_level.txt +0 -1
- {brynq_sdk_ftp-1.0.0 → brynq_sdk_ftp-2.0.0}/brynq_sdk_ftp.egg-info/dependency_links.txt +0 -0
- {brynq_sdk_ftp-1.0.0 → brynq_sdk_ftp-2.0.0}/brynq_sdk_ftp.egg-info/not-zip-safe +0 -0
- {brynq_sdk_ftp-1.0.0 → brynq_sdk_ftp-2.0.0}/setup.cfg +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
from setuptools import setup
|
|
2
|
-
|
|
1
|
+
from setuptools import setup, find_namespace_packages
|
|
3
2
|
|
|
4
3
|
setup(
|
|
5
4
|
name='brynq_sdk_ftp',
|
|
6
|
-
version='
|
|
5
|
+
version='2.0.0',
|
|
7
6
|
description='FTP wrapper from BrynQ',
|
|
8
7
|
long_description='FTP wrapper from Brynq',
|
|
9
8
|
author='BrynQ',
|
|
10
9
|
author_email='support@brynq.com',
|
|
11
|
-
packages=[
|
|
10
|
+
packages=find_namespace_packages(include=['brynq_sdk*']),
|
|
12
11
|
license='BrynQ License',
|
|
13
12
|
install_requires=[
|
|
14
|
-
'brynq-sdk-brynq>=
|
|
13
|
+
'brynq-sdk-brynq>=2',
|
|
15
14
|
'requests>=2,<=3',
|
|
16
15
|
'paramiko>=2,<=4',
|
|
17
16
|
'pysftp>0.2,<1',
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import ftplib
|
|
3
|
-
import time
|
|
4
|
-
from ftplib import FTP
|
|
5
|
-
from brynq_sdk.brynq import BrynQ
|
|
6
|
-
from typing import Union, List
|
|
7
|
-
from tenacity import retry, stop_after_attempt, wait_exponential_jitter, retry_if_exception
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def is_ftp_exception(e: BaseException) -> bool:
|
|
11
|
-
if isinstance(e, ftplib.all_errors):
|
|
12
|
-
error = str(e)[:400].replace('\'', '').replace('\"', '')
|
|
13
|
-
print(f"{error}, retrying")
|
|
14
|
-
return True
|
|
15
|
-
else:
|
|
16
|
-
return False
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class FTPS(BrynQ):
|
|
20
|
-
def __init__(self, label: Union[str, List] = None, debug=False):
|
|
21
|
-
super().__init__()
|
|
22
|
-
if label is not None:
|
|
23
|
-
credentials = self.get_system_credential(system='ftps', label=label)
|
|
24
|
-
self.host = credentials['host']
|
|
25
|
-
self.username = credentials['username']
|
|
26
|
-
self.password = credentials['password']
|
|
27
|
-
elif os.getenv("QLIK_HOST") is not None and os.getenv("QLIK_USER") is not None and os.getenv("QLIK_PASSWORD") is not None:
|
|
28
|
-
self.host = os.getenv("QLIK_HOST")
|
|
29
|
-
self.username = os.getenv("QLIK_USER")
|
|
30
|
-
self.password = os.getenv("QLIK_PASSWORD")
|
|
31
|
-
else:
|
|
32
|
-
raise ValueError("Set the environment variables QLIK_HOST, QLIK_USER and QLIK_PASSWORD or provide the label parameter for a credential from BrynQ")
|
|
33
|
-
self.debug = debug
|
|
34
|
-
|
|
35
|
-
@retry(stop=stop_after_attempt(5), wait=wait_exponential_jitter(initial=60, max=900), retry=retry_if_exception(is_ftp_exception), reraise=True)
|
|
36
|
-
def upload_file(self, local_path, filename, remote_path, remove_after_upload=False):
|
|
37
|
-
"""
|
|
38
|
-
Upload a file from the client to another client or server
|
|
39
|
-
:param local_path: the path where the upload file is located
|
|
40
|
-
:param filename: The file which should be uploaded
|
|
41
|
-
:param remote_path: The path on the destination client where the file should be saved
|
|
42
|
-
:param remove_after_upload: If true, remove the file after a succesfull upload
|
|
43
|
-
:return: a status if the upload is succesfull or not
|
|
44
|
-
"""
|
|
45
|
-
with FTP(host=self.host, user=self.username, passwd=self.password) as ftp:
|
|
46
|
-
ftp.cwd(remote_path)
|
|
47
|
-
with open(local_path + filename, 'rb') as fp:
|
|
48
|
-
# This runs until upload is successful, then breaks
|
|
49
|
-
while True:
|
|
50
|
-
try:
|
|
51
|
-
ftp.storbinary("STOR " + filename, fp)
|
|
52
|
-
# If the file should be removed after upload, remove it from the local path
|
|
53
|
-
if remove_after_upload:
|
|
54
|
-
os.remove(f'{local_path}{filename}')
|
|
55
|
-
except ftplib.error_temp as e:
|
|
56
|
-
# this catches 421 errors (socket timeout), sleeps 10 seconds and tries again. If any other exception is encountered, breaks.
|
|
57
|
-
if str(e).split()[0] == '421':
|
|
58
|
-
time.sleep(10)
|
|
59
|
-
continue
|
|
60
|
-
else:
|
|
61
|
-
raise
|
|
62
|
-
break
|
|
63
|
-
ftp.close()
|
|
64
|
-
return 'File is transferred'
|
|
65
|
-
|
|
66
|
-
@retry(stop=stop_after_attempt(5), wait=wait_exponential_jitter(initial=60, max=900), retry=retry_if_exception(is_ftp_exception), reraise=True)
|
|
67
|
-
def upload_multiple_files(self, local_path, remote_path, remove_after_upload=False):
|
|
68
|
-
"""
|
|
69
|
-
Upload all files in a directory from the client to another client or server
|
|
70
|
-
:param local_path: the path from where all the files should be uploaded
|
|
71
|
-
:param remote_path: The path on the destination client where the file should be saved
|
|
72
|
-
:param remove_after_upload: If true, remove the file after a succesfull upload
|
|
73
|
-
:return: a status if the upload is succesfull or not
|
|
74
|
-
"""
|
|
75
|
-
ftp = FTP(host=self.host, user=self.username, passwd=self.password)
|
|
76
|
-
ftp.cwd(remote_path)
|
|
77
|
-
for filename in os.listdir(local_path):
|
|
78
|
-
file = local_path + filename
|
|
79
|
-
if self.debug:
|
|
80
|
-
print(f"Remote path: {remote_path}, local file: {file}")
|
|
81
|
-
if os.path.isfile(file):
|
|
82
|
-
with open(file, 'rb') as fp:
|
|
83
|
-
# This runs until upload is successful, then breaks
|
|
84
|
-
while True:
|
|
85
|
-
try:
|
|
86
|
-
ftp.storbinary("STOR " + filename, fp)
|
|
87
|
-
# If the file should be removed after upload, remove it from the local path
|
|
88
|
-
if remove_after_upload:
|
|
89
|
-
os.remove(file)
|
|
90
|
-
except ftplib.error_temp as e:
|
|
91
|
-
# this catches 421 errors (socket timeout), sleeps 10 seconds and tries again. If any other exception is encountered, breaks.
|
|
92
|
-
if str(e).split()[0] == '421':
|
|
93
|
-
time.sleep(10)
|
|
94
|
-
continue
|
|
95
|
-
else:
|
|
96
|
-
raise
|
|
97
|
-
break
|
|
98
|
-
ftp.close()
|
|
99
|
-
return 'All files are transferred'
|
|
100
|
-
|
|
101
|
-
@retry(stop=stop_after_attempt(5), wait=wait_exponential_jitter(initial=60, max=900), retry=retry_if_exception(is_ftp_exception), reraise=True)
|
|
102
|
-
def download_file(self, local_path, remote_path, filename, remove_after_download=False):
|
|
103
|
-
"""
|
|
104
|
-
Returns a single file from a given remote path
|
|
105
|
-
:param local_path: the folder where the downloaded file should be stored
|
|
106
|
-
:param remote_path: the folder on the server where the file should be downloaded from
|
|
107
|
-
:param filename: the filename itself
|
|
108
|
-
:param remove_after_download: Should the file be removed on the server after the download or not
|
|
109
|
-
:return: a status
|
|
110
|
-
"""
|
|
111
|
-
if self.debug:
|
|
112
|
-
print(f"Remote path: {remote_path}, local file path: {filename}")
|
|
113
|
-
with FTP(host=self.host, user=self.username, passwd=self.password) as ftp:
|
|
114
|
-
with open('{}/{}'.format(local_path, filename), 'wb') as fp:
|
|
115
|
-
res = ftp.retrbinary('RETR {}/{}'.format(remote_path, filename), fp.write)
|
|
116
|
-
if not res.startswith('226 Successfully transferred'):
|
|
117
|
-
# Remove the created file on the local client if the download is failed
|
|
118
|
-
if os.path.isfile(f'{local_path}/{filename}'):
|
|
119
|
-
os.remove(f'{local_path}/{filename}')
|
|
120
|
-
else:
|
|
121
|
-
if remove_after_download:
|
|
122
|
-
ftp.delete(filename)
|
|
123
|
-
|
|
124
|
-
return res
|
|
125
|
-
|
|
126
|
-
@retry(stop=stop_after_attempt(5), wait=wait_exponential_jitter(initial=60, max=900), retry=retry_if_exception(is_ftp_exception), reraise=True)
|
|
127
|
-
def make_dir(self, dir_name):
|
|
128
|
-
"""
|
|
129
|
-
Create a directory on a remote machine
|
|
130
|
-
:param dir_name: give the path name which should be created
|
|
131
|
-
:return: the status if the creation is successfull or not
|
|
132
|
-
"""
|
|
133
|
-
with FTP(host=self.host, user=self.username, passwd=self.password) as ftp:
|
|
134
|
-
status = ftp.mkd(dir_name)
|
|
135
|
-
return status
|
|
136
|
-
|
|
137
|
-
@retry(stop=stop_after_attempt(5), wait=wait_exponential_jitter(initial=60, max=900), retry=retry_if_exception(is_ftp_exception), reraise=True)
|
|
138
|
-
def list_directories(self, remote_path=''):
|
|
139
|
-
"""
|
|
140
|
-
Give a NoneType of directories and files in a given directory. This one is only for information. The Nonetype
|
|
141
|
-
can't be iterated or something like that
|
|
142
|
-
:param remote_path: give the folder where to start in
|
|
143
|
-
:return: a NoneType with folders and files
|
|
144
|
-
"""
|
|
145
|
-
with FTP(host=self.host, user=self.username, passwd=self.password) as ftp:
|
|
146
|
-
ftp.cwd(remote_path)
|
|
147
|
-
if self.debug:
|
|
148
|
-
print(ftp.dir())
|
|
149
|
-
return ftp.dir()
|
|
150
|
-
|
|
151
|
-
@retry(stop=stop_after_attempt(5), wait=wait_exponential_jitter(initial=60, max=900), retry=retry_if_exception(is_ftp_exception), reraise=True)
|
|
152
|
-
def make_dirs(self, filepath: str):
|
|
153
|
-
"""
|
|
154
|
-
shadows os.makedirs but for ftp
|
|
155
|
-
:param filepath: filepath that you want to create
|
|
156
|
-
:return: nothing
|
|
157
|
-
"""
|
|
158
|
-
filepath = filepath.split('/')
|
|
159
|
-
with FTP(host=self.host, user=self.username, passwd=self.password) as ftp:
|
|
160
|
-
ftp.cwd('/')
|
|
161
|
-
for subpath in filepath:
|
|
162
|
-
if subpath != '':
|
|
163
|
-
file_list = []
|
|
164
|
-
ftp.retrlines('NLST', file_list.append)
|
|
165
|
-
if subpath in file_list:
|
|
166
|
-
ftp.cwd(subpath)
|
|
167
|
-
else:
|
|
168
|
-
ftp.mkd(subpath)
|
|
169
|
-
ftp.cwd(subpath)
|
|
170
|
-
|
|
171
|
-
@retry(stop=stop_after_attempt(5), wait=wait_exponential_jitter(initial=60, max=900), retry=retry_if_exception(is_ftp_exception), reraise=True)
|
|
172
|
-
def list_files(self, remote_path=''):
|
|
173
|
-
"""
|
|
174
|
-
Give a list with files in a certain folder
|
|
175
|
-
:param remote_path: give the folder where to look in
|
|
176
|
-
:return: a list with files
|
|
177
|
-
"""
|
|
178
|
-
with FTP(host=self.host, user=self.username, passwd=self.password) as ftp:
|
|
179
|
-
ftp.cwd(remote_path)
|
|
180
|
-
if self.debug:
|
|
181
|
-
print(ftp.nlst())
|
|
182
|
-
return ftp.nlst()
|
|
183
|
-
|
|
184
|
-
@retry(stop=stop_after_attempt(5), wait=wait_exponential_jitter(initial=60, max=900), retry=retry_if_exception(is_ftp_exception), reraise=True)
|
|
185
|
-
def remove_file(self, remote_filepath):
|
|
186
|
-
"""
|
|
187
|
-
Remove a file on a remote location
|
|
188
|
-
:param remote_file: the full path of the file that needs to be removed
|
|
189
|
-
"""
|
|
190
|
-
with FTP(host=self.host, user=self.username, passwd=self.password) as ftp:
|
|
191
|
-
ftp.delete(remote_filepath)
|
|
192
|
-
|
|
193
|
-
@retry(stop=stop_after_attempt(5), wait=wait_exponential_jitter(initial=60, max=900), retry=retry_if_exception(is_ftp_exception), reraise=True)
|
|
194
|
-
def remove_directory(self, remote_directory, recursive=False):
|
|
195
|
-
"""
|
|
196
|
-
Remove a file on a remote location
|
|
197
|
-
:param remote_directory: the directory you want to remove
|
|
198
|
-
:param recursive: if you want to remove the directory recursively (including all files and subdirectories)
|
|
199
|
-
"""
|
|
200
|
-
ftp = FTP(host=self.host, user=self.username, passwd=self.password)
|
|
201
|
-
if recursive:
|
|
202
|
-
ftp.cwd(remote_directory)
|
|
203
|
-
files = ftp.nlst() # List directory contents
|
|
204
|
-
for file_name in files:
|
|
205
|
-
if file_name in ('.', '..'):
|
|
206
|
-
continue
|
|
207
|
-
try:
|
|
208
|
-
ftp.delete(file_name) # Delete file
|
|
209
|
-
except:
|
|
210
|
-
self.remove_directory(f"{remote_directory}/{file_name}", recursive=True) # Recursive call for subdirectories
|
|
211
|
-
ftp.cwd('..') # Move back to the parent directory
|
|
212
|
-
ftp.rmd(remote_directory.split('/')[-1]) # Remove the empty directory
|
|
213
|
-
else:
|
|
214
|
-
ftp.rmd(remote_directory)
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
@retry(stop=stop_after_attempt(5), wait=wait_exponential_jitter(initial=60, max=900), retry=retry_if_exception(is_ftp_exception), reraise=True)
|
|
218
|
-
def send_command(self, command):
|
|
219
|
-
"""
|
|
220
|
-
Send a command to the ftp server
|
|
221
|
-
:param command: the command that needs to be send
|
|
222
|
-
:return: the response of the server
|
|
223
|
-
"""
|
|
224
|
-
with FTP(host=self.host, user=self.username, passwd=self.password) as ftp:
|
|
225
|
-
response = ftp.sendcmd(command)
|
|
226
|
-
return response
|
|
227
|
-
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
from io import StringIO
|
|
2
|
-
from paramiko.client import SSHClient, AutoAddPolicy
|
|
3
|
-
from paramiko import RSAKey
|
|
4
|
-
from paramiko.sftp_attr import SFTPAttributes
|
|
5
|
-
import pysftp
|
|
6
|
-
from typing import Union, List
|
|
7
|
-
from brynq_sdk.brynq import BrynQ
|
|
8
|
-
from stat import S_ISREG
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class SFTP(BrynQ):
|
|
12
|
-
def __init__(self, label: Union[str, List], debug=False):
|
|
13
|
-
"""
|
|
14
|
-
Init the SFTP class
|
|
15
|
-
:param label: The label of the connector
|
|
16
|
-
:param debug: If you want to see debug messages
|
|
17
|
-
"""
|
|
18
|
-
super().__init__()
|
|
19
|
-
credentials = self.get_system_credential(system='sftp', label=label)
|
|
20
|
-
self.debug = debug
|
|
21
|
-
if self.debug:
|
|
22
|
-
print(credentials)
|
|
23
|
-
self.host = credentials['host']
|
|
24
|
-
self.port = 22 if credentials['port'] is None else credentials['port']
|
|
25
|
-
self.username = credentials['username']
|
|
26
|
-
self.password = credentials['password']
|
|
27
|
-
self.cnopts = pysftp.CnOpts()
|
|
28
|
-
self.cnopts.hostkeys = None
|
|
29
|
-
self.private_key_path = None
|
|
30
|
-
self.private_key = None
|
|
31
|
-
if credentials['private_key_path'] is not None:
|
|
32
|
-
self.private_key_path = credentials['private_key_path']
|
|
33
|
-
self.private_key_pass = credentials['private_key_password']
|
|
34
|
-
if credentials['private_key'] is not None:
|
|
35
|
-
self.private_key = RSAKey(file_obj=StringIO(credentials['private_key']))
|
|
36
|
-
self.client = SSHClient()
|
|
37
|
-
self.client.set_missing_host_key_policy(AutoAddPolicy())
|
|
38
|
-
|
|
39
|
-
def upload_file(self, local_filepath, remote_filepath, confirm=True) -> SFTPAttributes:
|
|
40
|
-
"""
|
|
41
|
-
Upload a single file to a remote location. If there is no Private key
|
|
42
|
-
:param local_filepath: The file and the full path on your local machine
|
|
43
|
-
:param remote_filepath: The path and filename on the remote location
|
|
44
|
-
:param confirm: If you want to confirm the upload
|
|
45
|
-
:return: status
|
|
46
|
-
"""
|
|
47
|
-
if self.private_key is None:
|
|
48
|
-
self.client.connect(hostname=self.host, port=self.port, username=self.username, password=self.password)
|
|
49
|
-
else:
|
|
50
|
-
self.client.connect(hostname=self.host, port=self.port, username=self.username, pkey=self.private_key)
|
|
51
|
-
sftp = self.client.open_sftp()
|
|
52
|
-
response = sftp.put(local_filepath, remote_filepath, confirm=confirm)
|
|
53
|
-
self.client.close()
|
|
54
|
-
|
|
55
|
-
return response
|
|
56
|
-
|
|
57
|
-
def list_dir(self, remote_filepath, get_folders: bool = False) -> List[str]:
|
|
58
|
-
"""
|
|
59
|
-
Read the files and folders an a certain location
|
|
60
|
-
:param remote_filepath: The full path where you want to get the content from
|
|
61
|
-
:return: a list with files and folders in the given location
|
|
62
|
-
"""
|
|
63
|
-
if self.private_key is None:
|
|
64
|
-
if self.debug:
|
|
65
|
-
print('No private key')
|
|
66
|
-
self.client.connect(hostname=self.host, port=self.port, username=self.username, password=self.password)
|
|
67
|
-
else:
|
|
68
|
-
if self.debug:
|
|
69
|
-
print('Private key')
|
|
70
|
-
self.client.connect(hostname=self.host, port=self.port, username=self.username, pkey=self.private_key)
|
|
71
|
-
sftp = self.client.open_sftp()
|
|
72
|
-
sftp.chdir(remote_filepath)
|
|
73
|
-
list_files = sftp.listdir_attr()
|
|
74
|
-
list_files = [file.filename for file in list_files if S_ISREG(file.st_mode) or get_folders]
|
|
75
|
-
self.client.close()
|
|
76
|
-
|
|
77
|
-
return list_files
|
|
78
|
-
|
|
79
|
-
def download_file(self, remote_path, remote_file, local_path):
|
|
80
|
-
"""
|
|
81
|
-
Download a single file
|
|
82
|
-
:param remote_path: the path where the remote file exists
|
|
83
|
-
:param remote_file: the remote file itself
|
|
84
|
-
:param local_path: the path where the file needs to be downloaded to
|
|
85
|
-
:return: a file object
|
|
86
|
-
"""
|
|
87
|
-
if self.private_key is None:
|
|
88
|
-
self.client.connect(hostname=self.host, port=self.port, username=self.username, password=self.password)
|
|
89
|
-
else:
|
|
90
|
-
self.client.connect(hostname=self.host, port=self.port, username=self.username, pkey=self.private_key)
|
|
91
|
-
sftp = self.client.open_sftp()
|
|
92
|
-
sftp.get(remotepath=f'{remote_path}{remote_file}', localpath=f'{local_path}/{remote_file}')
|
|
93
|
-
self.client.close()
|
|
94
|
-
|
|
95
|
-
def make_dir(self, remote_path, new_dir_name):
|
|
96
|
-
"""
|
|
97
|
-
Create a new folder on a remote location
|
|
98
|
-
:param remote_path: The location where you want to create the new folder
|
|
99
|
-
:param new_dir_name: The name of the new folder
|
|
100
|
-
:return: a status if creating succeeded or not
|
|
101
|
-
"""
|
|
102
|
-
if self.private_key is None:
|
|
103
|
-
self.client.connect(hostname=self.host, port=self.port, username=self.username, password=self.password)
|
|
104
|
-
else:
|
|
105
|
-
self.client.connect(hostname=self.host, port=self.port, username=self.username, pkey=self.private_key)
|
|
106
|
-
sftp = self.client.open_sftp()
|
|
107
|
-
sftp.chdir(remote_path)
|
|
108
|
-
sftp.mkdir(new_dir_name)
|
|
109
|
-
self.client.close()
|
|
110
|
-
|
|
111
|
-
def remove_file(self, remote_file):
|
|
112
|
-
"""
|
|
113
|
-
Remove a file on a remote location
|
|
114
|
-
:param remote_file: the full path of the file that needs to be removed
|
|
115
|
-
:return: a status if deleting succeeded or not
|
|
116
|
-
"""
|
|
117
|
-
if self.private_key is None:
|
|
118
|
-
self.client.connect(hostname=self.host, port=self.port, username=self.username, password=self.password)
|
|
119
|
-
else:
|
|
120
|
-
self.client.connect(hostname=self.host, port=self.port, username=self.username, pkey=self.private_key)
|
|
121
|
-
sftp = self.client.open_sftp()
|
|
122
|
-
sftp.remove(remote_file)
|
|
123
|
-
self.client.close()
|
|
124
|
-
|
|
125
|
-
def move_file(self, old_file_path: str, new_file_path: str):
|
|
126
|
-
"""
|
|
127
|
-
Move or rename a file on a remote location
|
|
128
|
-
:param old_file_path: the full path of the file that needs to be moved or renamed
|
|
129
|
-
:param new_file_path: the full path of the new location of the file
|
|
130
|
-
:return:
|
|
131
|
-
"""
|
|
132
|
-
if self.private_key is None:
|
|
133
|
-
self.client.connect(hostname=self.host, port=self.port, username=self.username, password=self.password)
|
|
134
|
-
else:
|
|
135
|
-
self.client.connect(hostname=self.host, port=self.port, username=self.username, pkey=self.private_key)
|
|
136
|
-
sftp = self.client.open_sftp()
|
|
137
|
-
sftp.rename(oldpath=old_file_path, newpath=new_file_path)
|
|
138
|
-
self.client.close()
|
|
139
|
-
|
|
140
|
-
def rename_file(self, old_file_path: str, new_file_path: str):
|
|
141
|
-
self.move_file(old_file_path=old_file_path, new_file_path=new_file_path)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
brynq_sdk
|
|
File without changes
|
|
File without changes
|
|
File without changes
|