Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Status-Bot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Freifunk Hochstift
Status-Bot
Commits
535adb7c
Commit
535adb7c
authored
10 years ago
by
Helge Jung
Browse files
Options
Downloads
Patches
Plain Diff
ffpb.msg_handler: handle incomplete config and shutdown properly
parent
d4fd28fc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/ffpb.py
+26
-13
26 additions, 13 deletions
modules/ffpb.py
with
26 additions
and
13 deletions
modules/ffpb.py
+
26
−
13
View file @
535adb7c
...
...
@@ -11,6 +11,8 @@ import socket
import
SocketServer
import
threading
msgserver
=
None
# TODO: move into config file :)
msgserver_known_senders
=
{
"
127.0.0.1
"
:
"
localhost
"
,
...
...
@@ -42,19 +44,30 @@ class ThreadingTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
pass
def
setup
(
bot
):
host
=
"
localhost
"
port
=
4342
if
not
bot
.
config
.
ffpb
.
msg_host
is
None
:
host
=
bot
.
config
.
ffpb
.
msg_host
if
not
bot
.
config
.
ffpb
.
msg_port
is
None
:
port
=
int
(
bot
.
config
.
ffpb
.
msg_port
)
msgserver
=
ThreadingTCPServer
((
host
,
port
),
MsgHandler
)
msgserver
.
bot
=
bot
ip
,
port
=
msgserver
.
server_address
print
(
"
Messaging server listening on {}:{}
"
.
format
(
ip
,
port
))
msgserver_thread
=
threading
.
Thread
(
target
=
msgserver
.
serve_forever
)
msgserver_thread
.
daemon
=
True
msgserver_thread
.
start
()
global
msgserver
if
bot
.
config
.
has_section
(
'
ffpb
'
)
and
bot
.
config
.
ffpb
.
msg_enable
:
host
=
"
localhost
"
port
=
4342
if
not
bot
.
config
.
ffpb
.
msg_host
is
None
:
host
=
bot
.
config
.
ffpb
.
msg_host
if
not
bot
.
config
.
ffpb
.
msg_port
is
None
:
port
=
int
(
bot
.
config
.
ffpb
.
msg_port
)
msgserver
=
ThreadingTCPServer
((
host
,
port
),
MsgHandler
)
msgserver
.
bot
=
bot
ip
,
port
=
msgserver
.
server_address
print
(
"
Messaging server listening on {}:{}
"
.
format
(
ip
,
port
))
msgserver_thread
=
threading
.
Thread
(
target
=
msgserver
.
serve_forever
)
msgserver_thread
.
daemon
=
True
msgserver_thread
.
start
()
def
shutdown
(
bot
):
global
msgserver
if
not
msgserver
is
None
:
msgserver
.
shutdown
()
print
(
"
Closed messaging server.
"
)
msgserver
=
None
@willie.module.commands
(
'
status
'
)
def
ffpb_status
(
bot
,
trigger
):
...
...
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