Commit c9e24295 by Bach Dániel

random fixes

parent 97b5a74b
...@@ -154,11 +154,11 @@ class Context(object): ...@@ -154,11 +154,11 @@ class Context(object):
@staticmethod @staticmethod
def cleanup(): def cleanup():
if system == 'Linux': if system == 'Linux':
filelist = (( filelist = ([
'/root/.bash_history' '/root/.bash_history'
'/home/cloud/.bash_history' '/home/cloud/.bash_history'
'/root/.ssh' '/root/.ssh'
'/home/cloud/.ssh') '/home/cloud/.ssh']
+ glob('/etc/ssh/ssh_host_*')) + glob('/etc/ssh/ssh_host_*'))
for f in filelist: for f in filelist:
rmtree(f, ignore_errors=True) rmtree(f, ignore_errors=True)
...@@ -179,13 +179,13 @@ class Context(object): ...@@ -179,13 +179,13 @@ class Context(object):
pass pass
@staticmethod @staticmethod
def update(data): def update(data, uuid):
cur_dir = sys.path[0] cur_dir = sys.path[0]
new_dir = cur_dir + '.new' new_dir = cur_dir + '.new'
old_dir = cur_dir + '.old' old_dir = cur_dir + '.old'
f = StringIO(decodestring(data)) f = StringIO(decodestring(data))
try: 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) tar.extractall(new_dir)
except tarfile.ReadError as e: except tarfile.ReadError as e:
logger.error(e) logger.error(e)
...@@ -213,11 +213,20 @@ class Context(object): ...@@ -213,11 +213,20 @@ class Context(object):
if '%' not in x['addr']]) if '%' not in x['addr']])
return args return args
@staticmethod
def get_agent_version():
try:
with open('version.txt') as f:
return f.readline()
except IOError:
return None
class SerialLineReceiver(SerialLineReceiverBase): class SerialLineReceiver(SerialLineReceiverBase):
def connectionMade(self): def connectionMade(self):
self.send_command(command='agent_started', self.send_command(
args={}) command='agent_started',
args={'version': Context.get_agent_version()})
def shutdown(): def shutdown():
self.connectionLost2('shutdown') self.connectionLost2('shutdown')
...@@ -239,9 +248,7 @@ class SerialLineReceiver(SerialLineReceiverBase): ...@@ -239,9 +248,7 @@ class SerialLineReceiver(SerialLineReceiverBase):
self.lc.start(5, now=False) self.lc.start(5, now=False)
def send_status(self): def send_status(self):
import psutil # TODO ez azért kell itt van importálva, mert import psutil
# windows alatt kilépéskor kressel tőle a python
# így a service azt hiszi, hogy nem indult el rendesen
disk_usage = {(disk.device.replace('/', '_')): disk_usage = {(disk.device.replace('/', '_')):
psutil.disk_usage(disk.mountpoint).percent psutil.disk_usage(disk.mountpoint).percent
for disk in psutil.disk_partitions()} for disk in psutil.disk_partitions()}
......
...@@ -41,7 +41,7 @@ class SerialLineReceiverBase(LineReceiver, object): ...@@ -41,7 +41,7 @@ class SerialLineReceiverBase(LineReceiver, object):
try: try:
self.handle_command(command, args) self.handle_command(command, args)
except Exception as e: except Exception as e:
logging.error(u'Unhandled exception: %s' % e) logging.exception(u'Unhandled exception: ')
elif response is not None and isinstance(response, unicode): elif response is not None and isinstance(response, unicode):
logging.debug('received reply: %s (%s)' % (response, args)) logging.debug('received reply: %s (%s)' % (response, args))
self.handle_response(response, args) self.handle_response(response, args)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment