Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
agent
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
7
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
29303b99
authored
Nov 14, 2014
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix pep8
parent
5b769880
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
notify.py
+6
-3
No files found.
notify.py
View file @
29303b99
...
@@ -77,9 +77,11 @@ def accept():
...
@@ -77,9 +77,11 @@ def accept():
data
=
json
.
load
(
rsp
)
data
=
json
.
load
(
rsp
)
newtime
=
data
[
"new_suspend_time"
]
newtime
=
data
[
"new_suspend_time"
]
# Parse time from JSON (Create UTC Localized Datetime objec)
# Parse time from JSON (Create UTC Localized Datetime objec)
parsed_time
=
datetime
.
datetime
.
strptime
(
newtime
[:
-
6
],
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S.
%
f"
)
.
replace
(
tzinfo
=
UTC
)
parsed_time
=
datetime
.
datetime
.
strptime
(
newtime
[:
-
6
],
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S.
%
f"
)
.
replace
(
tzinfo
=
UTC
)
# Convert to the machine localization
# Convert to the machine localization
new_local_time
=
parsed_time
.
astimezone
(
get_localzone
())
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
new_local_time
=
parsed_time
.
astimezone
(
get_localzone
())
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
except
ValueError
as
e
:
except
ValueError
as
e
:
print
"Parsing time failed:
%
s"
%
e
print
"Parsing time failed:
%
s"
%
e
except
Exception
as
e
:
except
Exception
as
e
:
...
@@ -88,7 +90,8 @@ def accept():
...
@@ -88,7 +90,8 @@ def accept():
logger
.
exception
(
"renew failed"
)
logger
.
exception
(
"renew failed"
)
return
False
return
False
else
:
else
:
print
"Renew succeeded. The machine will be suspended at
%
s."
%
new_local_time
print
(
"Renew succeeded. The machine will be "
"suspended at
%
s."
%
new_local_time
)
os
.
remove
(
file_path
)
os
.
remove
(
file_path
)
return
True
return
True
...
...
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