Skip to content

Commit 284eb7e

Browse files
authored
Merge pull request #1187 from fcwys/main
Unified 'exit' as 'sys.exit' in the code to improve cross platform co…
2 parents 8d3dbf3 + 7159cd1 commit 284eb7e

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

mycli/main.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -524,14 +524,14 @@ def _connect():
524524
port = int(port)
525525
except ValueError:
526526
self.echo("Error: Invalid port number: '{0}'.".format(port), err=True, fg="red")
527-
exit(1)
527+
sys.exit(1)
528528

529529
_connect()
530530
except Exception as e: # Connecting to a database could fail.
531531
self.logger.debug("Database connection failed: %r.", e)
532532
self.logger.error("traceback: %r", traceback.format_exc())
533533
self.echo(str(e), err=True, fg="red")
534-
exit(1)
534+
sys.exit(1)
535535

536536
def get_password_from_file(self, password_file):
537537
password_from_file = None
@@ -1224,10 +1224,10 @@ def cli(
12241224
alias_dsn = mycli.config["alias_dsn"]
12251225
except KeyError:
12261226
click.secho("Invalid DSNs found in the config file. " 'Please check the "[alias_dsn]" section in myclirc.', err=True, fg="red")
1227-
exit(1)
1227+
sys.exit(1)
12281228
except Exception as e:
12291229
click.secho(str(e), err=True, fg="red")
1230-
exit(1)
1230+
sys.exit(1)
12311231
for alias, value in alias_dsn.items():
12321232
if verbose:
12331233
click.secho("{} : {}".format(alias, value))
@@ -1279,7 +1279,7 @@ def cli(
12791279
err=True,
12801280
fg="red",
12811281
)
1282-
exit(1)
1282+
sys.exit(1)
12831283
else:
12841284
mycli.dsn_alias = dsn
12851285

@@ -1342,10 +1342,10 @@ def cli(
13421342
mycli.formatter.format_name = "tsv"
13431343

13441344
mycli.run_query(execute)
1345-
exit(0)
1345+
sys.exit(0)
13461346
except Exception as e:
13471347
click.secho(str(e), err=True, fg="red")
1348-
exit(1)
1348+
sys.exit(1)
13491349

13501350
if sys.stdin.isatty():
13511351
mycli.run_cli()
@@ -1357,7 +1357,7 @@ def cli(
13571357
click.secho("Failed! Ran out of memory.", err=True, fg="red")
13581358
click.secho("You might want to try the official mysql client.", err=True, fg="red")
13591359
click.secho("Sorry... :(", err=True, fg="red")
1360-
exit(1)
1360+
sys.exit(1)
13611361

13621362
if mycli.destructive_warning and is_destructive(stdin_text):
13631363
try:
@@ -1366,7 +1366,7 @@ def cli(
13661366
except (IOError, OSError):
13671367
mycli.logger.warning("Unable to open TTY as stdin.")
13681368
if not warn_confirmed:
1369-
exit(0)
1369+
sys.exit(0)
13701370

13711371
try:
13721372
new_line = True
@@ -1377,10 +1377,10 @@ def cli(
13771377
mycli.formatter.format_name = "tsv"
13781378

13791379
mycli.run_query(stdin_text, new_line=new_line)
1380-
exit(0)
1380+
sys.exit(0)
13811381
except Exception as e:
13821382
click.secho(str(e), err=True, fg="red")
1383-
exit(1)
1383+
sys.exit(1)
13841384

13851385

13861386
def need_completion_refresh(queries):

0 commit comments

Comments
 (0)