Beispiel #1
0
    def __init__(self, url=None, faultHandler=None):
        """
        The constructor.

        @param url: the url to the SOAP interface.
        @type url: string

        @raises InvalidURL: if the url doesn't point ot a service
        @raises ConnectionFailed: if client can't connection to the service.
        """
        self.defaultPort = 8000
        self.proxy = None
        self.url = self.__CheckUrl(url, self.defaultPort)

        if self.url != None:
            try:
                from AccessGrid.Preferences import Preferences

                # First, check command line option
                if Application.instance().GetOption("insecure"):
                    self.handle = Client.InsecureHandle(self.url, faultHandler=faultHandler)
                # Second, check preferences
                elif not Application.instance().GetPreferences().GetPreference(Preferences.SECURE_VENUE_CONNECTION):
                    self.handle = Client.InsecureHandle(self.url, faultHandler=faultHandler)
                else:
                    self.handle = Client.SecureHandle(self.url, faultHandler=faultHandler)
                self.proxy = self.handle.GetProxy()

            except Exception, e:
                log.exception(e)
                self.proxy = None
                raise ConnectionFailed
            except:
    def Download(self, filename, localFile):
        """
        Download filename to local file localFile.
        """

        if filename in self.dataIndex:
            data = self.dataIndex[filename]
            url = data.uri
            print "URL: " , url
            my_identity = str(Application.instance().GetDefaultSubject())
            user=str(url.split('/')[3])
            passw=str(self.connectionId)
            DataStore.DownloadFile(my_identity, url, localFile, data.size, data.checksum, user, passw)
        else:
            raise FileNotFound
Beispiel #3
0
    def __init__(self, url=None, faultHandler=None):
        """
        The constructor.

        @param url: the url to the SOAP interface.
        @type url: string

        @raises InvalidURL: if the url doesn't point ot a service
        @raises ConnectionFailed: if client can't connection to the service.
        """
        self.defaultPort = 8000
        self.proxy = None
        self.url = self.__CheckUrl(url, self.defaultPort)

        if self.url != None:
            try:
                from AccessGrid.Preferences import Preferences
                # First, check command line option
                if Application.instance().GetOption("insecure"):
                    self.handle = Client.InsecureHandle(
                        self.url, faultHandler=faultHandler)
                # Second, check preferences
                elif not Application.instance().GetPreferences().GetPreference(
                        Preferences.SECURE_VENUE_CONNECTION):
                    self.handle = Client.InsecureHandle(
                        self.url, faultHandler=faultHandler)
                else:
                    self.handle = Client.SecureHandle(
                        self.url, faultHandler=faultHandler)
                self.proxy = self.handle.GetProxy()

            except Exception, e:
                log.exception(e)
                self.proxy = None
                raise ConnectionFailed
            except:
    def Upload(self, localFile):
        """
        Upload localFile to the venue datastore.
        """

        try:
            #log.debug("Upload %s to %s", localFile, self.uploadURL)
            my_identity = str(Application.instance().GetDefaultSubject())
            user=str(self.uploadURL.split('/')[-1])
            passw=str(self.connectionId)
            DataStore.UploadFiles(my_identity, self.uploadURL, [localFile], user, passw)
        except DataStore.UploadFailed, e:
            #rc, errlist = e.args[0]
            #for err in errlist:
            #    print err
            raise e
    def Download(self, filename, localFile):
        """
        Download filename to local file localFile.
        """

        if filename in self.dataIndex:
            data = self.dataIndex[filename]
            url = data.uri
            print "URL: ", url
            my_identity = str(Application.instance().GetDefaultSubject())
            user = str(url.split('/')[3])
            passw = str(self.connectionId)
            DataStore.DownloadFile(my_identity, url, localFile, data.size,
                                   data.checksum, user, passw)
        else:
            raise FileNotFound
    def Upload(self, localFile):
        """
        Upload localFile to the venue datastore.
        """

        try:
            #log.debug("Upload %s to %s", localFile, self.uploadURL)
            my_identity = str(Application.instance().GetDefaultSubject())
            user = str(self.uploadURL.split('/')[-1])
            passw = str(self.connectionId)
            DataStore.UploadFiles(my_identity, self.uploadURL, [localFile],
                                  user, passw)
        except DataStore.UploadFailed, e:
            #rc, errlist = e.args[0]
            #for err in errlist:
            #    print err
            raise e
        self.type = type
        self.url = url

    def __repr__(self):
        if self.type == self.TYPE_DIR:
            ret = "Directory: "
        else:
            ret = "File:      "

        ret += "%s %s %s" % (self.name, self.size, self.url)

        return ret


if __name__ == "__main__":
    Application.instance().Initialize("DataStoreClient")

    def testData(vurl,connectionId):

        dsc = GetVenueDataStore(vurl,connectionId)

        sh = DataStoreShell(dsc)
        sh.run()
        
    hdlr = Log.StreamHandler()
    hdlr.setLevel(Log.ERROR)
    Log.HandleLoggers(hdlr, Log.GetDefaultLoggers())

    if len(sys.argv) > 1 and sys.argv[1] == "-d":
        hdlr.setLevel(Log.DEBUG)
        del sys.argv[1]
        self.type = type
        self.url = url

    def __repr__(self):
        if self.type == self.TYPE_DIR:
            ret = "Directory: "
        else:
            ret = "File:      "

        ret += "%s %s %s" % (self.name, self.size, self.url)

        return ret


if __name__ == "__main__":
    Application.instance().Initialize("DataStoreClient")

    def testData(vurl, connectionId):

        dsc = GetVenueDataStore(vurl, connectionId)

        sh = DataStoreShell(dsc)
        sh.run()

    hdlr = Log.StreamHandler()
    hdlr.setLevel(Log.ERROR)
    Log.HandleLoggers(hdlr, Log.GetDefaultLoggers())

    if len(sys.argv) > 1 and sys.argv[1] == "-d":
        hdlr.setLevel(Log.DEBUG)
        del sys.argv[1]