def call(self, cmd, **kwargs):
        """A simple subprocess wrapper"""
        if isinstance(cmd, basestring):
            cmd = cmd.split()
        self.log.info('Running %s', cmd)
        p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE, **kwargs)
        out, err = p.communicate()
        if out:
            self.log.info(out)
        if err:
            if p.returncode == 0:
                self.log.info(err)
            else:
                self.log.error(err)
        if p.returncode != 0:
            self.log.error('returncode = %d' % p.returncode)
            raise Exception
        return out, err, p.returncode
def call ( self , cmd , ** kwargs ) : if isinstance ( cmd , basestring ) : cmd = cmd . split ( ) self . log . info ( 'Running %s' , cmd ) p = subprocess . Popen ( cmd , stdout = subprocess . PIPE , stderr = subprocess . PIPE , ** kwargs ) out , err = p . communicate ( ) if out : self . log . info ( out ) if err : if p . returncode == 0 : self . log . info ( err ) else : self . log . error ( err ) if p . returncode != 0 : self . log . error ( 'returncode = %d' % p . returncode ) raise Exception return out , err , p . returncode
A simple subprocess wrapper