示例#1
0
    def make(self, dst):
        if not len(self.files) and not len(self._writes):
            return

        make_dirs(dirname(dst))

        self._archive = ZipFile(dst, 'w', ZIP_DEFLATED)
        self.__add_files()
        self.__add_writes()
        self._archive.close()
        self._maked()
示例#2
0
 def loop_chapters(self):
     arc_name = self.get_archive_name()
     arc = self._archive_type()
     path = path_join(dirname(self.get_archive_path()), arc_name + '.%s' % arc)
     url = self.chapter
     temp_path = get_temp_path('{:0>2}_{}-temp_arc.zip'.format(
         self._storage['current_chapter'],
         arc_name
     ))
     self.save_file(url, temp_path)
     rename(temp_path, path)
示例#3
0
 def _safe_downloader(self, url, file_name, method='get') -> bool:
     try:
         make_dirs(dirname(file_name))
         url = self.normalize_uri(url)
         with open(file_name, 'wb') as out_file:
             response = self.requests(url, method=method, timeout=60)
             out_file.write(response.content)
             response.close()
             out_file.close()
     except OSError as ex:
         self.debug and print(ex)
         return False
     return True
示例#4
0
    def download_drivder(self):
        url_prefix = 'https://chromedriver.storage.googleapis.com/'
        url = '/chromedriver_linux64.zip'
        if ~platform.find('darwin'):
            url = '/chromedriver_mac64.zip'
        if self.is_win():
            url = '/chromedriver_win32.zip'

        path = storage('driver.zip')

        with open(path, 'wb') as driver:
            driver.write(get(url_prefix + self.driver_version + url).content)
            driver.close()
        with ZipFile(path) as file:
            file.extractall(dirname(self._driver_path()))
示例#5
0
 def get_arc_path(self):
     path = self.get_archive_name()
     name = dirname(self.get_archive_path())
     arc = self._archive_type()
     return path_join(path, name + '.%s' % arc)