Example #1
0
    def makedirs(self, filelist, endpoint):
        """ get list of dirs to make

            Parameters
            ----------
            filelist : list
                The list of files

            endpoint : str
                The endpoint to use
        """
        print "makedirs: filelist=", filelist
        dirlist = miscutils.get_list_directories(filelist)
        print "makedirs: dirlist=", dirlist
        for path in sorted(
                dirlist):  # should already be sorted, but just in case
            miscutils.fwdebug(0, 'GLOBUS_ONLINE_DEBUG',
                              'endpoint=%s, path=%s' % (endpoint, path))
            try:
                _ = self.goclient.endpoint_mkdir(endpoint, path)
            except Exception as e:
                if 'already exists' not in str(e):
                    raise
                else:
                    miscutils.fwdebug(
                        2, 'GLOBUS_ONLINE_DEBUG',
                        'already exists endpoint=%s, path=%s' %
                        (endpoint, path))
Example #2
0
    def create_http_intermediate_dirs(self, f):
        """ Create all directories that are valid prefixes of the URL *f*.

            Parameters
            ----------
            f : str
                String containing the full desintation path

            >>> C = EwdUtils('test_http_utils/.desservices.ini','file-http', 'desar2.cosmology.illinois.edu'')
            >>> C.create_http_intermediate_dirs("http://desar2.cosmology.illinois.edu/DESTesting/bar/testfile_dh.txt")
        """
        # Making bar/ sometimes returns a 301 status even if there doesn't seem to be a bar/ in the directory.
        m = re.match("(http://[^/]+)(/.*)", f)
        direc = miscutils.get_list_directories([m.group(2)])[-1]
        self.webdav.mkdirs(direc[1:])
        for x in miscutils.get_list_directories([m.group(2)]):
            self.existing_directories.add(x)
Example #3
0
    def create_http_intermediate_dirs(self, f):
        """Create all directories that are valid prefixes of the URL *f*.

        """
        # Making bar/ sometimes returns a 301 status even if there doesn't seem to be a bar/ in the directory.
        m = re.match(r"(https?://[^/]+)(/.*)", f)
        self.curl.setopt(pycurl.CUSTOMREQUEST, 'MKCOL')
        self.curl.setopt(pycurl.WRITEFUNCTION, lambda x: None)
        for x in miscutils.get_list_directories([m.group(2)]):
            if x not in self.existing_directories:
                self.curl.setopt(pycurl.URL, m.group(1) + x)
                if self.perform(cmd=f'MKCOL {m.group(1) + x}'):
                    self.existing_directories.add(x)
        self.curl.unsetopt(pycurl.CUSTOMREQUEST)