Commit bd239d28 authored by Gao, Shang's avatar Gao, Shang
Browse files

added exceptions to globus upload_resource method

parent 9f58e15c
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -99,12 +99,26 @@ class crossbowGlobus(crossbowBase):
          - description: string (optional)
            description of resource
        '''
        #get file info
        _, format = os.path.splitext(resource_path)
        #make sure file exists
        filename = os.path.basename(resource_path)
        directory,_ = os.path.split(resource_path)
        url = "file://CROSSBOW_NFS/%s/%s" % (package,filename)
        r = self.transfer.operation_ls(source_endpoint,path=directory,filter='name:'+filename)
        found = 0
        for item in r:
            found += 1
        if not found:
            raise Exception("Could not find specified file")
            
        #make sure file is not already on ckan
        pkg_metadata = self.ckan.action.package_show(id=package)
        rsc_metadata = [metadata for metadata in pkg_metadata['resources'] \
                        if metadata['name']==filename]
        if len(rsc_metadata) > 0:
            raise Exception("File already exists on CKAN, delete the existing file first")

        #get file info
        _, format = os.path.splitext(resource_path)
        url = "file://CROSSBOW_NFS/%s/%s" % (package,filename)
        size = r['DATA'][0]['size']

        #execute transfer
+1 −1
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ class crossbowMount(crossbowBase):

        #check if file already exists on nfs
        if os.path.isfile(nfs_path):
            raise Exception("File already exists on NFS, try using a different filename")
            raise Exception("File already exists on CKAN, delete the existing file first")

        #create directory if necessary
        if not os.path.exists(self.NFS_path + package):