From 8432263230da0a294cc7cc98aab9005c037be77a Mon Sep 17 00:00:00 2001
From: David Huss <dh@atoav.com>
Date: Thu, 28 May 2020 11:41:27 +0200
Subject: [PATCH] Make --sum compatible with -2 --fancy

---
 bbbmon/__init__.py |  2 +-
 bbbmon/bbbmon.py   |  2 +-
 bbbmon/meetings.py | 20 ++++++++++++--------
 pyproject.toml     |  2 +-
 4 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/bbbmon/__init__.py b/bbbmon/__init__.py
index 6f8839b..0871cd5 100644
--- a/bbbmon/__init__.py
+++ b/bbbmon/__init__.py
@@ -1 +1 @@
-__version__ = '0.1.29'
+__version__ = '0.1.30'
diff --git a/bbbmon/bbbmon.py b/bbbmon/bbbmon.py
index 890d283..cc62771 100755
--- a/bbbmon/bbbmon.py
+++ b/bbbmon/bbbmon.py
@@ -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__)
diff --git a/bbbmon/meetings.py b/bbbmon/meetings.py
index b817ecb..f3ef6e9 100644
--- a/bbbmon/meetings.py
+++ b/bbbmon/meetings.py
@@ -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,9 +52,10 @@ def request_meetings(secret: Secret, bbb_url: Url, user_config_path: str) -> Xml
     try:
         root = ElementTree.XML(r.text)
     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))
-        print("Exiting...")
-        exit()
+        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()
 
     xmldict = XmlDictConfig(root)
     if "returncode" in xmldict.keys():
@@ -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:
diff --git a/pyproject.toml b/pyproject.toml
index a486c20..fe059b4 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [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>"]
-- 
GitLab