add error reporting tool
git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@429 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
93
client/equo
93
client/equo
@@ -97,31 +97,76 @@ if len(options) < 1 or string.join(options).find("--help") != -1 or string.join(
|
||||
entropyTools.print_error("not enough parameters")
|
||||
sys.exit(1)
|
||||
|
||||
# sync mirrors tool
|
||||
elif (options[0] == "update") or (options[0] == "repoinfo") or (options[0] == "status"):
|
||||
if options[0] == "update":
|
||||
entropyTools.applicationLockCheck("update")
|
||||
rc = equoTools.repositories(options)
|
||||
sys.exit(rc)
|
||||
try:
|
||||
# sync mirrors tool
|
||||
if (options[0] == "update") or (options[0] == "repoinfo") or (options[0] == "status"):
|
||||
if options[0] == "update":
|
||||
entropyTools.applicationLockCheck("update")
|
||||
rc = equoTools.repositories(options)
|
||||
sys.exit(rc)
|
||||
|
||||
elif (options[0] == "search") or (options[0] == "install") or (options[0] == "remove") or (options[0] == "deptest"):
|
||||
if options[0] == "install":
|
||||
entropyTools.applicationLockCheck("install")
|
||||
elif options[0] == "remove":
|
||||
entropyTools.applicationLockCheck("remove")
|
||||
rc = equoTools.package(options)
|
||||
sys.exit(rc)
|
||||
elif (options[0] == "search") or (options[0] == "install") or (options[0] == "remove") or (options[0] == "deptest"):
|
||||
if options[0] == "install":
|
||||
entropyTools.applicationLockCheck("install")
|
||||
elif options[0] == "remove":
|
||||
entropyTools.applicationLockCheck("remove")
|
||||
rc = equoTools.package(options)
|
||||
sys.exit(rc)
|
||||
|
||||
elif (options[0] == "query"):
|
||||
rc = equoTools.query(options[1:])
|
||||
sys.exit(rc)
|
||||
elif (options[0] == "query"):
|
||||
rc = equoTools.query(options[1:])
|
||||
sys.exit(rc)
|
||||
|
||||
elif (options[0] == "database"):
|
||||
entropyTools.applicationLockCheck("database")
|
||||
rc = equoTools.database(options[1:])
|
||||
sys.exit(rc)
|
||||
elif (options[0] == "database"):
|
||||
entropyTools.applicationLockCheck("database")
|
||||
rc = equoTools.database(options[1:])
|
||||
sys.exit(rc)
|
||||
|
||||
elif (options[0] == "cleanup"):
|
||||
entropyTools.applicationLockCheck("cleanup")
|
||||
entropyTools.cleanup([ etpConst['packagestmpdir'], etpConst['logdir'], etpConst['entropyunpackdir'], etpConst['packagesbindir'] ])
|
||||
sys.exit(0)
|
||||
elif (options[0] == "cleanup"):
|
||||
entropyTools.applicationLockCheck("cleanup")
|
||||
entropyTools.cleanup([ etpConst['packagestmpdir'], etpConst['logdir'], etpConst['entropyunpackdir'], etpConst['packagesbindir'] ])
|
||||
sys.exit(0)
|
||||
except:
|
||||
from entropyTools import askquestion
|
||||
from remoteTools import getOnlineContent, reportApplicationError
|
||||
import string
|
||||
print_error(darkred("Hi. My name is Bug Reporter. I am sorry to inform you that Equo crashed. Well, you know, shit happens."))
|
||||
print_error(darkred("But there's something you could do to help Equo to be a better application."))
|
||||
print_error(darkgreen("Now I am showing you what happened. Don't panic, I'm here to help you. Suddenly happened:"))
|
||||
print
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
try:
|
||||
ferror = open("/tmp/equoerror.txt","w")
|
||||
traceback.print_exc(file = ferror)
|
||||
ferror.flush()
|
||||
ferror.close()
|
||||
f = open("/tmp/equoerror.txt","r")
|
||||
errorText = f.readlines()
|
||||
f.close()
|
||||
errorText = string.join(errorText," ")
|
||||
except:
|
||||
print
|
||||
print_error(darkred("Oh well, I cannot even write to /tmp. So, please copy the error and mail lxnay@sabayonlinux.org."))
|
||||
sys.exit(1)
|
||||
print
|
||||
print_error(blue("Ok, back here. Let me see if you are connected to the Internet. Yes, I am blue now, so?"))
|
||||
conntest = getOnlineContent("http://svn.sabayonlinux.org")
|
||||
if (conntest != False):
|
||||
print_error(darkgreen("Of course you are on the Internet..."))
|
||||
rc = askquestion(" Erm... Can I send the error to my creators so they can fix me?")
|
||||
if rc == "No":
|
||||
print_error(darkgreen("Ok, ok ok ok... Sorry!"))
|
||||
sys.exit(2)
|
||||
else:
|
||||
print_error(darkgreen("Gosh, you aren't! Well, I wrote the error to /tmp/equoerror.txt. When you want, mail the file to lxnay@sabayonlinux.org."))
|
||||
sys.exit(3)
|
||||
|
||||
# ok, come on!
|
||||
result = reportApplicationError(errorText)
|
||||
if (result != False):
|
||||
print_error(darkgreen("Thank you very much. The error has been reported and hopefully, the problem will be solved as soon as possible."))
|
||||
else:
|
||||
print_error(darkred("Ugh. Cannot send the report. I saved the error to /tmp/equoerror.txt. When you want, mail the file to lxnay@sabayonlinux.org."))
|
||||
sys.exit(4)
|
||||
|
||||
11
handlers/error_report.php
Normal file
11
handlers/error_report.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
$header = "MIME-Version: 1.0\r\n";
|
||||
$header .= "Content-type: text/html; charset=iso-8859-1\r\n";
|
||||
$arch = $_GET['arch'];
|
||||
$mail = "lxnay@sabayonlinux.org";
|
||||
$subject = "Entropy Error Reporting Handler";
|
||||
$message = '<html><head><title>Entropy Error Reporting Handler</title></head><body><p>';
|
||||
$message .= $_GET['stacktrace'] . "<br><br><br> Architecture: " . $arch . "</p></body></html>";
|
||||
print_r($message);
|
||||
mail($mail,$subject,$message, $header);
|
||||
?>
|
||||
@@ -641,7 +641,7 @@ def packages(options):
|
||||
|
||||
print_error(yellow(" * ")+red("packages: Exception caught: ")+str(e)+red(" . Showing traceback:"))
|
||||
import traceback
|
||||
traceback.print_stack()
|
||||
traceback.print_exc()
|
||||
|
||||
# trap CTRL+C
|
||||
if (str(e) == "100"):
|
||||
|
||||
@@ -384,6 +384,7 @@ else:
|
||||
# Handlers used by entropy to run and retrieve data remotely, using php helpers
|
||||
etpHandlers = {
|
||||
'md5sum': "md5sum.php?arch="+ETP_ARCH_CONST+"&package=", # md5sum handler
|
||||
'errorsend': "http://svn.sabayonlinux.org/entropy/handlers/error_report.php?arch="+ETP_ARCH_CONST+"&stacktrace=",
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ def print_error(msg, back = False):
|
||||
if (back):
|
||||
writechar("\r"+red(">>")+" "+msg)
|
||||
return
|
||||
print green(">>")+" "+msg
|
||||
print red(">>")+" "+msg
|
||||
|
||||
def print_info(msg, back = False):
|
||||
writechar("\r"+_cleanline+"\r")
|
||||
|
||||
@@ -27,6 +27,7 @@ from entropyConstants import *
|
||||
from clientConstants import *
|
||||
from outputTools import *
|
||||
import entropyTools
|
||||
import string
|
||||
|
||||
# Logging initialization
|
||||
import logTools
|
||||
@@ -108,6 +109,28 @@ def getOnlineContent(url):
|
||||
except:
|
||||
return False
|
||||
|
||||
# Error reporting function
|
||||
# @input: error string (please use repr())
|
||||
# @returns bool: True if ok. False if not.
|
||||
# @returns False: if the file is not found
|
||||
def reportApplicationError(errorstring):
|
||||
remoteLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"reportApplicationError: called. Requested string -> "+str(errorstring))
|
||||
outstring = ""
|
||||
for char in errorstring:
|
||||
if char == " ":
|
||||
char = "%20"
|
||||
outstring += char
|
||||
outstring = outstring.split("\n")
|
||||
outstring = string.join(outstring,"<br>")
|
||||
url = etpHandlers['errorsend']+outstring
|
||||
# now pray the server
|
||||
try:
|
||||
file = urllib2.urlopen(url)
|
||||
result = file.readlines()
|
||||
return result
|
||||
except:
|
||||
return False
|
||||
|
||||
###################################################
|
||||
# HTTP/FTP equo INTERNAL FUNCTIONS
|
||||
###################################################
|
||||
|
||||
Reference in New Issue
Block a user