当前位置: 首页>>代码示例>>Python>>正文


Python Status.queue方法代码示例

本文整理汇总了Python中status.Status.queue方法的典型用法代码示例。如果您正苦于以下问题:Python Status.queue方法的具体用法?Python Status.queue怎么用?Python Status.queue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在status.Status的用法示例。


在下文中一共展示了Status.queue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: BitcasaDownload

# 需要导入模块: from status import Status [as 别名]
# 或者: from status.Status import queue [as 别名]
class BitcasaDownload(object):
    def __init__(self, args, client, should_exit):
        log.debug("source dir: %s", args.src)
        log.debug("destination dir: %s", args.dst)
        log.debug("temp dir: %s", args.temp)
        log.debug("upload: %s", args.upload)
        if args.upload:
            log.debug("provider: %s", args.provider)
        log.debug("log dir: %s", args.logdir)
        log.debug("recursion: %s", args.rec)
        log.debug("depth: %s", args.depth)
        log.debug("max folder threads: %s", args.folderthreads)
        log.debug("max download threads: %s", args.threads)
        log.debug("progress: %s", args.progress)
        log.debug("silent queuer: %s", args.silentqueuer)
        log.debug("single: %s", args.single)

        #bittcasa base64 encdoded path
        self.basefolder = args.src
        if args.single:
            log.debug("Downloading single file. Setting max threads to 1")
            args.threads = 1
            args.folderthreads = 1

        self.args = args

        #Initialize
        self.should_exit = should_exit
        self.client = client
        self.session = requests.Session()
        self.results = results.Results(args.logdir, should_exit, args.nofilelog)

        # Threads        
        self.download_threads = []
        self.upload_threads = []
        self.copy_threads = []
        self.folder_threads = []

        self.status = Status(should_exit)
        self.shutdown_sent = False

    def shutdown(self):
        if not self.shutdown_sent:
            self.shutdown_sent = True
            self.status.shutdown()

    def get_status(self):
        return self.status

    def process(self, base=None):
        log.debug("Getting base folder")
        if self.args.upload and self.args.local and base is None:
            base = BitcasaFolder(None, "root", self.basefolder)
        else:
            remainingtries = 3
            apiratecount = 1
            while base is None and remainingtries > 0 and not self.should_exit.is_set():
                try:
                    base = self.client.get_folder(self.basefolder)
                except BitcasaException as e:
                    remainingtries -= 1
                    if e.code == 9006:
                        apiratecount += 1
                        remainingtries += 1
                        log.warn("API rate limit reached. Will retry")
                    else:
                        log.warn("Couldn't get base folder %s. Will retry %s more times", e.code, remainingtries)

                    if remainingtries > 0:
                        time.sleep(10 * apiratecount)
                    else:
                        log.error("Error could not retrieve base folder")
                        return
        if self.should_exit.is_set():
            return
        log.debug("Queuing base folder")
        folder = {
            "folder": base,
            "path": "",
            "depth": 0
        }

        if self.args.upload:
            folder["folder_id"] = self.args.dst
        
        step2_args = ( self.status, self.should_exit, self.results, self.args )
        download_args = ( self.status, self.should_exit, self.session, self.results, self.args)
        folder_args = ( self.status, self.results, self.args, self.should_exit )

        self.status.queue(folder)
        if not self.args.dryrun and not self.args.local:
            log.debug("Starting Downloaders")
            for qid in xrange(self.args.threads):
                qid += 1
                download_thread = threading.Thread(target=DownloadThread, args=download_args, name="Download %s" % qid)
                download_thread.daemon = True
                download_thread.start()
                self.download_threads.append(download_thread)
        
        log.debug("Starting Queuers")
#.........这里部分代码省略.........
开发者ID:reallistic,项目名称:BitcasaFileLister,代码行数:103,代码来源:bitcasadownload.py


注:本文中的status.Status.queue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。