-
-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor/design pattern #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
add command, facade patterns
chore: pyproject.toml
|
@CodiumAI-Agent /improve --pr_code_suggestions.commitable_code_suggestions=true |
| # HACK: Use ContextManager class to pass _password_context and _safe_cleanup methods | ||
| # TODO: Is there a better way to handle this? | ||
| # NOTE: Python’s garbage collector or internal caching might still have copies elsewhere?? | ||
| # TODO: mmap or mlock, cryptography, ctypes, or C extension for better memory handling | ||
| class ContextManager: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Initialize a logger in the ContextManager to prevent attribute errors in _password_context. [possible issue, importance: 8]
| # HACK: Use ContextManager class to pass _password_context and _safe_cleanup methods | |
| # TODO: Is there a better way to handle this? | |
| # NOTE: Python’s garbage collector or internal caching might still have copies elsewhere?? | |
| # TODO: mmap or mlock, cryptography, ctypes, or C extension for better memory handling | |
| class ContextManager: | |
| class ContextManager: | |
| def __init__(self): | |
| self.logger = logging.getLogger(__name__) | |
| @contextmanager | |
| def _password_context(self): | |
| try: | |
| password = getpass.getpass("Enter file encryption password: ") | |
| if not password: | |
| self.logger.error("Empty password rejected") | |
| yield None | |
| return | |
| password_bytes = bytearray(password.encode("utf-8")) | |
| yield password_bytes.decode("utf-8") | |
| finally: | |
| if "password_bytes" in locals(): | |
| for i in range(len(password_bytes)): | |
| password_bytes[i] = 0 | |
| password_bytes = None | |
| del password_bytes |
src/backup_manager.py
Outdated
| def _show_spinner(self): | ||
| spinner = itertools.cycle(["/", "-", "\\", "|"]) | ||
| start_time = time.time() | ||
|
|
||
| def run_spinner(): | ||
| while not hasattr(self, "process_complete"): | ||
| sys.stdout.write(next(spinner) + " ") | ||
| sys.stdout.flush() | ||
| sys.stdout.write("\b\b") | ||
| time.sleep(0.1) | ||
|
|
||
| spinner_thread = threading.Thread(target=run_spinner) | ||
| spinner_thread.start() | ||
|
|
||
| # Simulated process - replace with actual process monitoring | ||
| try: | ||
| subprocess.run(cmd, shell=True, check=True) | ||
| finally: | ||
| self.process_complete = True | ||
| spinner_thread.join() | ||
| sys.stdout.write("\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Refactor the spinner in BackupCommand to remove the duplicate subprocess.run call and resolve the undefined variable "cmd". [possible issue, importance: 8]
| def _show_spinner(self): | |
| spinner = itertools.cycle(["/", "-", "\\", "|"]) | |
| start_time = time.time() | |
| def run_spinner(): | |
| while not hasattr(self, "process_complete"): | |
| sys.stdout.write(next(spinner) + " ") | |
| sys.stdout.flush() | |
| sys.stdout.write("\b\b") | |
| time.sleep(0.1) | |
| spinner_thread = threading.Thread(target=run_spinner) | |
| spinner_thread.start() | |
| # Simulated process - replace with actual process monitoring | |
| try: | |
| subprocess.run(cmd, shell=True, check=True) | |
| finally: | |
| self.process_complete = True | |
| spinner_thread.join() | |
| sys.stdout.write("\n") | |
| def _show_spinner(self, process): | |
| spinner = itertools.cycle(["/", "-", "\\", "|"]) | |
| while process.poll() is None: | |
| sys.stdout.write(next(spinner) + " ") | |
| sys.stdout.flush() | |
| sys.stdout.write("\b\b") | |
| time.sleep(0.1) |
refactor calculation class and outputs
- add github action for releases - add copilot instructions for python
# BREAKING CHANGES: Current config file location moved to `~/.config/autotarcompress/config.json`. Please review example config file and update it for your needs. - Update example config file paths to reflect new structure. - Enhance BackupConfig class to include config verification and improved documentation.
add command, facade patterns
increase security on openssl command