Skip to content

Commit

Permalink
Fail silently if email in web-server config is missing and add verbos…
Browse files Browse the repository at this point in the history
…ity to email
  • Loading branch information
srbdev committed Oct 22, 2015
1 parent f14e92e commit 3004fab
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 52 deletions.
9 changes: 5 additions & 4 deletions packages/slycat/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
def send_error(subject, body):
import slycat.web.server

echo = subprocess.Popen(["echo", "\"%s\"" % body], stdout=subprocess.PIPE)
mail = subprocess.Popen(["mail", "-s", "\"%s %s\"" % (slycat.web.server.config["slycat-web-server"]["error-email"]["subject"], subject), slycat.web.server.config["slycat-web-server"]["error-email"]["address"]], stdin=echo.stdout, stdout=subprocess.PIPE)
if "error-email" in slycat.web.server.config["slycat-web-server"]:
echo = subprocess.Popen(["echo", "\"%s\"" % body], stdout=subprocess.PIPE)
mail = subprocess.Popen(["mail", "-s", "\"%s %s\"" % (slycat.web.server.config["slycat-web-server"]["error-email"]["subject"], subject), slycat.web.server.config["slycat-web-server"]["error-email"]["address"]], stdin=echo.stdout, stdout=subprocess.PIPE)

echo.stdout.close()
mail.communicate()
echo.stdout.close()
mail.communicate()
2 changes: 1 addition & 1 deletion packages/slycat/web/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def put_model_file(database, model, aid, value, content_type, input=False):
def get_model_file(database, model, aid):
artifact = model.get("artifact:%s" % aid, None)
if artifact is None:
slycat.email.send_error("slycat.web.server.__init__.py get_model_file", "cherrypy.HTTPError 404")
slycat.email.send_error("slycat.web.server.__init__.py get_model_file", "cherrypy.HTTPError 404 artifact is None for aid: %s" % aid)
raise cherrypy.HTTPError(404)
artifact_type = model["artifact-types"][aid]
if artifact_type != "file":
Expand Down
4 changes: 2 additions & 2 deletions packages/slycat/web/server/database/couchdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ def get(self, type, id):
try:
document = self[id]
except couchdb.client.http.ResourceNotFound:
slycat.email.send_error("slycat.web.server.database.couchdb.py get", "cherrypy.HTTPError 404")
slycat.email.send_error("slycat.web.server.database.couchdb.py get", "cherrypy.HTTPError 404 couchdb.client.http.ResourceNotFound")
raise cherrypy.HTTPError(404)
if document["type"] != type:
slycat.email.send_error("slycat.web.server.database.couchdb.py get", "cherrypy.HTTPError 404")
slycat.email.send_error("slycat.web.server.database.couchdb.py get", "cherrypy.HTTPError 404 document type %s is different than input type: %s" % (document["type"], type))
raise cherrypy.HTTPError(404)
return document

Expand Down
Loading

0 comments on commit 3004fab

Please sign in to comment.