Beispiel #1
0
    def load(self, filename):
        """
        _load_

        UncPickle data from file

        """

        #TODO: currently support both loading from file path or url
        #if there are more things to filter may be separate the load function

        # urllib2 needs a scheme - assume local file if none given
        if not urlparse(filename)[0]:
            filename = 'file:' + filename
            handle = urlopen(Request(filename, headers = {"Accept" : "*/*"}))
            self.data = cPickle.load(handle)
            handle.close()
        elif filename.startswith('file:'):
            handle = urlopen(Request(filename, headers = {"Accept" : "*/*"}))
            self.data = cPickle.load(handle)
            handle.close()
        else:
            # use own request class so we get authentication if needed
            from WMCore.Services.Requests import Requests
            request = Requests(filename)
            data = request.makeRequest('', incoming_headers = {"Accept" : "*/*"})
            self.data = cPickle.loads(data[0])

        #TODO: use different encoding scheme for different extension
        #extension = filename.split(".")[-1].lower()

        return
Beispiel #2
0
    def load(self, filename):
        """
        _load_

        UncPickle data from file

        """

        #TODO: currently support both loading from file path or url
        #if there are more things to filter may be separate the load function

        # urllib2 needs a scheme - assume local file if none given
        if not urlparse(filename)[0]:
            filename = 'file:' + filename
            handle = urlopen(Request(filename, headers={"Accept": "*/*"}))
            self.data = cPickle.load(handle)
            handle.close()
        elif filename.startswith('file:'):
            handle = urlopen(Request(filename, headers={"Accept": "*/*"}))
            self.data = cPickle.load(handle)
            handle.close()
        else:
            # use own request class so we get authentication if needed
            from WMCore.Services.Requests import Requests
            request = Requests(filename)
            data = request.makeRequest('', incoming_headers={"Accept": "*/*"})
            self.data = cPickle.loads(data[0])

        #TODO: use different encoding scheme for different extension
        #extension = filename.split(".")[-1].lower()

        return