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

[CPDEV-98931] Avoid interactive constants (exit) from site module #614

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
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
15 changes: 8 additions & 7 deletions kubemarine/procedures/migrate_kubemarine.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.
import argparse
import re
import sys
from abc import ABC, abstractmethod
from textwrap import dedent
from typing import List, Union
Expand Down Expand Up @@ -454,32 +455,32 @@ def run(context: dict) -> None:
print(patch_id)
else:
print("No patches available.")
exit(0)
sys.exit(0)

if args['describe']:
for patch in patches:
if patch.identifier == args['describe']:
print(patch.description)
exit(0)
sys.exit(0)
print(f"Unknown patch '{args['describe']}'")
exit(1)
sys.exit(1)

skip = [] if not args['skip'] else args['skip'].split(",")
apply = [] if not args['apply'] else args['apply'].split(",")

if apply and (set(apply) - set(patch_ids)):
print(f"Unknown patches {list(set(apply) - set(patch_ids))}")
exit(1)
sys.exit(1)

if skip and (set(skip) - set(patch_ids)):
print(f"Unknown patches {list(set(skip) - set(patch_ids))}")
exit(1)
sys.exit(1)

if apply:
positions = [patch_ids.index(apply_id) for apply_id in apply]
if not all(positions[i] < positions[i + 1] for i in range(len(positions) - 1)):
print("Incorrect order of patches to apply. See --list for correct order of patches.")
exit(1)
sys.exit(1)

actions = []
for patch in patches:
Expand All @@ -494,7 +495,7 @@ def run(context: dict) -> None:

if not actions:
print("No patches to apply")
exit(0)
sys.exit(0)

flow.ActionsFlow(actions).run_flow(context)

Expand Down
4 changes: 2 additions & 2 deletions kubemarine/resources/scripts/check_url_availability.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
status_code = urllib.urlopen(source, timeout=timeout).getcode()
if status_code != 200:
sys.stderr.write("Error status code: %s" % status_code)
exit(1)
sys.exit(1)
except Exception as e:
sys.stderr.write(str(e))
exit(1)
sys.exit(1)
2 changes: 1 addition & 1 deletion kubemarine/resources/scripts/simple_port_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@
if action == 'send' and len(data) != sz:
sys.stdout.write("Data is lost\n")
sys.stdout.flush()
exit(1)
sys.exit(1)
2 changes: 1 addition & 1 deletion kubemarine/resources/scripts/simple_port_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
if "Address already in use" in str(e):
sys.stdout.write("In use\n")
sys.stdout.flush()
exit(1)
sys.exit(1)
else:
raise

Expand Down
2 changes: 1 addition & 1 deletion scripts/ci/build_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
def call(args: List[str]) -> None:
return_code = subprocess.call(args)
if return_code != 0:
exit(return_code)
sys.exit(return_code)

# Copy ipip_check from package
with open('kubemarine/version', 'r') as version_file:
Expand Down
Loading