| Server IP : 61.19.30.66 / Your IP : 216.73.216.15 Web Server : Apache/2.2.22 (Ubuntu) System : Linux klw 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:39:31 UTC 2014 x86_64 User : www-data ( 33) PHP Version : 5.3.10-1ubuntu3.48 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /usr/share/pyshared/DistUpgrade/ |
Upload File : |
import os
import os.path
import logging
import subprocess
import sys
import gettext
import errno
APPORT_WHITELIST = {
"apt.log": "Aptlog",
"apt-term.log": "Apttermlog",
"apt-clone_system_state.tar.gz": "Aptclonesystemstate.tar.gz",
"history.log": "Historylog",
"lspci.txt": "Lspcitxt",
"main.log": "Mainlog",
"term.log": "Termlog",
"screenlog.0": "Screenlog",
"xorg_fixup.log": "Xorgfixup"
}
def _apport_append_logfiles(report, logdir="/var/log/dist-upgrade/"):
dirname = 'VarLogDistupgrade'
for fname in APPORT_WHITELIST:
f = os.path.join(logdir, fname)
if not os.path.isfile(f) or os.path.getsize(f) == 0:
continue
ident = dirname + APPORT_WHITELIST[fname]
report[ident] = (open(f), )
def apport_crash(type, value, tb):
logging.debug("running apport_crash()")
try:
from apport_python_hook import apport_excepthook
from apport.report import Report
except ImportError, e:
logging.error("failed to import apport python module, can't report bug: %s" % e)
return False
# we pretend we are update-manager
sys.argv[0] = "/usr/bin/update-manager"
apport_excepthook(type, value, tb)
# now add the files in /var/log/dist-upgrade/*
if os.path.exists('/var/crash/_usr_bin_update-manager.0.crash'):
report = Report()
report.setdefault('Tags', 'dist-upgrade')
report['Tags'] += ' dist-upgrade'
_apport_append_logfiles(report)
report.add_to_existing('/var/crash/_usr_bin_update-manager.0.crash')
return True
def apport_pkgfailure(pkg, errormsg):
logging.debug("running apport_pkgfailure() %s: %s", pkg, errormsg)
LOGDIR="/var/log/dist-upgrade/"
s = "/usr/share/apport/package_hook"
# we do not report followup errors from earlier failures
# dpkg messages will not be translated if DPKG_UNTRANSLATED_MESSAGES is
# set which it is by default so check for the English message first
if "dependency problems - leaving unconfigured" in errormsg:
return False
if gettext.dgettext('dpkg', "dependency problems - leaving unconfigured") in errormsg:
return False
# we do not run apport_pkgfailure for full disk errors
if os.strerror(errno.ENOSPC) in errormsg:
logging.debug("dpkg error because of full disk, not reporting against %s " % pkg)
return False
if os.path.exists(s):
args = [s, "-p", pkg]
for fname in APPORT_WHITELIST:
args.extend(["-l", os.path.join(LOGDIR, fname)])
try:
p = subprocess.Popen(args, stdin=subprocess.PIPE)
p.stdin.write("ErrorMessage: %s\n" % errormsg)
p.stdin.close()
#p.wait()
except Exception, e:
logging.warning("Failed to run apport (%s)" % e)
return False
return True
return False
def run_apport():
" run apport, check if we have a display "
if "RELEASE_UPRADER_NO_APPORT" in os.environ:
logging.debug("RELEASE_UPRADER_NO_APPORT env set")
return False
if "DISPLAY" in os.environ:
for p in ["/usr/share/apport/apport-gtk", "/usr/share/apport/apport-qt"]:
if os.path.exists(p):
ret = -1
try:
ret = subprocess.call(p)
except Exception:
logging.exception("Unable to launch '%s' " % p)
return (ret == 0)
elif os.path.exists("/usr/bin/apport-cli"):
try:
return (subprocess.call("/usr/bin/apport-cli") == 0)
except Exception:
logging.exception("Unable to launch '/usr/bin/apport-cli'")
return False
logging.debug("can't find apport")
return False
if __name__ == "__main__":
apport_crash(None, None, None)