Dolda2000 GitWeb
/
utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
62b251c
)
acmecert: Make error reporting more flexible.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Fri, 12 Nov 2021 17:30:57 +0000
(18:30 +0100)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Fri, 12 Nov 2021 17:30:57 +0000
(18:30 +0100)
acmecert
patch
|
blob
|
blame
|
history
diff --git
a/acmecert
b/acmecert
index
0ba66e2
..
f6f60e2
100755
(executable)
--- a/
acmecert
+++ b/
acmecert
@@
-1,9
+1,13
@@
#!/usr/bin/python3
#!/usr/bin/python3
-import sys, os, getopt, binascii, json, pprint, signal, time
+import sys, os, getopt, binascii, json, pprint, signal, time
, threading
import urllib.request
import Crypto.PublicKey.RSA, Crypto.Random, Crypto.Hash.SHA256, Crypto.Signature.PKCS1_v1_5
import urllib.request
import Crypto.PublicKey.RSA, Crypto.Random, Crypto.Hash.SHA256, Crypto.Signature.PKCS1_v1_5
+class msgerror(Exception):
+ def report(self, out):
+ out.write("acmecert: undefined error\n")
+
service = "https://acme-v02.api.letsencrypt.org/directory"
_directory = None
def directory():
service = "https://acme-v02.api.letsencrypt.org/directory"
_directory = None
def directory():
@@
-308,11
+312,16
@@
class maybeopen(object):
self.fp.close()
return False
self.fp.close()
return False
-class usageerr(Exception):
- pass
-
+invdata = threading.local()
commands = {}
commands = {}
+class usageerr(msgerror):
+ def __init__(self):
+ self.cmd = invdata.cmd
+
+ def report(self, out):
+ out.write("%s\n" % (self.cmd.__doc__,))
+
def cmd_reg(args):
"usage: acmecert reg [OUTPUT-FILE]"
acct = register()
def cmd_reg(args):
"usage: acmecert reg [OUTPUT-FILE]"
acct = register()
@@
-447,9
+456,13
@@
def main(argv):
usage(sys.stderr)
sys.exit(1)
try:
usage(sys.stderr)
sys.exit(1)
try:
- cmd(args)
- except usageerr:
- sys.stderr.write("%s\n" % (cmd.__doc__,))
+ try:
+ invdata.cmd = cmd
+ cmd(args)
+ finally:
+ invdata.cmd = None
+ except msgerror as exc:
+ exc.report(sys.stderr)
sys.exit(1)
if __name__ == "__main__":
sys.exit(1)
if __name__ == "__main__":