Browse Source

Change usage of exit() to sys.exit()

sys.exit() is the correct way to terminate.

It is recommended to not use exit() in programs[1]:
    The site module (which is imported automatically during startup,
    except if the -S command-line option is given) adds several
    constants to the built-in namespace. They are useful for the
    interactive interpreter shell and should not be used in programs.

[1] https://docs.python.org/3/library/constants.html#exit

Change-Id: I4bfeba2f351c51a4da2e283ee44e10b76f863ff6
John L. Villalovos 1 year ago
parent
commit
a9d6de3ed5
1 changed files with 3 additions and 2 deletions
  1. 3
    2
      gertty/config.py

+ 3
- 2
gertty/config.py View File

@@ -17,6 +17,7 @@ import collections
17 17
 import getpass
18 18
 import os
19 19
 import re
20
+import sys
20 21
 try:
21 22
     import ordereddict
22 23
 except:
@@ -137,7 +138,7 @@ class Config(object):
137 138
 
138 139
         if not os.path.exists(self.path):
139 140
             self.printSample()
140
-            exit(1)
141
+            sys.exit(1)
141 142
 
142 143
         self.config = yaml.load(open(self.path))
143 144
         schema = ConfigSchema().getSchema(self.config)
@@ -164,7 +165,7 @@ class Config(object):
164 165
                     "Error: Config file '{}' contains a password and does "
165 166
                     "not have permissions set to 0600.\n"
166 167
                     "Permissions are: {}".format(self.path, oct(mode)))
167
-                exit(1)
168
+                sys.exit(1)
168 169
         self.auth_type = server.get('auth-type', 'digest')
169 170
         self.verify_ssl = server.get('verify-ssl', True)
170 171
         if not self.verify_ssl:

Loading…
Cancel
Save