# HG changeset patch # User igor # Date 1184486250 -10800 # Node ID 98c2dffcf484aa0cf25b1ba556b4ada5ee5c49b4 # Parent 2c6cfa822bd8e5faf60f6910a2fb34a3b57fc28b The games with the write screen timeouts diff -r 2c6cfa822bd8 -r 98c2dffcf484 xentaur.py --- a/xentaur.py Fri Jul 13 20:57:09 2007 +0300 +++ b/xentaur.py Sun Jul 15 10:57:30 2007 +0300 @@ -13,8 +13,8 @@ def create_bridges_script(): unbound_bridges=bridges - create_unbound_bridges="\n".join(map(lambda x: "brctl show | awk '{print $1}' | grep -q "+x+" || brctl addbr "+x, unbound_bridges)) - create_unbound_bridges+="\n"+"\n".join(map(lambda x: "ip link set "+x+" up", unbound_bridges)) + create_unbound_bridges="\n".join(map(lambda x: "sudo /usr/sbin/brctl show | awk '{print $1}' | grep -q "+x+" || sudo /usr/sbin/brctl addbr "+x, unbound_bridges)) + create_unbound_bridges+="\n"+"\n".join(map(lambda x: "sudo /bin/ip link set "+x+" up", unbound_bridges)) print """#!/bin/sh # create unbound bridges @@ -24,11 +24,11 @@ def create_domains_script(): for N in range(len(domains)): - print "xm create xenomipsN N="+str(N)+" && sleep 1 && xm sched-credit -d $(xm list | grep "+domains[N]+" | awk '{print $2}') -c 10 && sleep 1" + print "sudo /usr/sbin/xm create xenomipsN N="+str(N)+" && sleep 1 && sudo /usr/sbin/xm sched-credit -d $(sudo /usr/sbin/xm list | grep "+domains[N]+" | awk '{print $2}') -c 10 && sleep 1" def destroy_domains_script(): for N in range(len(domains)): - print "xm shutdown "+domains[N] + print "sudo /usr/sbin/xm shutdown "+domains[N] def create_screens_script(): @@ -40,11 +40,12 @@ N+=1 screenlist="\n".join(screens) +#hardstatus string "\%{gk}\%c \%{yk}\%M\%d \%{wk}\%?\%-Lw\%?\%{bw}\%n*\%f\%t\%?(\%u)\%?\%{wk}\%?\%+Lw\%?" print """ + cat < screenrc hardstatus on hardstatus alwayslastline -hardstatus string "%{gk}%c %{yk}%M%d %{wk}%?%-Lw%?%{bw}%n*%f%t%?(%u)%?%{wk}%?%+Lw%?" screen -t console 0 bash %(screenlist)s @@ -148,7 +149,7 @@ ipshell() def stop_all(): - destroy_domains_script(domains) + destroy_domains_script() def show_usage(): print """Usage: @@ -175,6 +176,7 @@ def brake_link(domain,bridge): broken_links.append([domain,bridge]) +wt_timeout=0.5 def write_to(screen,string): """ write_to(screen,string): @@ -183,14 +185,19 @@ """ screen_number=screen - f=open('/tmp/xentaurbuf', 'w') - f.write(string) - f.close() - run_command("screen -X readreg p /tmp/xentaurbuf") run_command("screen -X select "+str(screen_number)) - run_command("nohup screen -X paste p >& /dev/null") - time.sleep(0.05) + time.sleep(wt_timeout) + for line in string.splitlines(): + f=open('/tmp/xentaurbuf', 'w') + f.write(line+"\n") + f.close() + run_command("screen -X readreg p /tmp/xentaurbuf") + time.sleep(wt_timeout) + run_command("nohup screen -X paste p >& /dev/null") + time.sleep(wt_timeout) + run_command("screen -X select 0") + #time.sleep(wt_timeout) #-----------------------------------------------------------------------