コード例 #1
0
    def StartDataOperations(self):
        '''
        Calls datastore methods.
        '''
        uploadFile = 'dataStoreTest.txt'
        localFile = 'dataStoreTest2.txt'

        #
        # GetUploadDescriptor
        #
        self.uploadUrl = self.dataStore.GetUploadDescriptor()
        print self.name, 'GetUploadDescriptor', self.uploadUrl, '\n'

        #
        # GetDataDescriptions
        #
        dList = self.dataStore.GetDataDescriptions()
        print self.name, 'GetDataDescriptions', dList, '\n'

        #
        # GSIHTTPUploadFiles
        #
        print self.name, 'GSIHTTPUploadFiles ', uploadFile, '\n'

        try:
            DataStore.GSIHTTPUploadFiles(self.uploadUrl, [uploadFile], None)
        except DataStore.UploadFailed, e:
            log.exception(self.name + " Upload failed")
コード例 #2
0
class DataStoreClient:
    '''
    Calls datastore methods to test datastore.
    '''
    def __init__(self, dataStore, index):
        '''
        Start datastoreclient
        **Arguments**
        *datastore* DataStore to test
        *index* Unique identifier
        '''
        self.dataStore = dataStore
        self.name = 'datastore' + str(index)

    def StartDataOperations(self):
        '''
        Calls datastore methods.
        '''
        uploadFile = 'dataStoreTest.txt'
        localFile = 'dataStoreTest2.txt'

        #
        # GetUploadDescriptor
        #
        self.uploadUrl = self.dataStore.GetUploadDescriptor()
        print self.name, 'GetUploadDescriptor', self.uploadUrl, '\n'

        #
        # GetDataDescriptions
        #
        dList = self.dataStore.GetDataDescriptions()
        print self.name, 'GetDataDescriptions', dList, '\n'

        #
        # GSIHTTPUploadFiles
        #
        print self.name, 'GSIHTTPUploadFiles ', uploadFile, '\n'

        try:
            DataStore.GSIHTTPUploadFiles(self.uploadUrl, [uploadFile], None)
        except DataStore.UploadFailed, e:
            log.exception(self.name + " Upload failed")

        #
        # GetDescription
        #
        data = self.dataStore.GetDescription(uploadFile)
        print self.name, 'GetDescription ', uploadFile, data, '\n'

        try:
            DataStore.GSIHTTPDownloadFile(data.uri, localFile, data.size,
                                          data.checksum)
        except DataStore.DownloadFailed, e:
            log.exception(self.name + "Download failed")
コード例 #3
0
    def __init__(self, url):
        VenueClient.__init__(self)
        print '--------------- SET PROFILE'
        profile = ClientProfile('userProfile')
        self.SetProfile(profile)
        self.profile.Dump()

        print '\n--------------- CREATE PROXY'
        try:
            venueUri = Client.Handle(url).get_proxy().GetDefaultVenue()
            print 'get url for default venue from server ', url

        except:
            venueUri = url

        print 'venue url: ', url
        print 'get proxy for venue', venueUri
        self.client = Client.Handle(venueUri).get_proxy()

        print '\n--------------- ENTER VENUE'
        self.EnterVenue(venueUri)

        print '\n--------------- ADD DATA'
        self.upload_url = self.client.GetUploadDescriptor()
        file_list = ['test_Apps.py']
        DataStore.GSIHTTPUploadFiles(self.upload_url, file_list, None)

        print '\n--------------- REMOVE DATA'
        data = DataDescription3('test_Apps.py')
        self.client.RemoveData(data)

        #         print '\n--------------- ADD SERVICE'
        #         service = ServiceDescription('serviceName', 'serviceDescription', 'serviceUri',\
        #                                      'serviceIcon', 'serviceStoragetype')
        #         self.client.AddService(service)

        #         print '\n--------------- REMOVE DATA'
        #        self.client.RemoveData(data)

        #         print '\n--------------- REMOVE SERVICE'
        #         self.client.RemoveService(service)

        nodeUrl = 'http://nodeserviceurl'
        print '\n--------------- SET NODE SERVICE URL', nodeUrl
        self.SetNodeServiceUri(nodeUrl)
        print '--------------- NODE SERVICE URL: ', self.nodeServiceUri

        print '\n--------------- CHANGE PROFILE'
        profile2 = ClientProfile('nodeProfile')
        self.SetProfile(profile2)
        self.profile.Dump()

        print '\n--------------- EXIT VENUE'
        self.ExitVenue()
コード例 #4
0
    def CreateDataStore(self):
        self.dataStorePath = 'DataStoreTestDir'
        #self.dataStorePath = os.path.join(self.dataStoreLocation, str(self.uniqueId))
        if not os.path.exists(self.dataStorePath):
            try:
                os.mkdir(self.dataStorePath)
            except OSError:
                self.dataStorePath = None

        self.dataStore = DataStore.DataStore(self, self.dataStorePath,
                                             str(self.uniqueId),
                                             self.dataTransferServer)
コード例 #5
0
    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
コード例 #6
0
    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
コード例 #7
0
hdlr = Log.StreamHandler()
hdlr.setLevel(Log.DEBUG)
Log.HandleLoggers(Log.StreamHandler(), Log.GetDefaultLoggers())

sys.path.append(r"c:\home\olson\ag\dev\AccessGrid")

from AccessGrid import DataStore

defaultURL = "https://localhost:9011/test"

if len(sys.argv) > 1:
    url = sys.argv[1]
else:
    url = defaultURL

files = [
    r"c:\temp\tarfile-0.6.5.zip",
    r"c:\boot.ini",
    r"c:\Program Files\Inno Setup 3\whatsnew.htm",
    #         r"file name with spaces.txt",
    #         r"c:\home\olson\ag\dev\AccessGrid\AccessGrid\put.py",
    #          r"c:\temp\put.py",
    r"c:\home\olson\docs\AG\ag-2-design\datastore-simplified.doc"
]

if re.search("^https:", url):
    x = DataStore.GSIHTTPUploadFiles(url, files, None)
elif re.search("^http:", url):
    x = DataStore.HTTPUploadFiles("ME", url, files, None)