本文整理汇总了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'])
示例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)