xentaur
diff xentaur.py @ 4:98c2dffcf484
The games with the write screen timeouts
author | igor |
---|---|
date | Sun Jul 15 10:57:30 2007 +0300 (2007-07-15) |
parents | 2c6cfa822bd8 |
children | 83a41d802a52 |
line diff
1.1 --- a/xentaur.py Fri Jul 13 20:57:09 2007 +0300 1.2 +++ b/xentaur.py Sun Jul 15 10:57:30 2007 +0300 1.3 @@ -13,8 +13,8 @@ 1.4 1.5 def create_bridges_script(): 1.6 unbound_bridges=bridges 1.7 - create_unbound_bridges="\n".join(map(lambda x: "brctl show | awk '{print $1}' | grep -q "+x+" || brctl addbr "+x, unbound_bridges)) 1.8 - create_unbound_bridges+="\n"+"\n".join(map(lambda x: "ip link set "+x+" up", unbound_bridges)) 1.9 + 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)) 1.10 + create_unbound_bridges+="\n"+"\n".join(map(lambda x: "sudo /bin/ip link set "+x+" up", unbound_bridges)) 1.11 1.12 print """#!/bin/sh 1.13 # create unbound bridges 1.14 @@ -24,11 +24,11 @@ 1.15 1.16 def create_domains_script(): 1.17 for N in range(len(domains)): 1.18 - 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" 1.19 + 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" 1.20 1.21 def destroy_domains_script(): 1.22 for N in range(len(domains)): 1.23 - print "xm shutdown "+domains[N] 1.24 + print "sudo /usr/sbin/xm shutdown "+domains[N] 1.25 1.26 def create_screens_script(): 1.27 1.28 @@ -40,11 +40,12 @@ 1.29 N+=1 1.30 screenlist="\n".join(screens) 1.31 1.32 +#hardstatus string "\%{gk}\%c \%{yk}\%M\%d \%{wk}\%?\%-Lw\%?\%{bw}\%n*\%f\%t\%?(\%u)\%?\%{wk}\%?\%+Lw\%?" 1.33 print """ 1.34 + 1.35 cat <<SCREENRC > screenrc 1.36 hardstatus on 1.37 hardstatus alwayslastline 1.38 -hardstatus string "%{gk}%c %{yk}%M%d %{wk}%?%-Lw%?%{bw}%n*%f%t%?(%u)%?%{wk}%?%+Lw%?" 1.39 1.40 screen -t console 0 bash 1.41 %(screenlist)s 1.42 @@ -148,7 +149,7 @@ 1.43 ipshell() 1.44 1.45 def stop_all(): 1.46 - destroy_domains_script(domains) 1.47 + destroy_domains_script() 1.48 1.49 def show_usage(): 1.50 print """Usage: 1.51 @@ -175,6 +176,7 @@ 1.52 def brake_link(domain,bridge): 1.53 broken_links.append([domain,bridge]) 1.54 1.55 +wt_timeout=0.5 1.56 def write_to(screen,string): 1.57 """ 1.58 write_to(screen,string): 1.59 @@ -183,14 +185,19 @@ 1.60 1.61 """ 1.62 screen_number=screen 1.63 - f=open('/tmp/xentaurbuf', 'w') 1.64 - f.write(string) 1.65 - f.close() 1.66 - run_command("screen -X readreg p /tmp/xentaurbuf") 1.67 run_command("screen -X select "+str(screen_number)) 1.68 - run_command("nohup screen -X paste p >& /dev/null") 1.69 - time.sleep(0.05) 1.70 + time.sleep(wt_timeout) 1.71 + for line in string.splitlines(): 1.72 + f=open('/tmp/xentaurbuf', 'w') 1.73 + f.write(line+"\n") 1.74 + f.close() 1.75 + run_command("screen -X readreg p /tmp/xentaurbuf") 1.76 + time.sleep(wt_timeout) 1.77 + run_command("nohup screen -X paste p >& /dev/null") 1.78 + time.sleep(wt_timeout) 1.79 + 1.80 run_command("screen -X select 0") 1.81 + #time.sleep(wt_timeout) 1.82 1.83 #----------------------------------------------------------------------- 1.84