Skip to content

Commit 5ac8cfd

Browse files
committed
combining print and sys.exit statements
1 parent 6591ef3 commit 5ac8cfd

File tree

7 files changed

+9
-18
lines changed

7 files changed

+9
-18
lines changed

piccolo/apps/app/commands/new.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ def new_app(app_name: str, root: str = "."):
2222
app_root = os.path.join(root, app_name)
2323

2424
if os.path.exists(app_root):
25-
print("Folder already exists - exiting.")
26-
sys.exit(1)
25+
sys.exit("Folder already exists - exiting.")
2726
os.mkdir(app_root)
2827

2928
with open(os.path.join(app_root, "__init__.py"), "w"):

piccolo/apps/migrations/commands/new.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ def _create_new_migration(app_config: AppConfig, auto=False) -> None:
7575
)
7676

7777
if sum([len(i.statements) for i in alter_statements]) == 0:
78-
print("No changes detected - exiting.")
79-
sys.exit(1)
78+
sys.exit("No changes detected - exiting.")
8079

8180
file_contents = render_template(
8281
migration_id=_id,
@@ -151,8 +150,7 @@ def new(app_name: str, auto: bool = False):
151150

152151
engine = Finder().get_engine()
153152
if auto and isinstance(engine, SQLiteEngine):
154-
print("Auto migrations aren't currently supported by SQLite.")
155-
sys.exit(1)
153+
sys.exit("Auto migrations aren't currently supported by SQLite.")
156154

157155
app_config = Finder().get_app_config(app_name=app_name)
158156

piccolo/apps/playground/commands/run.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,9 @@ def run(
131131
try:
132132
import IPython # type: ignore
133133
except ImportError:
134-
print(
134+
sys.exit(
135135
"Install iPython using `pip install ipython` to use this feature."
136136
)
137-
sys.exit(1)
138137

139138
if engine.upper() == "POSTGRES":
140139
db: Engine = PostgresEngine(

piccolo/apps/project/commands/new.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ def new_piccolo_conf(engine_name: str, force: bool = False, root: str = "."):
2323
file_path = os.path.join(root, "piccolo_conf.py")
2424

2525
if os.path.exists(file_path) and not force:
26-
print("The file already exists - exiting.")
27-
sys.exit(1)
26+
sys.exit("The file already exists - exiting.")
2827

2928
with open(file_path, "w") as f:
3029
template = JINJA_ENV.get_template("piccolo_conf.py.jinja")

piccolo/apps/shell/commands/run.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ def start_ipython_shell(
1717
**tables: t.Dict[str, t.Type[Table]]
1818
): # pragma: no cover
1919
if not IPYTHON:
20-
print(
20+
sys.exit(
2121
"Install iPython using `pip install ipython` to use this feature."
2222
)
23-
sys.exit(1)
2423

2524
existing_global_names = globals().keys()
2625
for table_class_name, table_class in tables.items():

piccolo/apps/user/commands/change_password.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ def change_password():
1717
confirmed_password = get_confirmed_password()
1818

1919
if not password == confirmed_password:
20-
print("Passwords don't match!")
21-
sys.exit(1)
20+
sys.exit("Passwords don't match!")
2221

2322
BaseUser.update_password_sync(user=username, password=password)
2423

piccolo/apps/user/commands/create.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,10 @@ def create():
4343
confirmed_password = get_confirmed_password()
4444

4545
if not password == confirmed_password:
46-
print("Passwords don't match!")
47-
sys.exit(1)
46+
sys.exit("Passwords don't match!")
4847

4948
if len(password) < 4:
50-
print("The password is too short")
51-
sys.exit(1)
49+
sys.exit("The password is too short")
5250

5351
is_admin = get_is_admin()
5452

0 commit comments

Comments
 (0)