Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
isgphys
python
Commits
a77b078f
Commit
a77b078f
authored
7 years ago
by
Sven Mäder
Browse files
Options
Downloads
Patches
Plain Diff
Add exception handling
parent
c0c347cf
No related branches found
No related tags found
1 merge request
!12
Deltalogparse
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/deltalogcat.py
+29
-12
29 additions, 12 deletions
bin/deltalogcat.py
with
29 additions
and
12 deletions
bin/deltalogcat.py
+
29
−
12
View file @
a77b078f
...
...
@@ -113,15 +113,22 @@ def tail_file(log_file):
fin
=
subprocess
.
Popen
([
'
tail
'
,
'
-F
'
,
log_file
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
poll
=
select
.
poll
()
poll
.
register
(
fin
.
stdout
)
while
True
:
start_time
=
time
.
perf_counter
()
if
poll
.
poll
(
1
):
line
=
fin
.
stdout
.
readline
().
decode
(
'
utf-8
'
)
parse
(
line
)
try
:
while
True
:
start_time
=
time
.
perf_counter
()
if
poll
.
poll
(
1
):
line
=
fin
.
stdout
.
readline
().
decode
(
'
utf-8
'
)
parse
(
line
)
sleep
(
start_time
)
except
KeyboardInterrupt
:
sys
.
stdout
.
flush
()
pass
sleep
(
start_time
)
def
read_file
(
log_file
):
...
...
@@ -129,19 +136,29 @@ def read_file(log_file):
with
open
(
log_file
,
'
r
'
)
as
fin
:
while
True
:
line
=
fin
.
readline
()
if
not
line
:
break
parse
(
line
)
def
read_stdin
():
"""
Read from stdin
"""
fin
=
sys
.
stdin
while
True
:
line
=
fin
.
readline
()
if
not
line
:
break
parse
(
line
)
try
:
while
True
:
line
=
fin
.
readline
()
if
not
line
:
break
parse
(
line
)
except
KeyboardInterrupt
:
sys
.
stdout
.
flush
()
pass
def
main
():
...
...
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