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


Python Output.new方法代码示例

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


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

示例1: run

# 需要导入模块: from output import Output [as 别名]
# 或者: from output.Output import new [as 别名]
    def run(self):
        while True:
            try:
                printRequest = self.get_print_request()
            except NotFoundException:
                logging.info("No print request to print. Waiting...")
                sleep(NODE['QUERY_TIME'])
                continue
            except UnauthorizedException:
                logging.warning("Node unauthorized. Waiting...")
                sleep(NODE['QUERY_TIME'])
                continue

            with Output.new() as output:
                try:
                    logging.info("Trying to print the request.")
                    output.printRequest(printRequest)
                except Exception as e:
                    logging.error("There was an error "
                                  "during printing:\n{}".format(e))
                    self.report_failure(printRequest)
                    continue
                logging.info("Succesfully printed the request.")
                self.report_success(printRequest)

            logging.info("Waiting for next request.")
            sleep(NODE['QUERY_TIME'])
开发者ID:Czocher,项目名称:zebra-printer,代码行数:29,代码来源:node.py

示例2: Node

# 需要导入模块: from output import Output [as 别名]
# 或者: from output.Output import new [as 别名]
from node import Node

import locale
import logging
import sys


# Set the default locale for dates and times in logs
locale.setlocale(locale.LC_ALL, '')

FORMAT = '%(asctime)s - %(levelname)s - [%(module)s.%(funcName)s] %(message)s'

logging.basicConfig(
    level=logging.DEBUG,
    format=FORMAT,
    datefmt='%c'
)

if __name__ == '__main__':
    # Test if the output is valid
    with Output.new() as output:
        output.test()

    # Start the Node
    try:
        node = Node()
        node.run()
    except KeyboardInterrupt:
        logging.info("Node successfully terminated.")
        sys.exit(0)
开发者ID:Czocher,项目名称:zebra-printer,代码行数:32,代码来源:main.py


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