Rev 42: Handle errors when submitting pending. in http://people.samba.org/bzr/jelmer/bzr-cia/trunk

Jelmer Vernooij jelmer at samba.org
Fri Oct 10 15:08:33 BST 2008


At http://people.samba.org/bzr/jelmer/bzr-cia/trunk

------------------------------------------------------------
revno: 42
revision-id: jelmer at samba.org-20081010140833-emso5966ifaour06
parent: jelmer at samba.org-20081010140514-nz47wfw72o8b7juu
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Fri 2008-10-10 16:08:33 +0200
message:
  Handle errors when submitting pending.
=== modified file '__init__.py'
--- a/__init__.py	2008-10-10 14:05:14 +0000
+++ b/__init__.py	2008-10-10 14:08:33 +0000
@@ -177,6 +177,27 @@
             print config.get_user_option('cia_project')
 
 
+def submit_pending(config):
+    import os
+    server = cia_connect(config)
+    cache_dir = cia_cache_dir()
+    for revid in os.listdir(cache_dir):
+        path = os.path.join(cache_dir, revid)
+        msg = open(path, 'r').read()
+        try:
+            server.hub.deliver(msg)
+        except xmlrpclib.ProtocolError, e:
+            error = e.errmsg
+        except socket.gaierror, (_, errmsg):
+            error = errmsg
+        except socket.error, (_, errmsg):
+            error = errmsg
+        if error is not None:
+            warning("Submitting %s failed: %s" % (revid, error))
+        else:
+            os.path.remove(path)
+
+
 class cmd_cia_submit(Command):
     """Submit a revision to CIA
 
@@ -193,14 +214,7 @@
             raise BzrCommandError("--pending and specifying a branch are mutually exclusive")
         if pending:
             from bzrlib.config import GlobalConfig
-            import os
-            server = cia_connect(GlobalConfig())
-            cache_dir = cia_cache_dir()
-            for revid in os.listdir(cache_dir):
-                path = os.path.join(cache_dir, revid)
-                msg = open(path, 'r').read()
-                server.hub.deliver(msg)
-                os.path.remove(path)
+            submit_pending(GlobalConfig())
         else:
             if branch is not None:
                 branch = "."




More information about the bazaar-commits mailing list