fix: logging utf-8 cannot decode
This commit is contained in:
@@ -76,7 +76,8 @@ class PackageInstaller():
|
|||||||
|
|
||||||
# Set up logging configuration
|
# Set up logging configuration
|
||||||
logfile_path = Path(self.log_path, f"{logfile_name}.log")
|
logfile_path = Path(self.log_path, f"{logfile_name}.log")
|
||||||
logging.basicConfig(filename=logfile_path, level=logging.INFO)
|
logging.basicConfig(filename=logfile_path,
|
||||||
|
level=logging.INFO, encoding='utf-8')
|
||||||
|
|
||||||
# Return logger object
|
# Return logger object
|
||||||
return logging.getLogger()
|
return logging.getLogger()
|
||||||
@@ -248,13 +249,16 @@ class PackageInstaller():
|
|||||||
result = subprocess.run(cmd_list, timeout=timeout,
|
result = subprocess.run(cmd_list, timeout=timeout,
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
if result.returncode != 0:
|
try:
|
||||||
log.error('Command failed: %s', cmd_list)
|
if result.returncode != 0:
|
||||||
log.error('stdout: %s', result.stdout.decode())
|
log.error('Command failed: %s', cmd_list)
|
||||||
log.error('stderr: %s', result.stderr.decode(errors='ignore'))
|
log.error('stdout: %s', result.stdout.decode())
|
||||||
else:
|
log.error('stderr: %s', result.stderr.decode(errors='ignore'))
|
||||||
log.info('Command succeeded: %s', cmd_list)
|
else:
|
||||||
log.info('stdout: %s', result.stdout.decode())
|
log.info('Command succeeded: %s', cmd_list)
|
||||||
|
log.info('stdout: %s', result.stdout.decode())
|
||||||
|
except:
|
||||||
|
...
|
||||||
# return the command list, return code, stdout, and stderr as a tuple
|
# return the command list, return code, stdout, and stderr as a tuple
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user