本文整理匯總了Python中henmanager.HenManager.power方法的典型用法代碼示例。如果您正苦於以下問題:Python HenManager.power方法的具體用法?Python HenManager.power怎麽用?Python HenManager.power使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類henmanager.HenManager
的用法示例。
在下文中一共展示了HenManager.power方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from henmanager import HenManager [as 別名]
# 或者: from henmanager.HenManager import power [as 別名]
def main():
if len(sys.argv) != 2:
print "FAIL: nodeid not provided!"
return -1
nodeid = sys.argv[1]
hm = HenManager()
if (hm.power(sys.argv[1], "poweroff") < 0):
print "FAIL: hm.power(%s, \"poweroff\") failed (cause unknown)!"\
% nodeid
return -1
time.sleep(2)
(sts, output) = hm.powerSilent(sys.argv[1], "status")
if (sts < 0):
print "FAIL: hm.power(%s, \"status\") returned: %s" % (nodeid, output)
return -1
if (output == "on"):
print "FAIL: hm.power(%s, \"status\") says the node is still on!" \
% nodeid
return -1
if (output == "off"):
print "SUCCESS: hm.power(%s, \"poweroff\") succeeded." % nodeid
return 0
print "FAIL: hm.power(%s, \"status\") returned: %s" % (nodeid, output)
return -1
示例2: HenManager
# 需要導入模塊: from henmanager import HenManager [as 別名]
# 或者: from henmanager.HenManager import power [as 別名]
###########################################################################################
# Main execution
###########################################################################################
print "Content-Type: text/html"
print ""
print ""
manager = HenManager()
nodes = manager.getNodes("all")
form = cgi.FieldStorage()
if form.has_key("id"):
pass
else:
sys.exit()
nodeid = form["id"].value
for nodeTypeDictionary in nodes.values():
for node in nodeTypeDictionary.values():
if (nodeid == node.getNodeID()):
print "<p>"
print "power status of "
manager.power(nodeid,"status")
print "</p>"
sys.exit()