diff --git a/.idea/bbb-status.iml b/.idea/bbb-status.iml
index a4225b5..c5f6482 100644
--- a/.idea/bbb-status.iml
+++ b/.idea/bbb-status.iml
@@ -5,7 +5,7 @@
-
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 0d00bb2..7174e2d 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,4 +1,4 @@
-
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 6426901..af20526 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,15 @@
-# README
+# bbb-status
+
+Python3 script to log and plot BigBlueButton usage statistics.
Thanks to Bernd Wurst who inspired this project with his gist on github:
-* https://gist.github.com/bwurst/7f94e0392c75d273a08d1e686182fc5e
+* [https://gist.github.com/bwurst/7f94e0392c75d273a08d1e686182fc5e]()
-## setup
+## Setup
Execute `bbb-conf --secret` on your server.
-This gives you your **API-secret**, the **URL** at which BigBlueButton is running at.
+This gives you your **API-secret** and the **URL** at which BigBlueButton is running at.
Save these two values in the first line of the following files:
@@ -16,7 +18,9 @@ Save these two values in the first line of the following files:
Note: You may `chmod 600` on the two above files.
-## run
+Optionally: Set the log interval to something different from 5 minutes by creating `secret/minutes.txt` with an integer in the first line.
+
+## Run
Start logging in the background:
@@ -30,7 +34,7 @@ Generate a new plot based on saved meeting data:
sudo docker-compose run bbb-status plot
```
-## example logging
+## Example - log meeting statistics
```shell
sudo docker-compose up -d # start logging in the background
@@ -53,6 +57,6 @@ bbb-status_1 | moderatorCount: 1
bbb-status_1 | >> Sleeping for five minutes <<
```
-## example plot
+## Example - create a plot from saved statistics
![plot of one month BBB usage](plot-last-month.png)
diff --git a/src/langfingaz/bbbRequest.py b/src/langfingaz/bbbRequest.py
index f2299d1..9e62420 100644
--- a/src/langfingaz/bbbRequest.py
+++ b/src/langfingaz/bbbRequest.py
@@ -73,7 +73,7 @@ def getRequestUrl(api_method: str = 'getMeetings', query_string: str = '') -> st
def getUrl() -> str:
- filepath = fileUtil.getProjectBaseDir().joinpath("secret").joinpath("url.txt")
+ filepath = fileUtil.getProjectBaseDir() / "secret" / "url.txt"
url = fileUtil.readFirstLine(filepath).strip()
if not url.endswith("/"):
raise ValueError("url should end with '/'")
@@ -81,9 +81,16 @@ def getUrl() -> str:
def getSecret() -> str:
- filepath = fileUtil.getProjectBaseDir().joinpath("secret").joinpath("secret.txt")
+ filepath = fileUtil.getProjectBaseDir() / "secret" / "secret.txt"
secret = fileUtil.readFirstLine(filepath).strip()
min_length = 12
if len(secret) <= min_length:
- raise ValueError("secret should be longer than {} characters!".format(min_length))
+ raise ValueError(f"secret should be longer than {min_length} characters!")
return secret
+
+
+def getSleepMinutes() -> int:
+ filepath = fileUtil.getProjectBaseDir() / "secret" / "minutes.txt"
+ if not filepath.exists():
+ return 5
+ return int(fileUtil.readFirstLine(filepath).strip())
diff --git a/src/langfingaz/logMeetingData.py b/src/langfingaz/logMeetingData.py
index 0be165e..9638d85 100755
--- a/src/langfingaz/logMeetingData.py
+++ b/src/langfingaz/logMeetingData.py
@@ -1,21 +1,19 @@
#!/usr/bin/python3
-
-import sys
-import time
from pathlib import Path
from langfingaz import parseMeetings, bbbRequest, saveData
+from langfingaz.bbbRequest import getSleepMinutes
from langfingaz.util import util as util
import langfingaz.util.fileUtil as fileUtil
-def sleepFiveMin(verbose=False):
- minute = 60
- fiveMinutes = 5 * minute
+def sleepMinutes(verbose=False):
+ minutes = getSleepMinutes()
+ seconds = minutes * 60
if verbose:
- print(">> Sleeping for five minutes <<")
- util.sleep(fiveMinutes)
+ print(f">> Sleeping for {minutes} minutes <<")
+ util.sleep(seconds)
def v2(folder: Path = fileUtil.getDataDir()):
@@ -24,21 +22,21 @@ def v2(folder: Path = fileUtil.getDataDir()):
while True:
meetingsStr = bbbRequest.requestMeetingData()
savedFile = saveData.saveMeetingsData(meetingsStr, folder)
- print("Saved meetings at {}".format(savedFile))
+ print(f"Saved meetings at {savedFile}")
meetings = parseMeetings.parseMeetingsData(meetingsStr)
bbbStatus = parseMeetings.BbbStatus(meetings)
bbbStatusStr = str(bbbStatus)
print(util.indentMultilineStr(bbbStatusStr))
- sleepFiveMin(verbose=True)
+ sleepMinutes(verbose=True)
def v1(folder: Path = fileUtil.getDataDir()):
while True:
saveData.requestAndSaveMeetingData(folder)
print('.')
- sleepFiveMin()
+ sleepMinutes()
if __name__ == '__main__':
diff --git a/src/langfingaz/plotMeetings.py b/src/langfingaz/plotMeetings.py
index d06e0f6..4f88fe6 100644
--- a/src/langfingaz/plotMeetings.py
+++ b/src/langfingaz/plotMeetings.py
@@ -14,7 +14,7 @@ from langfingaz.util import util
def getDefaultPlotFolder() -> Path:
- return fileUtil.getProjectBaseDir().joinpath("plot")
+ return fileUtil.getProjectBaseDir() / "plot"
def plotMeetings(dataDir: Path = fileUtil.getDataDir()):
@@ -81,7 +81,7 @@ def doPlotMeetings(bbbStati: List[BbbStatus]) -> Path:
fig.autofmt_xdate()
imgFormat = 'png'
- image: Path = getDefaultPlotFolder().joinpath(
+ image: Path = getDefaultPlotFolder() / (
"{}_until_{}.{}".format(
fileUtil.asString(time[0]),
fileUtil.asString(time[-1]),
diff --git a/src/langfingaz/saveData.py b/src/langfingaz/saveData.py
index 2dc1741..14e9895 100644
--- a/src/langfingaz/saveData.py
+++ b/src/langfingaz/saveData.py
@@ -39,7 +39,7 @@ def doSaveData(dataStr: str, folder: Path, dataType: str) -> Path:
:return: Path to created file
"""
- fileWithoutDate = folder.joinpath(dataType + '.xml')
+ fileWithoutDate = folder / f"{dataType}.xml"
prefixedFile = fileUtil.setDatetimePrefix(fileWithoutDate, datetime.now())
with open(prefixedFile, "w") as xml_file:
diff --git a/src/langfingaz/util/fileUtil.py b/src/langfingaz/util/fileUtil.py
index dbb9d08..2a1c32c 100644
--- a/src/langfingaz/util/fileUtil.py
+++ b/src/langfingaz/util/fileUtil.py
@@ -15,7 +15,7 @@ def getDataDir() -> Path:
"""
:return: The default data directory
"""
- return getProjectBaseDir().joinpath("data")
+ return getProjectBaseDir() / "data"
def readFirstLine(file: Path) -> str:
@@ -39,14 +39,14 @@ def setDatetimePrefix(file: Path, t: datetime) -> Path:
# filename = file.name
prefix = asString(t)
filename = prefix + "_" + file.name
- return file.parent.joinpath(filename)
+ return file.parent / filename
def removeDatetimePrefix(file: Path) -> Path:
prefixLen = __getDatetimePrefixLength()
# prefixlen + 1 to remove the underline!
- return file.parent.joinpath(file.name[prefixLen + 1:])
+ return file.parent / file.name[prefixLen + 1:]
def getDatetimePrefix(file: Path) -> datetime: