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):
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:
print(__version__)
......
......@@ -31,7 +31,7 @@ def generate_checksum(call_name: str, query_string: str, secret: Secret) -> str:
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
with the servers response
......@@ -52,6 +52,7 @@ def request_meetings(secret: Secret, bbb_url: Url, user_config_path: str) -> Xml
try:
root = ElementTree.XML(r.text)
except ElementTree.ParseError as e:
if not sum_:
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))
print("Exiting...")
exit()
......@@ -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
"""
meetings = []
try:
d = request_meetings(secret, bbb_url, user_config_path)
d = request_meetings(secret, bbb_url, user_config_path, sum_)
except:
return ["unreachable"]
......@@ -123,7 +124,7 @@ def list_meetings(config: Config, leaderboards: bool, n: int, participants: bool
"""
# 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
if sum_:
......@@ -249,12 +250,15 @@ def meetings_twolines(config: Config, watch: int, fancy: bool, sum_:bool):
"""
# 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
if sum_:
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
# blinking to a minimum
if watch is not None:
......
[tool.poetry]
name = "bbbmon"
version = "0.1.29"
version = "0.1.30"
description = "A small CLI utility to monitor bbb usage"
authors = ["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