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
a7d5ee9e
authored
Nov 14, 2014
by
Guba Sándor
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add local time support
parent
3666457b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
notify.py
+12
-2
No files found.
notify.py
View file @
a7d5ee9e
...
...
@@ -53,6 +53,9 @@ def wall(text):
def
accept
():
import
datetime
from
tzlocal
import
get_localzone
from
pytz
import
UTC
file_path
=
os
.
path
.
join
(
get_temp_dir
(),
file_name
)
if
not
os
.
path
.
isfile
(
file_path
):
print
"There is no recent notification to accept."
...
...
@@ -73,12 +76,19 @@ def accept():
rsp
=
opener
.
open
(
req
)
data
=
json
.
load
(
rsp
)
newtime
=
data
[
"new_suspend_time"
]
except
:
# 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
)
# Convert to the machine localization
new_local_time
=
parsed_time
.
astimezone
(
get_localzone
())
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
except
ValueError
as
e
:
print
"Parsing time failed:
%
s"
%
e
except
Exception
as
e
:
print
e
print
"Renewal failed. Please try it manually at
%
s"
%
url
logger
.
exception
(
"renew failed"
)
return
False
else
:
print
"Renew succeeded. The machine will be suspended at
%
s."
%
newtime
print
"Renew succeeded. The machine will be suspended at
%
s."
%
new
_local_
time
os
.
remove
(
file_path
)
return
True
...
...
Őry Máté
@orymate
commented
Nov 14, 2014
Owner
😎
:sunglasses:
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