From 36b963e1de245bb647398c316d692ca2c6420f54 Mon Sep 17 00:00:00 2001 From: thierry Date: Tue, 26 Jan 2010 17:36:27 +0000 Subject: [PATCH] avoid annoying warnings from ssh when loopbacking towards liquid --- scripts/manage-infrastructure.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/scripts/manage-infrastructure.py b/scripts/manage-infrastructure.py index ac8bd0f..f9983ec 100755 --- a/scripts/manage-infrastructure.py +++ b/scripts/manage-infrastructure.py @@ -30,16 +30,25 @@ class BuildBoxes: def header (self,message): print "===============",message - def run (self,argv,message): + def run (self,argv,message, trash_err=False): if self.options.dry_run: print 'DRY_RUN:', print " ".join(argv) else: if message: self.header(message) - subprocess.call(argv) + if not trash_err: + subprocess.call(argv) + else: + subprocess.call(argv,stderr=file('/dev/null','w')) - def backquote (self, argv): - return subprocess.Popen(argv,stdout=subprocess.PIPE).communicate()[0] + def backquote (self, argv, trash_err=False): + if not trash_err: + return subprocess.Popen(argv,stdout=subprocess.PIPE).communicate()[0] + else: + null = open('/dev/null','w') + result = subprocess.Popen(argv,stdout=subprocess.PIPE,stderr=null).communicate()[0] + null.close() + return result def reboot (self,box): command=['ssh',self.root(box),'shutdown','-r','now'] @@ -59,18 +68,18 @@ class BuildBoxes: self.reboot(box) else: command=['ssh',self.root(box),'uptime'] - uptime=self.backquote(command).strip() + uptime=self.backquote(command,True).strip() command=['ssh',self.root(box),'pgrep','build'] if self.options.dry_run: self.run(command,None) else: - pids=self.backquote(command) + pids=self.backquote(command,True) if not pids: self.header ('No build process on %s (%s)'%(box,uptime)) else: command=['ssh',self.root(box),'ps','-o','pid,command'] + [ pid for pid in pids.split("\n") if pid] - self.run(command,"Active build processes on %s (%s)"%(box,uptime)) + self.run(command,"Active build processes on %s (%s)"%(box,uptime),True) vplc_matcher = re.compile(".*(vplc[0-9]+$)") def vplcname (self, vservername): -- 2.43.0