Skip to content

Commit 41358b1

Browse files
authored
Fix/gnupg (#120)
* Add ignore_errors=True to problematic .gnupg removal * bump version v24.51.0 -> v25.3.0 * Add conditional checks for ssh transfers to prevent attempting to attach to non-existent RemoteHandler
1 parent 9680209 commit 41358b1

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
# v25.3.0
4+
5+
- Add ignore_errors=True to problematic .gnupg removal
6+
37
# v24.51.0
48

59
- Fixing dependency checker in batches

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "opentaskpy"
7-
version = "v24.51.0"
7+
version = "v25.3.0"
88
authors = [{ name = "Adam McDonagh", email = "adam@elitemonkey.net" }]
99
license = { text = "GPLv3" }
1010
classifiers = [
@@ -71,7 +71,7 @@ otf-batch-validator = "opentaskpy.cli.batch_validator:main"
7171
profile = 'black'
7272

7373
[tool.bumpver]
74-
current_version = "v24.51.0"
74+
current_version = "v25.3.0"
7575
version_pattern = "vYY.WW.PATCH[-TAG]"
7676
commit_message = "bump version {old_version} -> {new_version}"
7777
commit = true

src/opentaskpy/remotehandlers/ssh.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -404,19 +404,21 @@ def transfer_files(
404404
destination_directory = self.get_staging_directory(remote_spec)
405405

406406
# Check that the SFTP client is connected and active
407-
dest_sftp_client = dest_remote_handler.ssh_client.open_sftp()
407+
if dest_remote_handler:
408+
dest_sftp_client = dest_remote_handler.ssh_client.open_sftp()
408409

409410
# Create/validate staging directory exists on destination
410411
# Use SFTP connection to check if the directory exists
411-
try:
412-
dest_sftp_client.stat(destination_directory)
413-
except FileNotFoundError:
414-
# Create the directory
415-
self.logger.info(
416-
f"[{dest_remote_handler.spec['hostname']}] Creating destination"
417-
f" directory {destination_directory}"
418-
)
419-
mkdir_p(dest_sftp_client, destination_directory)
412+
if dest_remote_handler:
413+
try:
414+
dest_sftp_client.stat(destination_directory)
415+
except FileNotFoundError:
416+
# Create the directory
417+
self.logger.info(
418+
f"[{dest_remote_handler.spec['hostname']}] Creating destination"
419+
f" directory {destination_directory}"
420+
)
421+
mkdir_p(dest_sftp_client, destination_directory)
420422

421423
# Sanitise arguments
422424
files = [quote(file) for file in files]

src/opentaskpy/taskhandlers/transfer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ def encrypt_files(
773773
# Remove the temporary gnupg keychain files under f"{tmpdir}/.gnupg"
774774
if path.exists(f"{tmpdir}/.gnupg"):
775775
try:
776-
shutil.rmtree(f"{tmpdir}/.gnupg")
776+
shutil.rmtree(f"{tmpdir}/.gnupg", ignore_errors=True)
777777
except FileNotFoundError as e:
778778
self.logger.warning(
779779
f".gnupg deletion failed - FileNotFound but continuing: {e}"
@@ -840,7 +840,7 @@ def decrypt_files(self, files: dict, private_key: str) -> dict:
840840
# Remove the temporary gnupg keychain files under f"{tmpdir}/.gnupg"
841841
if path.exists(f"{tmpdir}/.gnupg"):
842842
try:
843-
shutil.rmtree(f"{tmpdir}/.gnupg")
843+
shutil.rmtree(f"{tmpdir}/.gnupg", ignore_errors=True)
844844
except FileNotFoundError as e:
845845
self.logger.warning(
846846
f".gnupg deletion failed - FileNotFound but continuing: {e}"
@@ -856,7 +856,7 @@ def decrypt_files(self, files: dict, private_key: str) -> dict:
856856
# Check if the directory exists first
857857
if path.exists(f"{tmpdir}/.gnupg"):
858858
try:
859-
shutil.rmtree(f"{tmpdir}/.gnupg")
859+
shutil.rmtree(f"{tmpdir}/.gnupg", ignore_errors=True)
860860
except FileNotFoundError as e:
861861
self.logger.warning(
862862
f".gnupg deletion failed - FileNotFound but continuing: {e}"

0 commit comments

Comments
 (0)