Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
eichkat3r
senfsip-moderated-mute
Commits
b697d003
Commit
b697d003
authored
Jun 13, 2021
by
Henry Krumb
Browse files
add debug option
parent
e97c7d21
Pipeline
#5786
passed with stage
in 3 minutes and 14 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
events.py
View file @
b697d003
...
...
@@ -15,7 +15,7 @@ import logging
import
os
import
subprocess
import
sys
logging
.
basicConfig
(
level
=
logging
.
DEBU
G
)
logging
.
basicConfig
(
level
=
logging
.
WARNIN
G
)
class
ModeratedMic
:
...
...
@@ -81,12 +81,10 @@ class ModeratedMic:
return
locked_state
=
"locked"
if
locked
else
"unlocked"
logging
.
debug
(
f
"caller
{
caller_num
}
pressed 0, they are in a
{
locked_state
}
meeting."
)
logging
.
debug
(
"fs_member_id:
"
,
fs_member_id
)
logging
.
debug
(
f
"fs_member_id:
{
fs_member_id
}
"
)
try
:
if
not
locked
:
logging
.
debug
(
self
.
fs
.
send
(
f
"api conference
{
conference_id
}
tmute
{
fs_member_id
}
"
).
data
)
else
:
logging
.
debug
(
self
.
fs
.
send
(
f
"api conference
{
conference_id
}
mute
{
fs_member_id
}
"
).
data
)
command
=
'mute'
if
locked
else
'tmute'
logging
.
debug
(
self
.
fs
.
send
(
f
"api conference
{
conference_id
}
{
command
}
{
fs_member_id
}
"
).
data
)
except
KeyError
as
e
:
# TODO investigate what actually happens here
logging
.
warning
(
"Error when sending (t)mute:"
)
...
...
@@ -160,21 +158,28 @@ class ModeratedMic:
@
click
.
command
()
@
click
.
option
(
'--debug'
,
'-d'
,
is_flag
=
True
)
@
click
.
argument
(
'mode'
,
type
=
click
.
Choice
([
'zero_key_handler'
,
'redis_handler'
]),
required
=
False
)
def
main
(
mode
):
def
main
(
mode
,
debug
):
if
debug
:
logging
.
getLogger
().
setLevel
(
logging
.
DEBUG
)
# no command line args supplied:
# spawns two subprocesses for 0-key and redis handlers
if
not
mode
:
interpreter_path
=
sys
.
executable
flags
=
[]
if
debug
:
flags
.
append
(
'-d'
)
zero_key_handler
=
subprocess
.
Popen
([
interpreter_path
,
'-u'
,
sys
.
argv
[
0
],
'zero_key_handler'
interpreter_path
,
'-u'
,
sys
.
argv
[
0
],
'zero_key_handler'
,
*
flags
])
redis_handler
=
subprocess
.
Popen
([
interpreter_path
,
'-u'
,
sys
.
argv
[
0
],
'redis_handler'
interpreter_path
,
'-u'
,
sys
.
argv
[
0
],
'redis_handler'
,
*
flags
])
zero_key_handler
.
wait
()
redis_handler
.
wait
()
...
...
senfsip-moderated-mute.service
View file @
b697d003
...
...
@@ -7,7 +7,7 @@ PartOf=freeswitch.service
[Service]
Type
=
simple
WorkingDirectory
=
/opt/senfsip-moderated-mute
ExecStart
=
/bin/bash -c "source venv/bin/activate && ./events.py"
ExecStart
=
/bin/bash -c "source venv/bin/activate && ./events.py
--debug
"
Restart
=
always
[Install]
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment