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
32a65e73
authored
Jul 24, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more code style and json
parent
7059917a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
notify.py
+8
-8
No files found.
notify.py
View file @
32a65e73
...
@@ -2,22 +2,22 @@
...
@@ -2,22 +2,22 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
##
##
#
Test program that informs the user about vm incoming time out
#
Notify user about vm expiring
##
##
import
platform
import
json
import
logging
import
logging
import
os
import
os
import
platform
import
subprocess
import
subprocess
import
urllib2
import
webbrowser
import
webbrowser
import
cPickle
as
pickle
system
=
platform
.
system
()
logger
=
logging
.
getLogger
()
logger
=
logging
.
getLogger
()
file_name
=
"vm_renewal.p"
file_name
=
"vm_renewal.p"
def
pars_arguments
():
def
pars
e
_arguments
():
import
argparse
import
argparse
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"-u"
,
"--url"
,
type
=
str
,
required
=
True
)
parser
.
add_argument
(
"-u"
,
"--url"
,
type
=
str
,
required
=
True
)
...
@@ -75,12 +75,12 @@ def accept():
...
@@ -75,12 +75,12 @@ def accept():
def
notify
(
url
):
def
notify
(
url
):
if
os
.
getenv
(
"DISPLAY"
)
and
system
==
'Linux'
or
system
==
'Windows'
:
if
os
.
getenv
(
"DISPLAY"
)
and
platform
.
system
()
in
(
'Linux'
,
'Windows'
)
:
webbrowser
.
open
(
url
,
new
=
2
,
autoraise
=
True
)
webbrowser
.
open
(
url
,
new
=
2
,
autoraise
=
True
)
elif
not
os
.
getenv
(
"DISPLAY"
):
elif
not
os
.
getenv
(
"DISPLAY"
):
if
os
.
path
.
isfile
(
"
%
s/
%
s"
%
(
get_temp_dir
(),
file_name
)):
if
os
.
path
.
isfile
(
"
%
s/
%
s"
%
(
get_temp_dir
(),
file_name
)):
logger
.
info
(
"There is on old request already saved"
)
logger
.
info
(
"There is on old request already saved"
)
pickle
.
dump
(
url
,
open
(
"
%
s/
%
s"
%
(
get_temp_dir
(),
file_name
),
"wb"
))
json
.
dump
(
url
,
open
(
"
%
s/
%
s"
%
(
get_temp_dir
(),
file_name
),
"wb"
))
wall
(
"This virtual machine is going to expire! Please type
\n
"
wall
(
"This virtual machine is going to expire! Please type
\n
"
" vm_renewal
\n
"
" vm_renewal
\n
"
"command to keep it running."
)
"command to keep it running."
)
...
@@ -89,7 +89,7 @@ def notify(url):
...
@@ -89,7 +89,7 @@ def notify(url):
def
main
():
def
main
():
args
=
pars_arguments
()
args
=
pars
e
_arguments
()
notify
(
args
.
url
)
notify
(
args
.
url
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
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