Gentoo Archives: gentoo-commits

From: John Helmert III <ajak@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/security:ajak-cvetool commit in: bin/
Date: Mon, 05 Jul 2021 20:24:20
Message-Id: 1625510318.abe128db3bf0ede3f813de854ccee897941638f1.ajak@gentoo
1 commit: abe128db3bf0ede3f813de854ccee897941638f1
2 Author: John Helmert III <ajak <AT> gentoo <DOT> org>
3 AuthorDate: Mon Jul 5 18:38:38 2021 +0000
4 Commit: John Helmert III <ajak <AT> gentoo <DOT> org>
5 CommitDate: Mon Jul 5 18:38:38 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/security.git/commit/?id=abe128db
7
8 bin/: split CVETool class into own file
9
10 ...and rename cvetool.py back to cvetool
11
12 Signed-off-by: John Helmert III <ajak <AT> gentoo.org>
13
14 bin/{cvetool.py => CVETool.py} | 33 ++-------------------------------
15 bin/cvetool | 33 +++++++++++++++++++++++++++++++++
16 2 files changed, 35 insertions(+), 31 deletions(-)
17
18 diff --git a/bin/cvetool.py b/bin/CVETool.py
19 old mode 100755
20 new mode 100644
21 similarity index 90%
22 rename from bin/cvetool.py
23 rename to bin/CVETool.py
24 index 557c030..c5996f6
25 --- a/bin/cvetool.py
26 +++ b/bin/CVETool.py
27 @@ -1,12 +1,8 @@
28 -#!/usr/bin/env python3
29 -# Copyright 2016 Alex Legler
30 -# Distributed under the terms of the GNU General Public License v3
31 -
32 import re
33 import sys
34 -import os
35 -from urllib.parse import urlencode
36 +
37 from base64 import b64encode
38 +from urllib.parse import urlencode
39 import requests
40
41 GLSAMAKER_URI = 'https://glsamaker.gentoo.org'
42 @@ -244,28 +240,3 @@ class CVETool:
43 if jsondata:
44 return response.json()
45 return response.text
46 -
47 -
48 -def main():
49 - if len(sys.argv) == 1:
50 - CVETool(None, 'usage', sys.argv[2:])
51 -
52 - auth = None
53 - authpath = os.path.join(os.path.expanduser('~'), '.config', 'cvetool_auth')
54 - if 'CVETOOL_AUTH' in os.environ:
55 - auth = os.environ['CVETOOL_AUTH']
56 - elif os.path.isfile(authpath):
57 - with open(authpath, 'r') as authfile:
58 - auth = authfile.readlines()[0]
59 - elif 'CVETOOL_AUTH' not in os.environ and not sys.argv[1] == 'pw':
60 - print('CVETOOL_AUTH environment variable missing. Generate its contents with the pw subcommand.')
61 - sys.exit(1)
62 -
63 - CVETool(auth, sys.argv[1], sys.argv[2:])
64 -
65 -
66 -if __name__ == "__main__":
67 - try:
68 - main()
69 - except KeyboardInterrupt:
70 - print('\n ! Exiting.')
71
72 diff --git a/bin/cvetool b/bin/cvetool
73 new file mode 100755
74 index 0000000..7e30837
75 --- /dev/null
76 +++ b/bin/cvetool
77 @@ -0,0 +1,33 @@
78 +#!/usr/bin/env python3
79 +# Copyright 2016 Alex Legler
80 +# Distributed under the terms of the GNU General Public License v3
81 +
82 +import os
83 +import re
84 +import sys
85 +
86 +from CVETool import CVETool
87 +
88 +def main():
89 + if len(sys.argv) == 1:
90 + CVETool(None, 'usage', sys.argv[2:])
91 +
92 + auth = None
93 + authpath = os.path.join(os.path.expanduser('~'), '.config', 'cvetool_auth')
94 + if 'CVETOOL_AUTH' in os.environ:
95 + auth = os.environ['CVETOOL_AUTH']
96 + elif os.path.isfile(authpath):
97 + with open(authpath, 'r') as authfile:
98 + auth = authfile.readlines()[0]
99 + elif 'CVETOOL_AUTH' not in os.environ and not sys.argv[1] == 'pw':
100 + print('CVETOOL_AUTH environment variable missing. Generate its contents with the pw subcommand.')
101 + sys.exit(1)
102 +
103 + CVETool(auth, sys.argv[1], sys.argv[2:])
104 +
105 +
106 +if __name__ == "__main__":
107 + try:
108 + main()
109 + except KeyboardInterrupt:
110 + print('\n ! Exiting.')