Commit c88ceaa3 by Szeberényi Imre

registry fix

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