Пример #1
0
    def open(self, **kwargs):
        """open url to get ready to download.

        args:
            ::param:    file_name       :
            ::param:    file_path       :
            ::param:    thread_count    :
            ::param:    force           :
            ::param:    complete_validate:
            ::param:    fix_damage      :
            ::param:    block_size      :

        """
        if not self.url:
            raise AttributeError
        if kwargs:
            self.config(**kwargs)

        self.__config()

        if self.file.force is not True and self.file.exist is True:
            raise Exception('FileExistsError')

        if self._kwargs is not None:
            return DLManager(self.url, self.file, **self._kwargs)
        else:
            return DLManager(self.url, self.file)
Пример #2
0
 def load(self, path, name):
     import cPickle
     if os.path.exists(os.path.join(path, name + '.db')) is True:
         with open(os.path.join(path, name + '.db'), 'rb') as f:
             pkl = cPickle.Unpickler(f)
             return DLManager.load(pkl.load())
     else:
         return None
Пример #3
0
    def load(self, path, name):

        import cPickle

        if os.path.exists(os.path.join(path, name + '.pkl')) is True:
            with open(os.path.join(path, name + '.pkl'), 'rb') as f:

                pkl = cPickle.Unpickler(f)
                self.url = pkl.load()
                self.file = pkl.load()

                return DLManager(self.url, self.file, pkl.load())
            # return None
        else:
            return None
Пример #4
0
    def open(self, **kwargs):
        """open url to get ready to download.

        args:
            ::param:    file_name       :
            ::param:    file_path       :
            ::param:    max_thread      :
            ::param:    force           :
            ::param:    verify          :
            ::param:    fix_try         :
            ::param:    block_size      :

        """
        if not self.url:
            raise AttributeError(
                'NoUrlError, you need to .add_url() before open.')
        if kwargs:
            self.config(**kwargs)
        self.__config()
        return DLManager(self.url, self.file)
Пример #5
0
    def open(self, url=None, host=None, path=None, port=None):
        """open url to get ready to download."""
        if self.__fileExists:
            raise Exception('FileExistsError')
            # return None
        try:
            if url:
                self.url = URLinfo(url, host, path, port)
            else:
                if not self.url:
                    raise Exception('NOURL')

        except:
            raise Exception('URLError')

        if not self.__get_file_info():
            raise Exception(
                "URLConnectError: CONNECT ERROR, THIS URL DON'T REACTE.")
            # return None

        if not self.__config():
            raise Exception('FileExistsError')

        return DLManager(self.url, self.file, self.ThreadCount)