Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapos.toolbox
Commits
3ba79139
Commit
3ba79139
authored
Mar 23, 2023
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
promise/plugin/util: fix PY2 support
parent
d38b5063
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
+15
-4
slapos/promise/plugin/util.py
slapos/promise/plugin/util.py
+15
-4
No files found.
slapos/promise/plugin/util.py
View file @
3ba79139
...
@@ -3,9 +3,11 @@ import json
...
@@ -3,9 +3,11 @@ import json
import
logging
import
logging
import
os
import
os
import
textwrap
import
textwrap
import
time
from
dateutil
import
parser
as
dateparser
from
dateutil
import
parser
as
dateparser
from
datetime
import
datetime
from
datetime
import
datetime
import
six
from
slapos.grid.promise.generic
import
GenericPromise
from
slapos.grid.promise.generic
import
GenericPromise
...
@@ -16,9 +18,15 @@ def iter_reverse_lines(f):
...
@@ -16,9 +18,15 @@ def iter_reverse_lines(f):
f
.
seek
(
0
,
os
.
SEEK_END
)
f
.
seek
(
0
,
os
.
SEEK_END
)
while
True
:
while
True
:
try
:
try
:
if
six
.
PY3
:
while
f
.
seek
(
-
2
,
os
.
SEEK_CUR
)
and
f
.
read
(
1
)
!=
b'
\
n
'
:
while
f
.
seek
(
-
2
,
os
.
SEEK_CUR
)
and
f
.
read
(
1
)
!=
b'
\
n
'
:
pass
pass
except
OSError
:
else
:
while
True
:
f
.
seek
(
-
2
,
os
.
SEEK_CUR
)
if
f
.
tell
()
==
0
or
f
.
read
(
1
)
==
'
\
n
'
:
break
except
(
OSError
,
IOError
):
return
return
pos
=
f
.
tell
()
pos
=
f
.
tell
()
yield
f
.
readline
()
yield
f
.
readline
()
...
@@ -62,7 +70,10 @@ def get_json_log_latest_timestamp(json_log_file):
...
@@ -62,7 +70,10 @@ def get_json_log_latest_timestamp(json_log_file):
for
f
in
iter_logrotate_file_handle
(
json_log_file
,
'rb'
):
for
f
in
iter_logrotate_file_handle
(
json_log_file
,
'rb'
):
for
line
in
iter_reverse_lines
(
f
):
for
line
in
iter_reverse_lines
(
f
):
l
=
json
.
loads
(
line
.
decode
().
replace
(
"'"
,
'"'
))
l
=
json
.
loads
(
line
.
decode
().
replace
(
"'"
,
'"'
))
return
dateparser
.
parse
(
l
[
'time'
]).
timestamp
()
date
=
dateparser
.
parse
(
l
[
'time'
])
if
six
.
PY2
:
return
time
.
mktime
(
date
.
timetuple
())
return
date
.
timestamp
()
return
0
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