Commit c88ceaa3 by Szeberényi Imre

registry fix

parent 3ad709c2
...@@ -18,8 +18,9 @@ formatter = logging.Formatter( ...@@ -18,8 +18,9 @@ formatter = logging.Formatter(
"%(asctime)s - %(name)s [%(levelname)s] %(message)s") "%(asctime)s - %(name)s [%(levelname)s] %(message)s")
fh.setFormatter(formatter) fh.setFormatter(formatter)
logger.addHandler(fh) logger.addHandler(fh)
level = os.environ.get('LOGLEVEL', 'DEBUG') #level = os.environ.get('LOGLEVEL', 'DEBUG')
logger.setLevel(level)
logger.setLevel('INFO')
logger.info("%s loaded", __file__) logger.info("%s loaded", __file__)
......
...@@ -52,9 +52,8 @@ logging.basicConfig( ...@@ -52,9 +52,8 @@ logging.basicConfig(
datefmt="%d/%b/%Y %H:%M:%S", datefmt="%d/%b/%Y %H:%M:%S",
) )
logger = logging.getLogger() logger = logging.getLogger()
level = environ.get('LOGLEVEL', 'INFO') #level = environ.get('LOGLEVEL', 'DEBUG')
logger.setLevel('INFO')
logger.setLevel(level)
class SerialLineReceiver(SerialLineReceiverBase): class SerialLineReceiver(SerialLineReceiverBase):
......
...@@ -39,7 +39,7 @@ class SerialLineReceiverBase(LineReceiver, object): ...@@ -39,7 +39,7 @@ class SerialLineReceiverBase(LineReceiver, object):
raise NotImplementedError("Subclass must implement abstract method") raise NotImplementedError("Subclass must implement abstract method")
def lineReceived(self, data): def lineReceived(self, data):
logger.debug("lineReceived: %s", data) # logger.debug("lineReceived: %s", data)
if (isinstance(data, unicode)): if (isinstance(data, unicode)):
data = data.strip('\0') data = data.strip('\0')
else: else:
......
No preview for this file type
...@@ -7,7 +7,7 @@ from os.path import join ...@@ -7,7 +7,7 @@ from os.path import join
import logging import logging
import tarfile import tarfile
from io import StringIO from io import BytesIO
from base64 import b64decode from base64 import b64decode
from hashlib import md5 from hashlib import md5
from datetime import datetime from datetime import datetime
...@@ -101,7 +101,7 @@ class Context(BaseContext): ...@@ -101,7 +101,7 @@ class Context(BaseContext):
@staticmethod @staticmethod
def _update_registry(dir, executable): def _update_registry(dir, executable):
# HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\circle-agent # HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\circle-agent
from _winreg import (OpenKeyEx, SetValueEx, QueryValueEx, from winreg import (OpenKeyEx, SetValueEx, QueryValueEx,
HKEY_LOCAL_MACHINE, KEY_ALL_ACCESS) HKEY_LOCAL_MACHINE, KEY_ALL_ACCESS)
with OpenKeyEx(HKEY_LOCAL_MACHINE, with OpenKeyEx(HKEY_LOCAL_MACHINE,
r'SYSTEM\CurrentControlSet\services\circle-agent', r'SYSTEM\CurrentControlSet\services\circle-agent',
...@@ -115,18 +115,19 @@ class Context(BaseContext): ...@@ -115,18 +115,19 @@ class Context(BaseContext):
def update(filename, executable, checksum, uuid): def update(filename, executable, checksum, uuid):
with open(filename, "r") as f: with open(filename, "r") as f:
data = f.read() data = f.read()
local_checksum = md5(data).hexdigest() logger.debug("type(data) %s" % type(data))
local_checksum = md5(data.encode()).hexdigest()
if local_checksum != checksum: if local_checksum != checksum:
raise Exception("Checksum missmatch the file is damaged.") raise Exception("Checksum missmatch the file is damaged.")
decoded = StringIO(b64decode(data)) decoded = BytesIO(b64decode(data))
try: try:
tar = tarfile.TarFile.open("dummy", fileobj=decoded, mode='r|gz') tar = tarfile.TarFile.open("dummy", fileobj=decoded, mode='r|gz')
tar.extractall(working_directory) tar.extractall(working_directory)
except tarfile.ReadError as e: except tarfile.ReadError as e:
logger.error(e) logger.error(e)
logger.info("Transfer completed!") logger.info("Transfer completed!")
Context._update_registry(working_directory, executable) old_exe = Context._update_registry(working_directory, executable)
logger.info('Updated') logger.info('%s Updated', old_exe)
reactor.stop() reactor.stop()
@staticmethod @staticmethod
......
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