Esempio n. 1
0
    def download(self, dest, sel_files=None):
        count = 0
        num = 0
        for u, files in self.urls:
            if sel_files is not None:
                files = set(files) & sel_files
            count += len(files)

        for urls, files in self.urls:
            if not isinstance(urls, list):
                urls = [urls]

            if sel_files is not None:
                files = set(files) & sel_files
            
            for filename in files:
                done = False

                for link in urls:
                    with open(os.path.join(dest, filename), 'wb') as dl:
                        progress.start_task(float(num) / count, 1.0 / count, '%d/%d: %%s' % (num + 1, count))
                        if download(pjoin(link, filename), dl):
                            num += 1
                            done = True
                            progress.finish_task()
                            break
                        
                        progress.finish_task()

                if not done:
                    logging.error('Failed to download "%s"!', filename)
Esempio n. 2
0
    def download(self, dest, sel_files=None):
        count = 0
        num = 0
        for u, files in self.urls:
            if sel_files is not None:
                files = set(files) & sel_files
            count += len(files)

        for urls, files in self.urls:
            if not isinstance(urls, list):
                urls = [urls]

            if sel_files is not None:
                files = set(files) & sel_files

            for filename in files:
                done = False

                for link in urls:
                    with open(os.path.join(dest, filename), 'wb') as dl:
                        progress.start_task(
                            float(num) / count, 1.0 / count,
                            '%d/%d: %%s' % (num + 1, count))
                        if download(pjoin(link, filename), dl):
                            num += 1
                            done = True
                            progress.finish_task()
                            break

                        progress.finish_task()

                if not done:
                    logging.error('Failed to download "%s"!', filename)
Esempio n. 3
0
    def write(self, fn, gen_out=False):
        if not self._list:
            return False

        if gen_out:
            fd, fn = tempfile.mkstemp(suffix='.7z', dir=fn)
            os.close(fd)

        with tempfile.TemporaryDirectory() as path:
            progress.start_task(0, 0.5)
            super(SevenAdapter, self).write(path)
            progress.finish_task()

            progress.update(0.5, 'Compressing...')
            subprocess.check_call(
                ['7z', 'a', os.path.abspath(fn), '.'], cwd=path)

        if gen_out:
            return fn
        else:
            return True
Esempio n. 4
0
    def setup(self, fs2_path):
        modpath = os.path.join(fs2_path, self.folder)

        if not os.path.isdir(modpath):
            os.mkdir(modpath)
        
        progress.start_task(0, 1/6.0)
        self.execute_del(modpath)
        progress.finish_task()
        
        progress.start_task(1/6.0, 1/6.0)
        self.execute_rename(modpath)
        progress.finish_task()
        
        progress.start_task(2/6.0, 1/6.0, 'Downloading: %s')
        self.download(modpath)
        progress.finish_task()
        
        progress.start_task(3/6.0, 1/6.0)
        self.extract(modpath)
        progress.finish_task()
        
        progress.start_task(4/6.0, 1/6.0)
        self.check_hashes(modpath)
        progress.finish_task()
        
        progress.start_task(5/6.0, 1/6.0)
        self.cleanup(modpath)
        progress.finish_task()
Esempio n. 5
0
    def setup(self, fs2_path):
        modpath = os.path.join(fs2_path, self.folder)

        if not os.path.isdir(modpath):
            os.mkdir(modpath)

        progress.start_task(0, 1 / 6.0)
        self.execute_del(modpath)
        progress.finish_task()

        progress.start_task(1 / 6.0, 1 / 6.0)
        self.execute_rename(modpath)
        progress.finish_task()

        progress.start_task(2 / 6.0, 1 / 6.0, 'Downloading: %s')
        self.download(modpath)
        progress.finish_task()

        progress.start_task(3 / 6.0, 1 / 6.0)
        self.extract(modpath)
        progress.finish_task()

        progress.start_task(4 / 6.0, 1 / 6.0)
        self.check_hashes(modpath)
        progress.finish_task()

        progress.start_task(5 / 6.0, 1 / 6.0)
        self.cleanup(modpath)
        progress.finish_task()