Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
df-aggregator
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Oleksandr Barabash
df-aggregator
Commits
2cdcefe7
Commit
2cdcefe7
authored
Aug 07, 2023
by
Oleksandr Barabash
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gracial quitter added
parent
8b40c213
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
10 deletions
+16
-10
app.py
app.py
+16
-10
No files found.
app.py
View file @
2cdcefe7
...
...
@@ -6,12 +6,11 @@ import os
import
signal
import
sys
from
asyncio
import
AbstractEventLoop
from
concurrent.futures
import
ThreadPoolExecutor
from
threading
import
Thread
from
typing
import
Any
,
Optional
from
absl
import
app
,
flags
from
marshmallow
import
EXCLUDE
from
openpyxl
import
Workbook
from
utils.ether_service.entities.data.kr_packet
import
KrPacketV2
from
utils.ether_service.utils.json_func
import
json_loads
...
...
@@ -48,6 +47,7 @@ class CSVLogger(PacketLogger):
def
__init__
(
self
,
file_path
:
Optional
[
str
]
=
None
):
self
.
file_path
=
file_path
self
.
file
=
None
self
.
records
=
0
if
file_path
is
not
None
:
self
.
file_path
=
file_path
...
...
@@ -71,14 +71,12 @@ class CSVLogger(PacketLogger):
def
write
(
self
,
data
:
str
)
->
None
:
""" Try write """
if
self
.
file
is
None
:
return
self
.
file
=
open
(
self
.
file_path
,
"a+"
)
self
.
file
.
write
(
data
)
while
True
:
try
:
self
.
file
.
write
(
data
)
return
except
Exception
:
self
.
file
=
open
(
self
.
file_path
,
"a+"
)
self
.
records
+=
1
if
self
.
records
%
50
==
0
:
self
.
file
.
flush
()
def
log
(
self
,
kr_packet
:
KrPacketV2
)
->
None
:
""" Log packet """
...
...
@@ -187,7 +185,15 @@ def main(_argv) -> int:
io_loop
))
signal
.
signal
(
signal
.
SIGTERM
,
stop_server
(
ws_client
,
packet_logger
,
io_loop
))
io_loop
.
run_forever
()
thread
=
Thread
(
target
=
io_loop
.
run_forever
)
thread
.
start
()
while
True
:
data
=
input
()
print
(
repr
(
data
))
if
data
.
strip
()
.
lower
()
==
"q"
:
stop_server
(
ws_client
,
packet_logger
,
io_loop
)(
None
,
None
)
thread
.
join
()
break
return
0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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