Skip to content

Commit e776933

Browse files
authored
Merge pull request #216 from OP-TED/feature/TED-640
remove try catch
2 parents f6982c2 + 15f28b0 commit e776933

2 files changed

Lines changed: 17 additions & 25 deletions

File tree

ted_sws/notice_fetcher/adapters/ted_api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ def get_by_query(self, query: dict) -> List[dict]:
9696
documents_content += response_body[RESPONSE_RESULTS]
9797
decoded_documents_content = []
9898
for document_content in documents_content:
99-
document_content[DOCUMENT_CONTENT] = base64.b64decode(document_content[DOCUMENT_CONTENT]).decode(encoding="utf-8")
99+
document_content[DOCUMENT_CONTENT] = base64.b64decode(document_content[DOCUMENT_CONTENT]).decode(
100+
encoding="utf-8")
100101
decoded_documents_content.append(document_content)
101102

102103
return decoded_documents_content

ted_sws/notice_publisher/adapters/sftp_notice_publisher.py

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,17 @@ def __init__(self, hostname=default_host, username=default_user, password=defaul
2727
def connect(self):
2828
"""Connects to the sftp server and returns the sftp connection object"""
2929

30-
try:
31-
cnopts = pysftp.CnOpts()
32-
# TODO: to be checked/removed when SSL will be setup
33-
cnopts.hostkeys = None
34-
# Get the sftp connection object
35-
self.connection = pysftp.Connection(
36-
host=self.hostname,
37-
username=self.username,
38-
password=self.password,
39-
port=self.port,
40-
cnopts=cnopts
41-
)
42-
except Exception as err:
43-
raise Exception(err)
30+
cnopts = pysftp.CnOpts()
31+
# TODO: to be checked/removed when SSL will be setup
32+
cnopts.hostkeys = None
33+
# Get the sftp connection object
34+
self.connection = pysftp.Connection(
35+
host=self.hostname,
36+
username=self.username,
37+
password=self.password,
38+
port=self.port,
39+
cnopts=cnopts
40+
)
4441

4542
self.is_connected = True
4643

@@ -57,18 +54,12 @@ def publish(self, source_path, remote_path) -> bool:
5754
"""
5855
Publish file_content to the sftp server remote path.
5956
"""
60-
try:
61-
self.connection.put(source_path, remote_path)
62-
return True
63-
except Exception as err:
64-
raise Exception(err)
57+
self.connection.put(source_path, remote_path)
58+
return True
6559

6660
def remove(self, remote_path) -> bool:
6761
"""
6862
6963
"""
70-
try:
71-
self.connection.unlink(remote_path)
72-
return True
73-
except Exception as err:
74-
raise Exception(err)
64+
self.connection.unlink(remote_path)
65+
return True

0 commit comments

Comments
 (0)