The url validation code wasn't working on python2.4
authorDiane Trout <diane@caltech.edu>
Tue, 23 Jun 2009 23:46:49 +0000 (23:46 +0000)
committerDiane Trout <diane@caltech.edu>
Tue, 23 Jun 2009 23:46:49 +0000 (23:46 +0000)
the problem where rpc exception are being eaten by something is getting
really annoying.

htsworkflow/automation/copier.py
test/test_copier.py

index 775e6c61aa3718c99775e1d31f1ac880e61b5c2d..0f526948615996c7d80ac8c61834b5da81c798aa 100644 (file)
@@ -220,6 +220,7 @@ class CopierBot(rpc.XmlRpcBot):
         start our copy
         """
         # Note, args comes in over the network, so don't trust it.
+        logging.debug("Arguments to startCopy %s" % (unicode(args),))
         copy_urls = []
         for a in args:
             clean_url = self.validate_url(a)
@@ -293,12 +294,19 @@ class CopierBot(rpc.XmlRpcBot):
         return reply
 
     def validate_url(self, url):
-        split_url = urlparse.urlsplit(url)
+        user_url = urlparse.urlsplit(url)
+        user_scheme = user_url[0]
+        user_netloc = user_url[1]
+        user_path = user_url[2]
+
         for source in self.sources:
-            split_source = urlparse.urlsplit(source)
-            if (split_url.scheme == split_source.scheme) and \
-               (split_url.netloc == split_source.netloc) and \
-               (split_url.path.startswith(split_source.path)):
+            source_url = urlparse.urlsplit(source)
+            source_scheme = source_url[0]
+            source_netloc = source_url[1]
+            source_path = source_url[2]
+            if (user_scheme == source_scheme) and \
+               (user_netloc == source_netloc) and \
+               (user_path.startswith(source_path)):
                return url
         return None
 
index da4834010d17c18d06226fa9070ac6a3c8f295c6..3a0890f9d14fa2ef1e0b30fc94917b393caf8226 100644 (file)
@@ -24,7 +24,7 @@ jid: copier@example.fake
 password: badpassword
 authorized_users: user1@example.fake user2@example.fake
 rsync_password_file: ~/.sequencer
-rsync_sources: rsync://localhost/tmp/sequencer_source
+rsync_sources: rsync://localhost/tmp/sequencer_source rsync://user@server:1234/other_sequencer
 rsync_destination: /tmp/sequencer_destination
 notify_users: user3@example.fake
 # who to run to
@@ -57,6 +57,10 @@ notify_users: user3@example.fake
         self.failUnlessEqual(
           c.validate_url('rsync://localhost/tmp/sequencer_source/bleem'), 
           'rsync://localhost/tmp/sequencer_source/bleem')
+        self.failUnlessEqual(
+          c.validate_url('rsync://user@server:1234/other_sequencer'),
+          'rsync://user@server:1234/other_sequencer')
+
 
     def test_dirlist_filter(self):
        """