Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Warden
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
Container 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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pavel Valach
Warden
Commits
a220e53b
Commit
a220e53b
authored
10 years ago
by
Pavel Kácha
Browse files
Options
Downloads
Patches
Plain Diff
Added format_timestamp helper function
parent
168609eb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
warden3/warden_client/warden_client.py
+12
-3
12 additions, 3 deletions
warden3/warden_client/warden_client.py
with
12 additions
and
3 deletions
warden3/warden_client/warden_client.py
+
12
−
3
View file @
a220e53b
...
@@ -4,14 +4,13 @@
...
@@ -4,14 +4,13 @@
# Copyright (C) 2011-2015 Cesnet z.s.p.o
# Copyright (C) 2011-2015 Cesnet z.s.p.o
# Use of this source is governed by a 3-clause BSD-style license, see LICENSE file.
# Use of this source is governed by a 3-clause BSD-style license, see LICENSE file.
import
json
,
httplib
,
ssl
,
socket
,
logging
,
logging
.
handlers
import
json
,
httplib
,
ssl
,
socket
,
logging
,
logging
.
handlers
,
time
from
urlparse
import
urlparse
from
urlparse
import
urlparse
from
urllib
import
urlencode
from
urllib
import
urlencode
from
sys
import
stderr
,
exc_info
from
sys
import
stderr
,
exc_info
from
pprint
import
pformat
from
pprint
import
pformat
from
traceback
import
format_tb
from
traceback
import
format_tb
from
os
import
path
from
os
import
path
from
time
import
sleep
from
operator
import
itemgetter
from
operator
import
itemgetter
...
@@ -514,7 +513,7 @@ class Client(object):
...
@@ -514,7 +513,7 @@ class Client(object):
while
ev
and
attempt
:
while
ev
and
attempt
:
if
attempt
<
retry
:
if
attempt
<
retry
:
self
.
logger
.
info
(
"
%d transient errors, retrying (%d to go)
"
%
(
len
(
ev
),
attempt
))
self
.
logger
.
info
(
"
%d transient errors, retrying (%d to go)
"
%
(
len
(
ev
),
attempt
))
sleep
(
pause
or
self
.
pause
)
time
.
sleep
(
pause
or
self
.
pause
)
res
=
self
.
send_events_chunked
(
ev
)
res
=
self
.
send_events_chunked
(
ev
)
attempt
-=
1
attempt
-=
1
...
@@ -579,6 +578,16 @@ class Client(object):
...
@@ -579,6 +578,16 @@ class Client(object):
def
format_timestamp
(
epoch
=
None
,
utcoffset
=
None
):
t
=
epoch
if
epoch
else
time
.
time
()
tstr
=
"
%04d-%02d-%02dT%02d:%02d:%02d
"
%
time
.
localtime
(
t
)[:
6
]
us
=
int
(
t
%
1
*
1000000
+
0.5
)
usstr
=
"
.
"
+
str
(
us
).
rstrip
(
"
0
"
)
if
us
else
""
offset
=
utcoffset
if
utcoffset
is
not
None
else
-
(
time
.
altzone
if
time
.
daylight
else
time
.
timezone
)
offsstr
=
(
"
%+03d:%02d
"
%
divmod
((
offset
+
30
)
//
60
,
60
))
if
offset
else
"
Z
"
return
tstr
+
usstr
+
offsstr
def
read_cfg
(
cfgfile
):
def
read_cfg
(
cfgfile
):
abspath
=
path
.
join
(
path
.
dirname
(
__file__
),
cfgfile
)
abspath
=
path
.
join
(
path
.
dirname
(
__file__
),
cfgfile
)
with
open
(
abspath
,
"
r
"
)
as
f
:
with
open
(
abspath
,
"
r
"
)
as
f
:
...
...
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