Exemplo n.º 1
0
def main_menu():
    cls()
    a=XMLJobManager()
    status=a.listByStatus()
    running=processtools.is_running()
    if running==False: idle=""
    elif status[1]==0: idle="(idle)"
    else: idle="(processing)"
    
    httprunning=processtools.is_http_running()
    
    print "(c) 2011 Node Styk.Tv v0.2 ", version.commit, " (", version.date+")"
    print "Node ID:",  version.nodeid
    print "IP: ", pwdtools.getMainIp(), "  (", pwdtools.getIfaceType()+")"
    print
    print "Node is running: ",   running,  idle,  " HTTP server is running: ", httprunning
    print "WORKFLOWS: ", status[0], " pending, ", status[1], " processing, ", status[2], " finished, ",  status[3], " failed"
    print
    print "1) Network settings"
    print "2) Change root password"
    print "3) Change node password"
    if running:
        print "4) Stop node"
    else:
        print "5) Start node"
    if os.path.exists("/home/node/styk.tv/update.sh"): print "6) Update node"
    if os.path.exists(Config.CONFIGDIR+"/node.log"): print "7) Show current log"
    print "0) Exit"
    print
    sys.stdout.write("Enter choice: ")
    
    return sys.stdin.readline().strip()
Exemplo n.º 2
0
def printStatus(out, checkcpu):
    doc=getDOMImplementation().createDocument(None, "status", None)
    node=doc.createElement("node")
    a=XMLJobManager()
    status=a.listByStatus()
    node.setAttribute("running", str(is_running()))
    node.setAttribute("pending", str(status[0]))
    node.setAttribute("processing", str(status[1]))
    node.setAttribute("finished", str(status[2]))
    node.setAttribute("failed", str(status[3]))
    doc.documentElement.appendChild(node)
    mem=doc.createElement("memory")
    phy=psutil.phymem_usage()
    virt=psutil.virtmem_usage()
    mem.setAttribute("total_physical", str(phy.total))
    mem.setAttribute("avail_physical", str(phy.total-phy.used))
    mem.setAttribute("total_virtual", str(virt.total))
    mem.setAttribute("avail_virtual", str(virt.total-virt.used))
    doc.documentElement.appendChild(mem)
    if checkcpu:
        cpu=doc.createElement("cpu")
        cpu.setAttribute("usage", str(psutil.cpu_percent(3)))
        doc.documentElement.appendChild(cpu)
    lsl=LocalStoreList()
    for disk in lsl.disks:
        d=doc.createElement("disk")
        d.setAttribute("guid", disk.uuid)
        d.setAttribute("online", str(disk.online))
        d.setAttribute('freespace', str(disk.freespace))
        doc.documentElement.appendChild(d)
    doc.writexml(out)