logging of gridftp errors
[qcg-portal.git] / filex / ftp.py
index d83a55c..2b09d3e 100644 (file)
@@ -4,14 +4,17 @@ from itertools import chain
 import os
 import re
 from threading import Event
-from django.utils.http import urlunquote
 
+from django.utils.http import urlunquote
 from django.utils.timezone import localtime, UTC
 from gridftp import FTPClient, Buffer, HandleAttr, OperationAttr
 
 
 class FTPError(Exception):
-    pass
+    def __init__(self, message, verbose=None, *args, **kwargs):
+        super(FTPError, self).__init__(message, *args, **kwargs)
+
+        self.verbose = verbose
 
 
 class FTPOperation:
@@ -67,14 +70,11 @@ class FTPOperation:
         self._end.clear()
 
         if self._error is not None:
-            # TODO logging
-            print 'GridFTP ERROR:', self._error
-
             match = re.search(r'A system call failed: (.*)$', self._error.replace('\r\n', '\n'), re.MULTILINE)
 
             msg = match.groups()[0] if match else "Unknown error"
 
-            raise FTPError(msg)
+            raise FTPError(msg, self._error)
 
     def listing(self, url):
         self.cli.verbose_list(url, self._done, None, self.op_attr)