Skip to content

Commit

Permalink
remove deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
teemukataja committed Dec 22, 2023
1 parent 0507e73 commit c27d0cd
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 51 deletions.
33 changes: 1 addition & 32 deletions sda_uploader/cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""SDA Uploader CLI."""

import sys
import secrets
import getpass
import argparse

Expand All @@ -10,7 +9,7 @@

from typing import Optional, Sequence, Tuple, Union

from crypt4gh.keys import c4gh, get_private_key, get_public_key
from crypt4gh.keys import get_private_key, get_public_key
from nacl.public import PrivateKey

from .sftp import _sftp_connection, _sftp_upload_file, _sftp_upload_directory, _sftp_client
Expand All @@ -22,36 +21,6 @@ def mock_callback(password: str) -> str:
return password


def _remove_file(filepath: str) -> None:
"""Remove temp files."""
try:
Path(filepath).unlink()
print(f"Removed temp file {filepath}")
except FileNotFoundError:
print(f"Deletion of file {filepath} failed")
pass
except PermissionError:
print(f"No permission to delete {filepath}. Please do manual cleanup.")
pass
except Exception:
print(f"Unexpected {Exception}, {type(Exception)}")
pass


def generate_one_time_key() -> Tuple:
"""Generate one time Crypt4GH encryption key."""
random_password = secrets.token_hex(16)
private_key_file = f"{getpass.getuser()}_temporary_crypt4gh.key"
public_key_file = f"{getpass.getuser()}_temporary_crypt4gh.pub"
# Remove existing temp keys if they exist
_remove_file(private_key_file)
_remove_file(public_key_file)

c4gh.generate(private_key_file, public_key_file, passphrase=str.encode(random_password))
print("One-time use encryption key generated.")
return private_key_file, public_key_file, random_password


def load_encryption_keys(
private_key_file: Union[str, Path] = "",
private_key_password: Optional[str] = None,
Expand Down
19 changes: 0 additions & 19 deletions sda_uploader/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,25 +245,6 @@ def _start_process(self) -> None:
else:
print("All fields must be filled")

def _remove_file(self, filepath: str) -> None:
"""Remove temp files."""
try:
Path(filepath).unlink()
print(f"Removed temp file {filepath}")
except FileNotFoundError:
print(f"Deletion of file {filepath} failed")
pass
except PermissionError:
print(f"No permission to delete {filepath}. Please do manual cleanup.")
pass
except Exception:
print(f"Unexpected {Exception}, {type(Exception)}")
pass

def mock_callback(self, password: str) -> str:
"""Mock callback to return password."""
return password

def write_config(self) -> None:
"""Save field values for re-runs."""
data = {
Expand Down

0 comments on commit c27d0cd

Please sign in to comment.