diff options
author | Amjith Ramanujam <amjith@netflix.com> | 2021-01-16 08:13:55 -0800 |
---|---|---|
committer | Amjith Ramanujam <amjith@netflix.com> | 2021-01-16 08:13:55 -0800 |
commit | 042ddade88ebc38a3ec529ca24335899b6a6809b (patch) | |
tree | d049d2de2e6a549e370693a05e8e6c845a65912a | |
parent | 609c3ec5c868a7273530d6d7a076273abe652ce8 (diff) |
Coerce port to int.
-rwxr-xr-x | mycli/main.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/mycli/main.py b/mycli/main.py index 7c3c3d6..32718db 100755 --- a/mycli/main.py +++ b/mycli/main.py @@ -397,7 +397,11 @@ class MyCli(object): socket = socket or cnf['socket'] or guess_socket_location() user = user or cnf['user'] or os.getenv('USER') host = host or cnf['host'] - port = port or cnf['port'] + try: + port = port or int(cnf['port']) + except ValueError as e: + self.echo("Error: Invalid port number: '{0}'.".format(cnf['port']), + err=True, fg='red') ssl = ssl or {} passwd = passwd if isinstance(passwd, str) else cnf['password'] |