Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bbbmon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bbb
bbbmon
Commits
c4230bbc
Commit
c4230bbc
authored
5 years ago
by
David Huss
Browse files
Options
Downloads
Patches
Plain Diff
Add command abbreviations (e.g. bbbmon m)
parent
29880dc9
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+10
-0
10 additions, 0 deletions
README.md
bbbmon/bbbmon.py
+31
-10
31 additions, 10 deletions
bbbmon/bbbmon.py
pyproject.toml
+1
-1
1 addition, 1 deletion
pyproject.toml
with
42 additions
and
11 deletions
README.md
+
10
−
0
View file @
c4230bbc
...
...
@@ -77,3 +77,13 @@ For help run:
bbbmon
-h
```
bbbmon supports command abbreviations – these commands produce the same result:
```
bash
bbbmon meetings
bbbmon meeting
bbbmon mee
bbbmon m
```
This works as long as there is no other command starting with the same letters.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
bbbmon/bbbmon.py
+
31
−
10
View file @
c4230bbc
...
...
@@ -23,9 +23,29 @@ FRIENDLY_KEYNAMES = {
"
moderatorCount
"
:
"
Number of Moderators
"
}
# Allow -h as help option as well
CONTEXT_SETTINGS
=
dict
(
help_option_names
=
[
'
-h
'
,
'
--help
'
])
class
AliasedGroup
(
click
.
Group
):
"""
Subclass of Group to allow abbreviating commands like this:
Instead of `bbbmon meetings` one could type `bbbmon m`
"""
def
get_command
(
self
,
ctx
,
cmd_name
):
rv
=
click
.
Group
.
get_command
(
self
,
ctx
,
cmd_name
)
if
rv
is
not
None
:
return
rv
matches
=
[
x
for
x
in
self
.
list_commands
(
ctx
)
if
x
.
startswith
(
cmd_name
)]
if
not
matches
:
return
None
elif
len
(
matches
)
==
1
:
return
click
.
Group
.
get_command
(
self
,
ctx
,
matches
[
0
])
ctx
.
fail
(
'
Too many matches: %s
'
%
'
,
'
.
join
(
sorted
(
matches
)))
def
generate_checksum
(
call_name
:
str
,
query_string
:
str
,
secret
:
Secret
)
->
str
:
"""
Generate Checksum for the request header (passed as value for `?checksum=`)
...
...
@@ -167,6 +187,7 @@ def print_leaderboard(meetings: Iterable[XmlDictConfig], key: str, endpoint_name
else
:
print
(
"
{:>5} {}
"
.
format
(
m
[
key
],
m
[
"
meetingName
"
]))
def
print_duration_leaderboard
(
meetings
:
Iterable
[
XmlDictConfig
],
endpoint_name
:
str
,
presenter
:
bool
,
presenter_id
:
bool
,
fancy
:
bool
):
"""
Print a leaderboard of all meetings sorted by a given key (e.g.
...
...
@@ -184,12 +205,14 @@ def print_duration_leaderboard(meetings: Iterable[XmlDictConfig], endpoint_name:
else
:
print
(
"
{:>12} {}
"
.
format
(
format_duration
(
m
),
m
[
"
meetingName
"
]))
def
print_header
(
endpoint_name
:
str
,
text
:
str
,
fancy
=
True
):
if
fancy
:
click
.
echo
(
click
.
style
(
"
[{}] {}
"
.
format
(
endpoint_name
,
text
),
fg
=
'
black
'
,
bg
=
'
white
'
,
bold
=
True
))
else
:
print
(
"
[{}] {}
"
.
format
(
endpoint_name
,
text
))
def
print_overview
(
config
:
Config
,
leaderboards
:
bool
,
participants
:
bool
,
presenter
:
bool
,
presenter_id
:
bool
,
show_meetings
:
bool
,
watch
:
int
,
fancy
:
bool
):
"""
For each endpoint in the configuration get the active meetings and print
...
...
@@ -254,7 +277,8 @@ def print_overview(config: Config, leaderboards: bool, participants: bool, prese
print_duration_leaderboard
(
meeting
,
endpoint
.
name
,
presenter
,
presenter_id
,
fancy
)
@click.group
(
context_settings
=
CONTEXT_SETTINGS
)
@click.group
(
context_settings
=
CONTEXT_SETTINGS
,
cls
=
AliasedGroup
)
def
main
():
"""
BBBMON is a small CLI utility to monitor bbb usage
...
...
@@ -296,10 +320,7 @@ def meetings(ctx, leaderboards, participants, presenter, watch, presenter_id, me
@click.option
(
'
--print
'
,
'
print_
'
,
is_flag
=
True
,
help
=
"
Print the config to stdout
"
)
@click.option
(
'
--path
'
,
is_flag
=
True
,
help
=
"
Print the path to the config
"
)
def
config
(
ctx
,
new
,
edit
,
path
,
print_
):
"""
Print, show or edit the config
Example: bbbmon config --new
"""
"""
Print, show or edit the config
"""
user_config_path
=
get_user_config_path
()
if
edit
:
...
...
This diff is collapsed.
Click to expand it.
pyproject.toml
+
1
−
1
View file @
c4230bbc
[tool.poetry]
name
=
"bbbmon"
version
=
"0.1.1
2
"
version
=
"0.1.1
3
"
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>"
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment