From a29da1f72ea6c21b9dc836b5e440b729a9a9c6bc Mon Sep 17 00:00:00 2001 From: Florian Roth Date: Sat, 14 Apr 2018 12:42:47 +0200 Subject: [PATCH] Error fix in loki-upgrader --- lib/lokilogger.py | 2 +- loki-upgrader.py | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/lokilogger.py b/lib/lokilogger.py index 8ea4e91f..6512050a 100644 --- a/lib/lokilogger.py +++ b/lib/lokilogger.py @@ -14,7 +14,7 @@ import socket from helpers import removeNonAsciiDrop -__version__ = '0.27.5' +__version__ = '0.28.0' # Logger Class ----------------------------------------------------------------- class LokiLogger(): diff --git a/loki-upgrader.py b/loki-upgrader.py index 09a69c88..8bbe1408 100644 --- a/loki-upgrader.py +++ b/loki-upgrader.py @@ -160,13 +160,22 @@ def update_loki(self): try: # Create file if not present - os.makedirs(os.path.basename(targetFile)) + if not os.path.exists(os.path.dirname(targetFile)): + os.makedirs(os.path.dirname(targetFile)) + except Exception as e: + if self.debug: + self.logger.log("DEBUG", "Upgrader", "Cannot create dir name '%s'" % os.path.dirname(targetFile)) + traceback.print_exc() + + try: # Create target file target = file(targetFile, "wb") with source, target: - shutil.copyfileobj(source, target) + shutil.copyfileobj(source, target) + if self.debug: + self.logger.log("DEBUG", "Upgrader", "Successfully extracted '%s'" % targetFile) except Exception as e: - self.logger.log("ERROR", "Upgrader", "Cannot extract %s" % targetFile) + self.logger.log("ERROR", "Upgrader", "Cannot extract '%s'" % targetFile) if self.debug: traceback.print_exc()