Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aura-engine
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Show more breadcrumbs
Lars Kruse
aura-engine
Commits
a6fd60cc
Commit
a6fd60cc
authored
5 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Changed color handling and log level.
parent
c12dee25
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/cli_tool/padavan.py
+2
-1
2 additions, 1 deletion
modules/cli_tool/padavan.py
modules/communication/redis/adapter.py
+12
-10
12 additions, 10 deletions
modules/communication/redis/adapter.py
with
14 additions
and
11 deletions
modules/cli_tool/padavan.py
+
2
−
1
View file @
a6fd60cc
...
...
@@ -24,7 +24,8 @@
import
json
from
modules.base.enum
import
RedisChannel
,
TerminalColors
from
modules.base.enum
import
RedisChannel
from
modules.base.utils
import
TerminalColors
from
modules.communication.redis.adapter
import
ClientRedisAdapter
,
ServerRedisAdapter
from
modules.communication.redis.messenger
import
RedisMessenger
from
libraries.database.broadcasts
import
AuraDatabaseModel
...
...
This diff is collapsed.
Click to expand it.
modules/communication/redis/adapter.py
+
12
−
10
View file @
a6fd60cc
...
...
@@ -35,7 +35,8 @@ from modules.communication.redis.messenger import RedisMessenger
# from modules.communication.connection_tester import ConnectionTester
from
libraries.database.statestore
import
RedisStateStore
from
modules.base.exceptions
import
RedisConnectionException
from
modules.base.enum
import
RedisChannel
,
TerminalColors
,
FallbackType
from
modules.base.enum
import
RedisChannel
,
FallbackType
from
modules.base.utils
import
TerminalColors
# ------------------------------------------------------------------------------------------ #
...
...
@@ -78,14 +79,14 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
self
.
pubsub
=
self
.
redisdb
.
pubsub
()
self
.
pubsub
.
subscribe
(
self
.
channel
)
self
.
logger
.
info
(
TerminalColors
.
ORANGE
.
value
+
"
waiting for REDIS message on channel
"
+
self
.
channel
+
TerminalColors
.
ENDC
.
value
)
self
.
logger
.
debug
(
TerminalColors
.
YELLOW
.
value
+
"
waiting for REDIS message on channel
"
+
self
.
channel
+
TerminalColors
.
ENDC
.
value
)
# listener loop
for
item
in
self
.
pubsub
.
listen
():
if
item
[
"
type
"
]
==
"
subscribe
"
:
continue
self
.
logger
.
info
(
TerminalColors
.
ORANGE
.
value
+
"
received REDIS message:
"
+
TerminalColors
.
ENDC
.
value
+
str
(
item
))
self
.
logger
.
debug
(
TerminalColors
.
YELLOW
.
value
+
"
received REDIS message:
"
+
TerminalColors
.
ENDC
.
value
+
str
(
item
))
item
[
"
channel
"
]
=
self
.
decode_if_needed
(
item
[
"
channel
"
])
item
[
"
data
"
]
=
self
.
decode_if_needed
(
item
[
"
data
"
])
...
...
@@ -96,7 +97,7 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
self
.
logger
.
error
(
str
(
rce
))
if
not
self
.
shutdown_event
.
is_set
():
self
.
logger
.
info
(
TerminalColors
.
ORANGE
.
value
+
"
waiting for REDIS message on channel
"
+
self
.
channel
+
TerminalColors
.
ENDC
.
value
)
self
.
logger
.
debug
(
TerminalColors
.
YELLOW
.
value
+
"
waiting for REDIS message on channel
"
+
self
.
channel
+
TerminalColors
.
ENDC
.
value
)
self
.
pubsub
.
unsubscribe
()
...
...
@@ -116,7 +117,7 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
self
.
pubsub
.
subscribe
(
channel
)
try
:
self
.
logger
.
info
(
"
I am listening on channel
'"
+
channel
+
"'
for
"
+
str
(
socket_timeout
)
+
"
seconds
"
)
self
.
logger
.
debug
(
"
I am listening on channel
'"
+
channel
+
"'
for
"
+
str
(
socket_timeout
)
+
"
seconds
"
)
for
item
in
self
.
pubsub
.
listen
():
it
=
self
.
receive_message
(
item
)
...
...
@@ -175,7 +176,7 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
self
.
execute
(
RedisChannel
.
GNF_REPLY
.
value
,
self
.
scheduler
.
get_next_file_for
,
playlist
)
elif
item
[
"
data
"
].
find
(
"
adapt_trackservice_title
"
)
>=
0
:
fil
e
=
item
[
"
data
"
].
split
(
"
|+|+|
"
)[
1
]
sourc
e
=
item
[
"
data
"
].
split
(
"
|+|+|
"
)[
1
]
artist
=
item
[
"
data
"
].
split
(
"
|+|+|
"
)[
2
]
title
=
item
[
"
data
"
].
split
(
"
|+|+|
"
)[
3
]
...
...
@@ -184,7 +185,8 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
if
not
title
:
title
=
""
self
.
execute
(
RedisChannel
.
TS_REPLY
.
value
,
self
.
scheduler
.
adapt_trackservice_title
,
file
,
artist
,
title
)
self
.
execute
(
RedisChannel
.
TS_REPLY
.
value
,
self
.
scheduler
.
liquidsoapcommunicator
.
store_trackservice_info
,
source
)
self
.
execute
(
RedisChannel
.
TS_REPLY
.
value
,
self
.
scheduler
.
adapt_trackservice_title
,
source
,
artist
,
title
)
elif
item
[
"
data
"
]
==
"
recreate_db
"
:
self
.
execute
(
RedisChannel
.
RDB_REPLY
.
value
,
self
.
scheduler
.
recreate_database
)
...
...
@@ -214,7 +216,7 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
# sometimes the sender is faster than the receiver. redis messages would be lost
time
.
sleep
(
0.1
)
self
.
logger
.
info
(
TerminalColors
.
ORANGE
.
value
+
"
replying REDIS message
"
+
TerminalColors
.
ENDC
.
value
+
reply
+
TerminalColors
.
ORANGE
.
value
+
"
on channel
"
+
channel
+
TerminalColors
.
ENDC
.
value
)
self
.
logger
.
debug
(
TerminalColors
.
YELLOW
.
value
+
"
replying REDIS message
"
+
TerminalColors
.
ENDC
.
value
+
reply
+
TerminalColors
.
YELLOW
.
value
+
"
on channel
"
+
channel
+
TerminalColors
.
ENDC
.
value
)
# publish
self
.
redisclient
.
publish
(
channel
,
reply
)
...
...
@@ -223,7 +225,7 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
def
join_comm
(
self
):
try
:
while
self
.
is_alive
():
self
.
logger
.
info
(
str
(
datetime
.
now
())
+
"
joining
"
)
self
.
logger
.
debug
(
str
(
datetime
.
now
())
+
"
joining
"
)
self
.
join
()
self
.
logger
.
warning
(
"
join out
"
)
...
...
@@ -259,7 +261,7 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
# FIXME Review logic
if
not
self
.
can_send
:
self
.
logger
.
info
(
"
sending a
"
+
str
(
len
(
message
))
+
"
long message via REDIS.
"
)
self
.
logger
.
debug
(
"
sending a
"
+
str
(
len
(
message
))
+
"
long message via REDIS.
"
)
self
.
socket
.
send
(
message
.
encode
(
"
utf-8
"
))
self
.
can_send
=
False
else
:
...
...
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