Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Public Attributes | Static Public Attributes
storage.shepherd.byteio.ByteIOBackend Class Reference

List of all members.

Public Member Functions

def __init__
def copyTo
def copyFrom
def prepareToGet
def prepareToPut
def remove
def list
def getAvailableSpace
def generateLocalID
def matchProtocols
def notify
def checksum

Public Attributes

 file_arrived
 ns
 ssl_config
 datadir
 transferdir
 turlprefix
 idstore

Static Public Attributes

list public_request_names = ['notify']
list supported_protocols = ['byteio']

Detailed Description

Definition at line 13 of file byteio.py.


Constructor & Destructor Documentation

def storage.shepherd.byteio.ByteIOBackend.__init__ (   self,
  backendcfg,
  ns_uri,
  file_arrived,
  ssl_config 
)

Definition at line 18 of file byteio.py.

00018 
00019     def __init__(self, backendcfg, ns_uri, file_arrived, ssl_config):
00020         self.file_arrived = file_arrived
00021         self.ns = arc.NS('she', ns_uri)
00022         self.ssl_config = ssl_config
00023         self.datadir = str(backendcfg.Get('StoreDir'))
00024         self.transferdir = str(backendcfg.Get('TransferDir'))
00025         self.turlprefix = str(backendcfg.Get('TURLPrefix'))
00026         if not os.path.exists(self.datadir):
00027             os.mkdir(self.datadir)
00028         log.msg(arc.VERBOSE, "ByteIOBackend datadir:", self.datadir)
00029         if not os.path.exists(self.transferdir):
00030             os.mkdir(self.transferdir)
00031         else:
00032             for filename in os.listdir(self.transferdir):
00033                 os.remove(os.path.join(self.transferdir, filename))
00034         log.msg(arc.VERBOSE, "ByteIOBackend transferdir:", self.transferdir)
00035         self.idstore = {}


Member Function Documentation

def storage.shepherd.byteio.ByteIOBackend.checksum (   self,
  localID,
  checksumType 
)

Definition at line 108 of file byteio.py.

00108 
00109     def checksum(self, localID, checksumType):
00110         return create_checksum(file(os.path.join(self.datadir, localID), 'rb'), checksumType)

Here is the call graph for this function:

def storage.shepherd.byteio.ByteIOBackend.copyFrom (   self,
  localID,
  turl,
  protocol 
)

Definition at line 42 of file byteio.py.

00042 
00043     def copyFrom(self, localID, turl, protocol):
00044         # TODO: download to a separate file, and if checksum OK, then copy the file 
00045         f = file(os.path.join(self.datadir, localID), 'wb')
00046         log.msg(arc.VERBOSE, self.turlprefix, 'Downloading file from', turl)
00047         download_from_turl(turl, protocol, f, ssl_config = self.ssl_config)
00048         f.close()

Here is the call graph for this function:

def storage.shepherd.byteio.ByteIOBackend.copyTo (   self,
  localID,
  turl,
  protocol 
)

Definition at line 36 of file byteio.py.

00036 
00037     def copyTo(self, localID, turl, protocol):
00038         f = file(os.path.join(self.datadir, localID),'rb')
00039         log.msg(arc.VERBOSE, self.turlprefix, 'Uploading file to', turl)
00040         upload_to_turl(turl, protocol, f, ssl_config = self.ssl_config)
00041         f.close()
    

Here is the call graph for this function:

Definition at line 89 of file byteio.py.

00089 
00090     def generateLocalID(self):
00091         return arc.UUID()

Definition at line 86 of file byteio.py.

00086 
00087     def getAvailableSpace(self):
00088         return None

Definition at line 83 of file byteio.py.

00083 
00084     def list(self):
00085         return os.listdir(os.datadir)

Definition at line 92 of file byteio.py.

00092 
00093     def matchProtocols(self, protocols):
00094         return [protocol for protocol in protocols if protocol in self.supported_protocols]

def storage.shepherd.byteio.ByteIOBackend.notify (   self,
  inpayload 
)

Definition at line 95 of file byteio.py.

00095 
00096     def notify(self, inpayload):
00097         request_node = inpayload.Get('notify')
00098         subject = str(request_node.Get('subject'))
00099         referenceID = self.idstore.get(subject, None)
00100         state = str(request_node.Get('state'))
00101         path = os.path.join(self.transferdir, subject)
00102         log.msg(arc.VERBOSE, self.turlprefix, 'Removing', path)
00103         os.remove(path)
00104         self.file_arrived(referenceID)
00105         out = arc.PayloadSOAP(self.ns)
00106         response_node = out.NewChild('she:notifyResponse').Set('OK')
00107         return out

def storage.shepherd.byteio.ByteIOBackend.prepareToGet (   self,
  referenceID,
  localID,
  protocol 
)

Definition at line 49 of file byteio.py.

00049 
00050     def prepareToGet(self, referenceID, localID, protocol):
00051         if protocol not in self.supported_protocols:
00052             raise Exception, 'Unsupported protocol: ' + protocol
00053         turl_id = arc.UUID()
00054         try:
00055             os.link(os.path.join(self.datadir, localID), os.path.join(self.transferdir, turl_id))
00056             self.idstore[turl_id] = referenceID
00057             log.msg(arc.VERBOSE, self.turlprefix, '++', self.idstore)
00058             turl = self.turlprefix + turl_id
00059             return turl
00060         except:
00061             return None

def storage.shepherd.byteio.ByteIOBackend.prepareToPut (   self,
  referenceID,
  localID,
  protocol 
)

Definition at line 62 of file byteio.py.

00062 
00063     def prepareToPut(self, referenceID, localID, protocol):
00064         if protocol not in self.supported_protocols:
00065             raise Exception, 'Unsupported protocol: ' + protocol
00066         turl_id = arc.UUID()
00067         datapath = os.path.join(self.datadir, localID)
00068         f = file(datapath, 'wb')
00069         f.close()
00070         os.link(datapath, os.path.join(self.transferdir, turl_id))
00071         self.idstore[turl_id] = referenceID
00072         log.msg(arc.VERBOSE, self.turlprefix, '++', self.idstore)
00073         turl = self.turlprefix + turl_id
00074         return turl

def storage.shepherd.byteio.ByteIOBackend.remove (   self,
  localID 
)

Definition at line 75 of file byteio.py.

00075 
00076     def remove(self, localID):
00077         try:
00078             fn = os.path.join(self.datadir, localID)
00079             os.remove(fn)
00080         except:
00081             return 'failed: ' + traceback.format_exc()
00082         return 'removed'


Member Data Documentation

Definition at line 22 of file byteio.py.

Definition at line 19 of file byteio.py.

Definition at line 34 of file byteio.py.

Definition at line 20 of file byteio.py.

Definition at line 15 of file byteio.py.

Definition at line 21 of file byteio.py.

Definition at line 16 of file byteio.py.

Definition at line 23 of file byteio.py.

Definition at line 24 of file byteio.py.


The documentation for this class was generated from the following file: