Skip to content
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

Interactive prompt for existing exploits #11

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions ataka/player-cli/player_cli/exploit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,18 @@ def exploit_download(
print(f'{ERROR_STR}: unsafe archive: link detected')
raise typer.Exit(code=1)

try:
os.mkdir(path)
except FileExistsError:
if overwrite:
print(f'{WARN_STR}: directory "{path}" already exists (proceeding anyway)')
else:
print(f'{ERROR_STR}: directory "{path}" already exists (use --overwrite to proceed anyway)')
# Check if the directory already exists and ask the user if
# overwriting is fine if overwrite is not explicitly specified
if os.path.exists(path) and not overwrite:
confirm_str = f'{ERROR_STR}: directory "{path}" already exists, do you want to overwrite it?'

overwrite_answer = Confirm.ask(confirm_str)
if not overwrite_answer:
raise typer.Exit(code=1)

# Recursivly create directories, not raising FileExistsError on
# existing directories(overwrite-case)
os.makedirs(path, exist_ok=True)
tar.extractall(path)


Expand Down