本文整理汇总了Python中Library.loadEmulatorHelp方法的典型用法代码示例。如果您正苦于以下问题:Python Library.loadEmulatorHelp方法的具体用法?Python Library.loadEmulatorHelp怎么用?Python Library.loadEmulatorHelp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Library
的用法示例。
在下文中一共展示了Library.loadEmulatorHelp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_emulator
# 需要导入模块: import Library [as 别名]
# 或者: from Library import loadEmulatorHelp [as 别名]
def get_emulator(name=""):
'''
Display emulator by name
'''
ET.register_namespace("test", "http://127.0.0.1/cocoma")
response.set_header('Content-Type', 'application/vnd.bonfire+xml')
response.set_header('Accept', '*/*')
response.set_header('Allow', 'GET, HEAD')
try:
helpMod=Library.loadEmulatorHelp(name)
argMod=Library.loadEmulatorArgNames(name)
emulatorXml = ET.Element('emulator', { 'xmlns':'http://127.0.0.1/cocoma','href':'/emulators/'+str(name)})
emulatorInfoXml=ET.SubElement(emulatorXml,'info')
emulatorHelpXml=ET.SubElement(emulatorInfoXml,'help')
emulatorHelpXml.text = str(helpMod())
emulatorResourcesListXml=ET.SubElement(emulatorInfoXml,'resources')
#get list of resources
resList=argMod()
#get arguments for every resource { "mem":[startLoad,stopLoad,malloc]}, "io":[...]}
for resource in resList:
argNames=argMod(resource)
#<mem>
emulatorResourceXml=ET.SubElement(emulatorResourcesListXml,resource)
#<startLoad>
#{"startload":{"upperBound":100,"lowerBound":0},"stopload":{"upperBound":100,"lowerBound":0}}
for args in argNames:
emulatorArgsXml=ET.SubElement(emulatorResourceXml,args)
#<upperBound>
emulatorUpperBound=ET.SubElement(emulatorArgsXml,"upperBound")
emulatorUpperBound.text = str(argNames[args]["upperBound"])
emulatorLowerBound=ET.SubElement(emulatorArgsXml,"lowerBound")
emulatorLowerBound.text = str(argNames[args]["lowerBound"])
if not (argNames[args].has_key("argHelp")):
argNames[args]["argHelp"] = "No help Available"
emuArgHelp=ET.SubElement(emulatorArgsXml,"argHelp")
emuArgHelp.text = str(argNames[args]["argHelp"])
lk0 = ET.SubElement(emulatorXml, 'link', {'rel':'parent', 'href':'/', 'type':'application/vnd.bonfire+xml'})
#<link href="/emulations" rel="parent" type="application/vnd.cocoma+xml"/>
lk0 = ET.SubElement(emulatorXml, 'link', {'rel':'parent', 'href':'/emulators', 'type':'application/vnd.bonfire+xml'})
return prettify(emulatorXml)
except Exception, e:
response.status = 404
return "<error>"+str(e)+"</error>"