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
ed9eeabb
Commit
ed9eeabb
authored
4 years ago
by
David Huss
Browse files
Options
Downloads
Patches
Plain Diff
Handle ignore period for cards better
parent
7e28be4d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
stechuhr_client/client.py
+16
-4
16 additions, 4 deletions
stechuhr_client/client.py
stechuhr_client/config.py
+3
-0
3 additions, 0 deletions
stechuhr_client/config.py
with
19 additions
and
4 deletions
stechuhr_client/client.py
+
16
−
4
View file @
ed9eeabb
...
...
@@ -290,7 +290,7 @@ def read_key_input(input_queue, config, logger):
# Buffer to store incoming keys till ENTER (keycode 28) is received
keybuffer
=
[]
last_s
tring
=
None
last_s
een_cards
=
None
# Loop Forever over the Input
while
True
:
...
...
@@ -318,10 +318,22 @@ def read_key_input(input_queue, config, logger):
# and reset the keybuffer
joined_string
=
""
.
join
(
keybuffer
)
# Don't add the string to the queue if is the same as before to avoid duplicates
if
last_string
is
None
or
joined_string
!=
last_string
:
if
last_seen_cards
is
None
or
len
(
last_seen_cards
)
==
0
:
input_queue
.
put
(
joined_string
)
last_string
=
joined_string
last_seen_cards
.
append
({
"
id
"
:
joined_string
,
"
time
"
:
time
.
time
()})
else
:
# Remove all cards from the list if they are past the threshold
last_seen_cards
=
[
c
for
c
in
last_seen_cards
if
time
.
time
()
-
c
[
"
time
"
]
>
config
[
"
client
"
][
"
ignore_duration
"
]
]
if
not
joined_string
in
[
c
[
"
id
"
]
for
c
in
last_seen_cards
]:
input_queue
.
put
(
joined_string
)
last_seen_cards
.
append
({
"
id
"
:
joined_string
,
"
time
"
:
time
.
time
()})
else
:
card
=
[
c
for
c
in
last_seen_cards
if
joined_string
==
c
[
"
id
"
]][
0
]
logger
.
info
(
"
Ignored duplicated register attempt of card {} because it was seen {} seconds ago
"
.
format
(
card
[
"
id
"
],
card
[
"
time
"
]))
keybuffer
=
[]
except
(
KeyboardInterrupt
,
SystemExit
,
OSError
)
as
e
:
cardreader
.
close
()
...
...
This diff is collapsed.
Click to expand it.
stechuhr_client/config.py
+
3
−
0
View file @
ed9eeabb
...
...
@@ -35,6 +35,9 @@ location = "lerchenfeld/mensa"
entrance =
"
haupteingang
"
direction =
"
in
"
# Duration for which to ignore repeated register attempt for a card (in seconds)
ignore_duration = 10
# A list of possible python regex patterns for the id (logical OR!)
id_patterns = [
"
^806[A-Z0-9]{9}04$
"
,
...
...
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