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']
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):