Commits

Kevin Dangoor  committed d0be5b5

add deploy_error

  • Participants
  • Parent commits fec5ee7

Comments (0)

Files changed (1)

File backend/python/bespin/deploy.py

 
 import os
 from urllib import quote
+from traceback import format_exc
+import logging
 
 from simplejson import dumps, loads
 from omnisync.main import OmniSync
 from bespin.filesystem import get_project
 from bespin.database import User
 
+
+log = logging.getLogger("bespin.deploy")
+
 # Ideally, we would have a better "remote server" abstraction than this!
 class DeploymentKeyChain(KeyChain):
     """A keychain with deployment-specific information."""
     
 def deploy_error(qi, e):
     """Handles errors that come up during deployment."""
-    print e
+    log.debug("Handling deploy error: %s", e)
+    s = database._get_session()
+    user = qi.message['user']
+    # if the user hadn't already been looked up, go ahead and pull
+    # them out of the database
+    if isinstance(user, basestring):
+        user = User.find_user(user)
+    else:
+        s.add(user)
+    
+    # if we didn't find the user in the database, there's not much
+    # we can do.
+    if user:
+        # it looks like a programming error and we
+        # want more information
+        tb = format_exc()
+        message = dict(jobid=qi.id, output=tb, error=True)
+        message['asyncDone'] = True
+        retval = Message(user_id=user.id, message=dumps(message))
+        s.add(retval)
     
 def run_deploy(user, project, kcpass):
     """Add the deployment request to the worker queue."""
         quote(credentials['password'], safe=""), 
         quote(pdo.remote_host, safe=""),
         quote(pdo.remote_directory))
-    print "DU: ", desturl
         
     try:
         os.chdir(project.location)