本文整理汇总了Python中attrdict.AttrDict.contextfile方法的典型用法代码示例。如果您正苦于以下问题:Python AttrDict.contextfile方法的具体用法?Python AttrDict.contextfile怎么用?Python AttrDict.contextfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类attrdict.AttrDict
的用法示例。
在下文中一共展示了AttrDict.contextfile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start_mock_server80
# 需要导入模块: from attrdict import AttrDict [as 别名]
# 或者: from attrdict.AttrDict import contextfile [as 别名]
def start_mock_server80():
"""Start a mock Tomcat Manager application
:returns: a tuple: (url, user, password) where the server is accessible
"""
# pylint: disable=unused-variable
# go find an unused port
sock = socket.socket(socket.AF_INET, type=socket.SOCK_STREAM)
sock.bind(('localhost', 0))
address, port = sock.getsockname()
sock.close()
tms = AttrDict()
tms.url = 'http://localhost:{}/manager'.format(port)
tms.user = USER
tms.password = PASSWORD
tms.warfile = '/path/to/server.war'
tms.contextfile = 'path/to/context.xml'
mock_server = HTTPServer(('localhost', port), MockRequestHandler80)
mock_server_thread = Thread(target=mock_server.serve_forever)
mock_server_thread.setDaemon(True)
mock_server_thread.start()
return tms
示例2: tomcat_manager_server
# 需要导入模块: from attrdict import AttrDict [as 别名]
# 或者: from attrdict.AttrDict import contextfile [as 别名]
def tomcat_manager_server(request):
"""start a local http server which provides a similar interface to a real Tomcat Manager app"""
url = request.config.getoption('--url')
if url:
# use the server info specified on the command line
tms = AttrDict()
tms.url = url
tms.user = request.config.getoption('--user')
tms.password = request.config.getoption('--password')
tms.warfile = request.config.getoption('--warfile')
tms.contextfile = request.config.getoption('--contextfile')
return tms
else:
# go start up a fake server
return start_mock_server80()