bbbctl 0.4__tar.gz → 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -335,10 +335,11 @@ class ApiError(RuntimeError):
|
|
|
335
335
|
|
|
336
336
|
|
|
337
337
|
class BBBApiClient:
|
|
338
|
-
def __init__(self, api, secret, ssl_context=None):
|
|
338
|
+
def __init__(self, api, secret, ssl_context=None, debug=0):
|
|
339
339
|
self.api = api.rstrip("/")
|
|
340
340
|
self.secret = secret
|
|
341
341
|
self.ssl = ssl_context or ssl.create_default_context()
|
|
342
|
+
self.debug = max(0, debug)
|
|
342
343
|
|
|
343
344
|
def makeurl(self, command, **query):
|
|
344
345
|
query = urllib.parse.urlencode(
|
|
@@ -354,8 +355,13 @@ class BBBApiClient:
|
|
|
354
355
|
|
|
355
356
|
def call(self, command, **query):
|
|
356
357
|
url = self.makeurl(command, **query)
|
|
358
|
+
if self.debug:
|
|
359
|
+
print(f">>> {url}", file=sys.stderr)
|
|
357
360
|
with urllib.request.urlopen(url, context=self.ssl) as f:
|
|
358
361
|
xml = f.read().decode("utf8")
|
|
362
|
+
if self.debug >= 2:
|
|
363
|
+
for line in xml:
|
|
364
|
+
print(f"<<< {line}", file=sys.stderr)
|
|
359
365
|
root = ET.fromstring(xml)
|
|
360
366
|
if (status := root.find("./returncode")) is None or status.text != "SUCCESS":
|
|
361
367
|
raise ApiError(root)
|
|
@@ -418,6 +424,12 @@ def build_parser():
|
|
|
418
424
|
help="Skip TLS verification and accept self-signed or expired SSL certificates",
|
|
419
425
|
action="store_true",
|
|
420
426
|
)
|
|
427
|
+
parser.add_argument(
|
|
428
|
+
"-v",
|
|
429
|
+
"--debug",
|
|
430
|
+
help="Print alls API calls. Repeat to also print all API responses.",
|
|
431
|
+
action="count",
|
|
432
|
+
)
|
|
421
433
|
|
|
422
434
|
formats = ["human", "compact", "xml", "json", "jsonline"]
|
|
423
435
|
parser.add_argument(
|
|
@@ -643,7 +655,7 @@ def main():
|
|
|
643
655
|
ctx.check_hostname = False
|
|
644
656
|
ctx.verify_mode = ssl.CERT_NONE
|
|
645
657
|
|
|
646
|
-
client = BBBApiClient(server, secret, ssl_context=ctx)
|
|
658
|
+
client = BBBApiClient(server, secret, ssl_context=ctx, debug=args.debug)
|
|
647
659
|
|
|
648
660
|
try:
|
|
649
661
|
args.cmd(client, args)
|
|
File without changes
|
|
File without changes
|