Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def cb_log(level, line):
if not (level & _logmask):
return
if level & pyalpm.LOG_ERROR:
line = "ERROR: " + line
elif level & pyalpm.LOG_WARNING:
line = "WARNING: " + line
elif level & pyalpm.LOG_DEBUG:
line = "DEBUG: " + line
elif level & pyalpm.LOG_FUNCTION:
line = "FUNC: " + line
sys.stderr.write(line)
if "command failed to execute correctly" in line:
# We get this warning sometimes (I think it's when Cnchi installs
# the kernel package). It seems to be harmless, we'll log it as
# a debug message instead of an error message
logging.debug(line)
return
if level & pyalpm.LOG_ERROR == pyalpm.LOG_ERROR:
logging.error(line)
elif level & pyalpm.LOG_WARNING == pyalpm.LOG_WARNING:
# Alpm outputs non-english log messages so we can't target certain
# useless warnings. I think most of the warnings are useless anyway.
# We can revisit this later if need be.
logging.debug(line)
elif level & pyalpm.LOG_DEBUG == pyalpm.LOG_DEBUG:
# There are a lot of "extracting" messages (not very useful), so we
# do not log them.
if " error " in line and "error 0" not in line:
logging.debug(line)
elif "extracting" not in line and "extract: skipping dir extraction" not in line:
logging.debug(line)
#except:
# _line = str(_line, encoding='latin-1').strip("\n")
if not (level & _logmask):
return
if level & pyalpm.LOG_ERROR:
ErrorDialog.format_secondary_text("ERROR: "+line)
response = ErrorDialog.run()
if response:
ErrorDialog.hide()
#t.release()
elif level & pyalpm.LOG_WARNING:
WarningDialog.format_secondary_text("WARNING: "+line)
response = WarningDialog.run()
if response:
WarningDialog.hide()
elif level & pyalpm.LOG_DEBUG:
line = "DEBUG: " + line
print(line)
elif level & pyalpm.LOG_FUNCTION:
line = "FUNC: " + line
print(line)
#sys.stderr.write(line)