Exemplo n.º 1
0
    def _loop_remotes(self):
        for item in self._remotes:
            filename = item["name"] + "." + item["type"]

            print self._base_path

            download_path = self._base_path + filename
            extract_path = self._base_path + item["name"]

            if rm_existing(extract_path):
                print "Directory deleted: " + extract_path

            print "Attempting to download: " + filename

            if self._download(item["url"], download_path):
                print "File downloaded: " + filename

            archive = self._get_archive(download_path, item["type"])
            archive.extract(extract_path)
            print "Extracted :" + filename

            os.remove(download_path)
            print "Removed: " + filename

        return True
Exemplo n.º 2
0
    def execute(self):
        if not self._out_path:
            set_out_path(self._base_path)
        
        for root, dirs, files in os.walk(self._base_path):
            for item in self._ignores:
                self._remove_from_list(dirs,item)
                self._remove_from_list(files,item)
                
            # Create all required directories
            for d in dirs:
                root = fix_path(root)
                
                old = root + d
                new = self._out_path + old.replace(self._base_path,'')

                if rm_existing(new):
                    print 'Directory removed: ' + new

                if not os.path.isdir(new):
                    os.mkdir(new)
                    print 'Directory created at: ' + new
    
            #loop through all files in the directory
            for f in files:
                root = fix_path(root)

                old = root + f
                new = self._out_path + old.replace(self._base_path,'')

                try:
                    new_file = open(new,'w')
                    new_file.write(open(old,'r').read())
                    new_file.flush()
                    new_file.close()
                    print 'File ' + f + ' copied.'
                except IOError:
                    print "Error writing file: " + f