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
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
c9e24295
authored
Jun 13, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
random fixes
parent
97b5a74b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
10 deletions
+17
-10
agent.py
+16
-9
utils.py
+1
-1
No files found.
agent.py
View file @
c9e24295
...
...
@@ -154,11 +154,11 @@ class Context(object):
@staticmethod
def
cleanup
():
if
system
==
'Linux'
:
filelist
=
(
(
filelist
=
(
[
'/root/.bash_history'
'/home/cloud/.bash_history'
'/root/.ssh'
'/home/cloud/.ssh'
)
'/home/cloud/.ssh'
]
+
glob
(
'/etc/ssh/ssh_host_*'
))
for
f
in
filelist
:
rmtree
(
f
,
ignore_errors
=
True
)
...
...
@@ -179,13 +179,13 @@ class Context(object):
pass
@staticmethod
def
update
(
data
):
def
update
(
data
,
uuid
):
cur_dir
=
sys
.
path
[
0
]
new_dir
=
cur_dir
+
'.new'
old_dir
=
cur_dir
+
'.old'
f
=
StringIO
(
decodestring
(
data
))
try
:
tar
=
tarfile
.
TarFile
.
open
(
"dummy"
,
fileobj
=
f
,
mode
=
'r|
bz2
'
)
tar
=
tarfile
.
TarFile
.
open
(
"dummy"
,
fileobj
=
f
,
mode
=
'r|
gz
'
)
tar
.
extractall
(
new_dir
)
except
tarfile
.
ReadError
as
e
:
logger
.
error
(
e
)
...
...
@@ -213,11 +213,20 @@ class Context(object):
if
'
%
'
not
in
x
[
'addr'
]])
return
args
@staticmethod
def
get_agent_version
():
try
:
with
open
(
'version.txt'
)
as
f
:
return
f
.
readline
()
except
IOError
:
return
None
class
SerialLineReceiver
(
SerialLineReceiverBase
):
def
connectionMade
(
self
):
self
.
send_command
(
command
=
'agent_started'
,
args
=
{})
self
.
send_command
(
command
=
'agent_started'
,
args
=
{
'version'
:
Context
.
get_agent_version
()})
def
shutdown
():
self
.
connectionLost2
(
'shutdown'
)
...
...
@@ -239,9 +248,7 @@ class SerialLineReceiver(SerialLineReceiverBase):
self
.
lc
.
start
(
5
,
now
=
False
)
def
send_status
(
self
):
import
psutil
# TODO ez azért kell itt van importálva, mert
# windows alatt kilépéskor kressel tőle a python
# így a service azt hiszi, hogy nem indult el rendesen
import
psutil
disk_usage
=
{(
disk
.
device
.
replace
(
'/'
,
'_'
)):
psutil
.
disk_usage
(
disk
.
mountpoint
)
.
percent
for
disk
in
psutil
.
disk_partitions
()}
...
...
utils.py
View file @
c9e24295
...
...
@@ -41,7 +41,7 @@ class SerialLineReceiverBase(LineReceiver, object):
try
:
self
.
handle_command
(
command
,
args
)
except
Exception
as
e
:
logging
.
e
rror
(
u'Unhandled exception:
%
s'
%
e
)
logging
.
e
xception
(
u'Unhandled exception: '
)
elif
response
is
not
None
and
isinstance
(
response
,
unicode
):
logging
.
debug
(
'received reply:
%
s (
%
s)'
%
(
response
,
args
))
self
.
handle_response
(
response
,
args
)
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