aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Helmert III <ajak@gentoo.org>2021-07-05 13:38:38 -0500
committerJohn Helmert III <ajak@gentoo.org>2021-07-05 13:38:38 -0500
commitabe128db3bf0ede3f813de854ccee897941638f1 (patch)
treebf72c742f46aba65bb6b8ba9d7a233c858a9ecbf
parentcvetool: avoid referencing sys.argv in CVETool constructor (diff)
downloadsecurity-abe128db.tar.gz
security-abe128db.tar.bz2
security-abe128db.zip
bin/: split CVETool class into own file
...and rename cvetool.py back to cvetool Signed-off-by: John Helmert III <ajak@gentoo.org>
-rw-r--r--[-rwxr-xr-x]bin/CVETool.py (renamed from bin/cvetool.py)33
-rwxr-xr-xbin/cvetool33
2 files changed, 35 insertions, 31 deletions
diff --git a/bin/cvetool.py b/bin/CVETool.py
index 557c030..c5996f6 100755..100644
--- a/bin/cvetool.py
+++ b/bin/CVETool.py
@@ -1,12 +1,8 @@
-#!/usr/bin/env python3
-# Copyright 2016 Alex Legler
-# Distributed under the terms of the GNU General Public License v3
-
import re
import sys
-import os
-from urllib.parse import urlencode
+
from base64 import b64encode
+from urllib.parse import urlencode
import requests
GLSAMAKER_URI = 'https://glsamaker.gentoo.org'
@@ -244,28 +240,3 @@ class CVETool:
if jsondata:
return response.json()
return response.text
-
-
-def main():
- if len(sys.argv) == 1:
- CVETool(None, 'usage', sys.argv[2:])
-
- auth = None
- authpath = os.path.join(os.path.expanduser('~'), '.config', 'cvetool_auth')
- if 'CVETOOL_AUTH' in os.environ:
- auth = os.environ['CVETOOL_AUTH']
- elif os.path.isfile(authpath):
- with open(authpath, 'r') as authfile:
- auth = authfile.readlines()[0]
- elif 'CVETOOL_AUTH' not in os.environ and not sys.argv[1] == 'pw':
- print('CVETOOL_AUTH environment variable missing. Generate its contents with the pw subcommand.')
- sys.exit(1)
-
- CVETool(auth, sys.argv[1], sys.argv[2:])
-
-
-if __name__ == "__main__":
- try:
- main()
- except KeyboardInterrupt:
- print('\n ! Exiting.')
diff --git a/bin/cvetool b/bin/cvetool
new file mode 100755
index 0000000..7e30837
--- /dev/null
+++ b/bin/cvetool
@@ -0,0 +1,33 @@
+#!/usr/bin/env python3
+# Copyright 2016 Alex Legler
+# Distributed under the terms of the GNU General Public License v3
+
+import os
+import re
+import sys
+
+from CVETool import CVETool
+
+def main():
+ if len(sys.argv) == 1:
+ CVETool(None, 'usage', sys.argv[2:])
+
+ auth = None
+ authpath = os.path.join(os.path.expanduser('~'), '.config', 'cvetool_auth')
+ if 'CVETOOL_AUTH' in os.environ:
+ auth = os.environ['CVETOOL_AUTH']
+ elif os.path.isfile(authpath):
+ with open(authpath, 'r') as authfile:
+ auth = authfile.readlines()[0]
+ elif 'CVETOOL_AUTH' not in os.environ and not sys.argv[1] == 'pw':
+ print('CVETOOL_AUTH environment variable missing. Generate its contents with the pw subcommand.')
+ sys.exit(1)
+
+ CVETool(auth, sys.argv[1], sys.argv[2:])
+
+
+if __name__ == "__main__":
+ try:
+ main()
+ except KeyboardInterrupt:
+ print('\n ! Exiting.')