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


Python queue.join方法代码示例

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


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

示例1: download_file

# 需要导入模块: import queue [as 别名]
# 或者: from queue import join [as 别名]
def download_file(url, saveDir):
    # interfacelift returns a 403 forbidden unless you include a referer.
    headers = { 'User-Agent' : "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)",
                'Referer': url}
    req = Request(url, None, headers)
    filename = IMG_FILE_PATTERN.search(url).group()
    saveFile = os.path.join(saveDir, filename)
    with open(saveFile, 'wb') as f:
        try:
            res = urlopen(req)
            f.write(res.read())
            print('[+] Downloaded %s' % filename)
        except Exception as e:
            print(e)
            try: os.remove(saveFile)
            except: pass

# Thread worker. Constantly takes URLs from the queue 
开发者ID:benjaminheng,项目名称:interfacelift-downloader,代码行数:20,代码来源:interfacelift-downloader.py

示例2: print_resolution_list

# 需要导入模块: import queue [as 别名]
# 或者: from queue import join [as 别名]
def print_resolution_list():
    print('\n[Widescreen 16:10]')
    print(', '.join(key for key in RES_WIDESCREEN_16_10))
    print('\n[Widescreen 16:9]')
    print(', '.join(key for key in RES_WIDESCREEN_16_9))
    print('\n[Widescreen 21:9]')
    print(', '.join(key for key in RES_WIDESCREEN_21_9))
    print('\n[Dual Monitors]')
    print(', '.join(key for key in RES_DUAL_MONITORS))
    print('\n[Triple Monitors]')
    print(', '.join(key for key in RES_TRIPLE_MONITORS))
    print('\n[iPhone resolutions]')
    print(', '.join(key for key in RES_IPHONE))
    print('\n[iPad resolutions]')
    print(', '.join(key for key in RES_IPAD))

# Validates the supplied arguments 
开发者ID:benjaminheng,项目名称:interfacelift-downloader,代码行数:19,代码来源:interfacelift-downloader.py

示例3: copy_output_file

# 需要导入模块: import queue [as 别名]
# 或者: from queue import join [as 别名]
def copy_output_file(src_name, src_dir, dst, trim_header, append=True):
        src = os.path.join(src_dir, src_name)
        dst = os.path.join(os.getcwd(), dst)
        logging.debug("Copying {0} to {1}".format(src, dst))
        try:
            dst_exists = os.path.isfile(dst)
            src_file = open(src, 'r', encoding='utf8')
            mode = 'w' if not dst_exists or not append else 'a'
            dst_file = open(dst, mode, encoding='utf8')

            line_count = 0
            for line in src_file:
                line_count += 1
                if line_count == 1 and trim_header and dst_exists:
                    continue
                dst_file.write(line)

            src_file.close()
            dst_file.close()
        except IOError as e:
            logging.debug("Exception while copying files: " + str(e))
            return 
开发者ID:tableau,项目名称:connector-plugin-sdk,代码行数:24,代码来源:tdvt.py

示例4: copy_files_to_zip

# 需要导入模块: import queue [as 别名]
# 或者: from queue import join [as 别名]
def copy_files_to_zip(self, dst_file_name, src_dir, is_logs):
        dst = os.path.join(os.getcwd(), dst_file_name)
        mode = 'w' if not os.path.isfile(dst) else 'a'
        optional_dir_name = self.test_config.config_file.replace('.', '_')
        if is_logs is True:
            log_dir = os.path.join(src_dir, optional_dir_name)
            glob_path = glob.glob(os.path.join(log_dir, '*.txt'))
            glob_path.extend(glob.glob(os.path.join(log_dir, '*.log')))
            glob_path.extend(glob.glob(os.path.join(log_dir, 'crashdumps/*')))
        else:
            glob_path = glob.glob(os.path.join(src_dir, 'actual.*'))
        with zipfile.ZipFile(dst, mode, zipfile.ZIP_DEFLATED) as myzip:
            for actual in glob_path:
                path = pathlib.PurePath(actual)
                file_to_be_zipped = path.name
                inner_output = os.path.join(optional_dir_name, file_to_be_zipped)
                myzip.write(actual, inner_output) 
开发者ID:tableau,项目名称:connector-plugin-sdk,代码行数:19,代码来源:tdvt.py

示例5: do_test_queue_work

# 需要导入模块: import queue [as 别名]
# 或者: from queue import join [as 别名]
def do_test_queue_work(i, q):
    """This will be called in a queue.join() context, so make sure to mark all work items as done and
    continue through the loop. Don't try and exit or return from here if there are still work items in the queue.
    See the python queue documentation."""

    abort_test_run = False
    while True:
        # This blocks if the queue is empty.
        work = q.get()

        work.run()

        q.task_done() 
开发者ID:tableau,项目名称:connector-plugin-sdk,代码行数:15,代码来源:tdvt.py

示例6: copy_test_result_file

# 需要导入模块: import queue [as 别名]
# 或者: from queue import join [as 别名]
def copy_test_result_file(self):
        src = os.path.join(self.temp_dir, "tdvt_output.json")
        dst = os.path.join(os.getcwd(), TestOutputFiles.output_json)
        try:
            if not os.path.isfile(dst):
                shutil.copyfile(src, dst)
            else:
                src_file = open(src, 'r', encoding='utf8')
                results = json.load(src_file)
                src_file.close()

                dst_file = open(dst, 'r', encoding='utf8')
                existing_results = json.load(dst_file)
                dst_file.close()

                existing_results['failed_tests'].extend(results['failed_tests'])

                existing_results['successful_tests'].extend(results['successful_tests'])

                existing_results['skipped_tests'].extend(results['skipped_tests'])

                existing_results['disabled_tests'].extend(results['disabled_tests'])

                # Check the newly succeeding tests, and if they are in the existing failed
                # test list, remove them from the failed test list since they now succeed
                for element in results['successful_tests']:
                    for failed in existing_results['failed_tests']:
                        if element['test_name'] == failed['test_name']:
                            existing_results['failed_tests'].remove(failed)

                dst_file = open(dst, 'w', encoding='utf8')
                json.dump(existing_results, dst_file)
                dst_file.close()
        except IOError:
            return 
开发者ID:tableau,项目名称:connector-plugin-sdk,代码行数:37,代码来源:tdvt.py

示例7: delete_output_files

# 需要导入模块: import queue [as 别名]
# 或者: from queue import join [as 别名]
def delete_output_files(root_dir):
    for f in TestOutputFiles.all_output_files:
        out_file = os.path.join(root_dir, f)
        for f in glob.glob(out_file):
            if os.path.exists(out_file):
                try:
                    os.unlink(out_file)
                except Exception as e:
                    print(e)
                    continue 
开发者ID:tableau,项目名称:connector-plugin-sdk,代码行数:12,代码来源:tdvt.py

示例8: flush

# 需要导入模块: import queue [as 别名]
# 或者: from queue import join [as 别名]
def flush(self):
        """Forces a flush from the internal queue to the server"""
        queue = self.queue
        size = queue.qsize()
        queue.join()
        self.log.debug('successfully flushed {0} items.'.format(size)) 
开发者ID:KunihikoKido,项目名称:sublime-elasticsearch-client,代码行数:8,代码来源:client.py

示例9: join

# 需要导入模块: import queue [as 别名]
# 或者: from queue import join [as 别名]
def join(self):
        """Ends the consumer thread once the queue is empty. Blocks execution until finished"""
        self.consumer.pause()
        self.consumer.join() 
开发者ID:KunihikoKido,项目名称:sublime-elasticsearch-client,代码行数:6,代码来源:client.py


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