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
7059917a
authored
Jul 24, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix style to match pep8
parent
c56ff392
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
10 deletions
+22
-10
agent.py
+3
-0
notify.py
+19
-10
No files found.
agent.py
View file @
7059917a
...
...
@@ -67,6 +67,7 @@ def linux_set_time(time):
class
Context
(
object
):
@staticmethod
def
change_password
(
password
):
if
system
==
'Linux'
:
...
...
@@ -287,7 +288,9 @@ class Context(object):
import
notify
notify
.
notify
(
msg
)
class
SerialLineReceiver
(
SerialLineReceiverBase
):
def
connectionMade
(
self
):
self
.
send_command
(
command
=
'agent_started'
,
...
...
notify.py
View file @
7059917a
...
...
@@ -5,18 +5,23 @@
# Test program that informs the user about vm incoming time out
##
import
platform
,
logging
,
os
,
subprocess
,
webbrowser
,
sys
import
platform
import
logging
import
os
import
subprocess
import
webbrowser
import
cPickle
as
pickle
system
=
platform
.
system
()
logger
=
logging
.
getLogger
()
file_name
=
"vm_renewal.p"
def
pars_arguments
():
import
argparse
parser
=
argparse
.
ArgumentParser
()
;
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"-u"
,
"--url"
,
type
=
str
,
required
=
True
)
args
=
parser
.
parse_args
()
;
args
=
parser
.
parse_args
()
return
args
...
...
@@ -31,6 +36,7 @@ def get_temp_dir():
temp_dir
=
"/var/tmp"
return
temp_dir
def
wall
(
text
):
if
text
is
None
:
logger
.
error
(
"Incorrect function call"
)
...
...
@@ -48,10 +54,10 @@ def accept():
# Load the saved url
url
=
pickle
.
load
(
open
(
"
%
s/
%
s"
%
(
get_temp_dir
(),
file_name
),
"rb"
))
# Fake data to post so we make urllib2 send a POST instead of a GET
# do POST request to
# do POST request to
req
=
urllib2
.
Request
(
url
,
""
)
rsp
=
urllib2
.
urlopen
(
req
)
rsp
=
urllib2
.
urlopen
(
req
)
# Get the result of the request
success
=
rsp
.
info
()[
'renewal'
]
if
success
is
not
None
or
rsp
.
getcode
()
==
200
:
...
...
@@ -67,6 +73,7 @@ def accept():
print
"Successfull renewal of this vm!"
os
.
remove
(
"
%
s/
%
s"
%
(
get_temp_dir
(),
file_name
))
def
notify
(
url
):
if
os
.
getenv
(
"DISPLAY"
)
and
system
==
'Linux'
or
system
==
'Windows'
:
webbrowser
.
open
(
url
,
new
=
2
,
autoraise
=
True
)
...
...
@@ -74,13 +81,16 @@ def notify(url):
if
os
.
path
.
isfile
(
"
%
s/
%
s"
%
(
get_temp_dir
(),
file_name
)):
logger
.
info
(
"There is on old request already saved"
)
pickle
.
dump
(
url
,
open
(
"
%
s/
%
s"
%
(
get_temp_dir
(),
file_name
),
"wb"
))
wall
(
"This vm is about to time out! Please type vm_renewal command to renew your current process"
)
wall
(
"This virtual machine is going to expire! Please type
\n
"
" vm_renewal
\n
"
"command to keep it running."
)
else
:
raise
StandardError
(
'Not supported system type'
)
raise
Exception
(
'Not supported system type'
)
def
main
():
args
=
pars_arguments
()
notify
(
args
.
url
)
if
__name__
==
'__main__'
:
main
()
\ No newline at end of file
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