Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
stechuhr-client
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
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pandemic_Response
stechuhr-client
Commits
fc9a8712
Commit
fc9a8712
authored
Mar 15, 2021
by
David Huss
Browse files
Options
Downloads
Patches
Plain Diff
Clean up a little
parent
8dcb60a7
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
stechuhr_client/client.py
+16
-12
16 additions, 12 deletions
stechuhr_client/client.py
with
16 additions
and
12 deletions
stechuhr_client/client.py
+
16
−
12
View file @
fc9a8712
...
@@ -160,6 +160,19 @@ def midinumber_to_hertz(note: int) -> float:
...
@@ -160,6 +160,19 @@ def midinumber_to_hertz(note: int) -> float:
return
(
440
/
32
)
*
(
2
**
((
note
-
9
)
/
12
))
return
(
440
/
32
)
*
(
2
**
((
note
-
9
)
/
12
))
def
build_url
(
config
,
endpoint
:
str
=
""
)
->
str
:
"""
Build a URL for requests
"""
if
config
[
"
server
"
][
"
port
"
]
==
80
:
protocol
=
"
http
"
else
:
protocol
=
"
https
"
url
=
'
{}://{}/{}
'
.
format
(
protocol
,
config
[
"
server
"
][
"
address
"
].
rstrip
(
"
/
"
),
endpoint
.
lstrip
(
"
/
"
))
return
url
def
process_request
(
output_queue
,
config
=
None
,
logger
=
None
):
def
process_request
(
output_queue
,
config
=
None
,
logger
=
None
):
"""
"""
Process a event from the output queue.
Process a event from the output queue.
...
@@ -181,12 +194,7 @@ def process_request(output_queue, config=None, logger=None):
...
@@ -181,12 +194,7 @@ def process_request(output_queue, config=None, logger=None):
dispatch_led
(
"
failure
"
,
config
)
dispatch_led
(
"
failure
"
,
config
)
dispatch_buzzer
(
"
failure
"
,
config
)
dispatch_buzzer
(
"
failure
"
,
config
)
elif
response
==
"
error
"
:
elif
response
==
"
error
"
:
if
config
[
"
server
"
][
"
port
"
]
==
80
:
url
=
build_url
(
config
,
"
/alive
"
)
protocol
=
"
http
"
else
:
protocol
=
"
https
"
url
=
'
{}://{}/alive
'
.
format
(
protocol
,
config
[
"
server
"
][
"
address
"
].
rstrip
(
"
/
"
))
reached
=
False
reached
=
False
attempts
=
1
attempts
=
1
# Display the fitting LED color for the state at the given repetition
# Display the fitting LED color for the state at the given repetition
...
@@ -204,6 +212,7 @@ def process_request(output_queue, config=None, logger=None):
...
@@ -204,6 +212,7 @@ def process_request(output_queue, config=None, logger=None):
logger
.
warn
(
"
Didn
'
t reach server at {} for {} attempts:
"
.
format
(
url
,
attempts
,
e
))
logger
.
warn
(
"
Didn
'
t reach server at {} for {} attempts:
"
.
format
(
url
,
attempts
,
e
))
attempts
+=
1
attempts
+=
1
time
.
sleep
(
6
)
time
.
sleep
(
6
)
else
:
else
:
time
.
sleep
(
0.01
)
time
.
sleep
(
0.01
)
...
@@ -381,12 +390,7 @@ def update_id_patterns(config, logger) -> 'Config':
...
@@ -381,12 +390,7 @@ def update_id_patterns(config, logger) -> 'Config':
"""
"""
Update the id_patterns from the server via http
Update the id_patterns from the server via http
"""
"""
if
config
[
"
server
"
][
"
port
"
]
==
80
:
url
=
build_url
(
config
,
"
/config/database/id_patterns
"
)
protocol
=
"
http
"
else
:
protocol
=
"
https
"
url
=
'
{}://{}/config/database/id_patterns
'
.
format
(
protocol
,
config
[
"
server
"
][
"
address
"
].
rstrip
(
"
/
"
))
logger
.
debug
(
"
Requesting id_pattern update at address: {}
"
.
format
(
url
))
logger
.
debug
(
"
Requesting id_pattern update at address: {}
"
.
format
(
url
))
# Send request
# Send request
...
...
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