Commit 84322632 authored by David Huss's avatar David Huss 💬
Browse files

Make --sum compatible with -2 --fancy

parent 9edb99bb
__version__ = '0.1.29' __version__ = '0.1.30'
...@@ -53,7 +53,7 @@ def main(userconfig, watch, version): ...@@ -53,7 +53,7 @@ def main(userconfig, watch, version):
Internally bbbmon relies on the offical bbb-API, which means you need to have the server's secret in order to create a valid request. Create a new configuration with: bbbmon config --new Internally bbbmon relies on the offical bbb-API, which means you need to have the server's secret in order to create a valid request. Create a new configuration with: bbbmon config --new
""" """
__version__ = "0.1.29" __version__ = "0.1.30"
if version: if version:
print(__version__) print(__version__)
......
...@@ -31,7 +31,7 @@ def generate_checksum(call_name: str, query_string: str, secret: Secret) -> str: ...@@ -31,7 +31,7 @@ def generate_checksum(call_name: str, query_string: str, secret: Secret) -> str:
return m.hexdigest() return m.hexdigest()
def request_meetings(secret: Secret, bbb_url: Url, user_config_path: str) -> XmlDictConfig: def request_meetings(secret: Secret, bbb_url: Url, user_config_path: str, sum_: bool) -> XmlDictConfig:
""" """
Make a getMeetings-API Call to the bbb instance and return a XmlDictConfig Make a getMeetings-API Call to the bbb instance and return a XmlDictConfig
with the servers response with the servers response
...@@ -52,9 +52,10 @@ def request_meetings(secret: Secret, bbb_url: Url, user_config_path: str) -> Xml ...@@ -52,9 +52,10 @@ def request_meetings(secret: Secret, bbb_url: Url, user_config_path: str) -> Xml
try: try:
root = ElementTree.XML(r.text) root = ElementTree.XML(r.text)
except ElementTree.ParseError as e: except ElementTree.ParseError as e:
click.echo("{} The XML returned from {} couldn't be properly parsed. The response text from the Server was:\n{}".format(click.style('Error:', fg='red', bold=True), url, r.text)) if not sum_:
print("Exiting...") click.echo("{} The XML returned from {} couldn't be properly parsed. The response text from the Server was:\n{}".format(click.style('Error:', fg='red', bold=True), url, r.text))
exit() print("Exiting...")
exit()
xmldict = XmlDictConfig(root) xmldict = XmlDictConfig(root)
if "returncode" in xmldict.keys(): if "returncode" in xmldict.keys():
...@@ -68,13 +69,13 @@ def request_meetings(secret: Secret, bbb_url: Url, user_config_path: str) -> Xml ...@@ -68,13 +69,13 @@ def request_meetings(secret: Secret, bbb_url: Url, user_config_path: str) -> Xml
def get_meetings(secret: Secret, bbb_url: Url, user_config_path: str) -> Iterable[XmlDictConfig]: def get_meetings(secret: Secret, bbb_url: Url, user_config_path: str, sum_: bool) -> Iterable[XmlDictConfig]:
""" """
Request meetings and return a list of them. Sorted by biggest first Request meetings and return a list of them. Sorted by biggest first
""" """
meetings = [] meetings = []
try: try:
d = request_meetings(secret, bbb_url, user_config_path) d = request_meetings(secret, bbb_url, user_config_path, sum_)
except: except:
return ["unreachable"] return ["unreachable"]
...@@ -123,7 +124,7 @@ def list_meetings(config: Config, leaderboards: bool, n: int, participants: bool ...@@ -123,7 +124,7 @@ def list_meetings(config: Config, leaderboards: bool, n: int, participants: bool
""" """
# Request Meetings from API # Request Meetings from API
meetings = [get_meetings(e.secret, e.url, config.path) for e in config.endpoints] meetings = [get_meetings(e.secret, e.url, config.path, sum_) for e in config.endpoints]
# Collate all meetings from all endpoints together for --sum flag # Collate all meetings from all endpoints together for --sum flag
if sum_: if sum_:
...@@ -249,12 +250,15 @@ def meetings_twolines(config: Config, watch: int, fancy: bool, sum_:bool): ...@@ -249,12 +250,15 @@ def meetings_twolines(config: Config, watch: int, fancy: bool, sum_:bool):
""" """
# Request Meetings from API # Request Meetings from API
meetings = [get_meetings(e.secret, e.url, config.path) for e in config.endpoints] meetings = [get_meetings(e.secret, e.url, config.path, sum_) for e in config.endpoints]
# Collate meetings from all endpoints together in sum mode # Collate meetings from all endpoints together in sum mode
if sum_: if sum_:
config, meetings = sum_meetings(config, meetings) config, meetings = sum_meetings(config, meetings)
if sum_ and fancy:
config.endpoints[0].name = "bbb"
# Clear screen after request is done, and before printing new data to keep # Clear screen after request is done, and before printing new data to keep
# blinking to a minimum # blinking to a minimum
if watch is not None: if watch is not None:
......
[tool.poetry] [tool.poetry]
name = "bbbmon" name = "bbbmon"
version = "0.1.29" version = "0.1.30"
description = "A small CLI utility to monitor bbb usage" description = "A small CLI utility to monitor bbb usage"
authors = ["David Huss <david.huss@hfbk-hamburg.de>"] authors = ["David Huss <david.huss@hfbk-hamburg.de>"]
maintainers = ["David Huss <david.huss@hfbk-hamburg.de>"] maintainers = ["David Huss <david.huss@hfbk-hamburg.de>"]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment