def _copyFile(self, filepath1, filepath2): p = subprocess.Popen("scp '%s' '%s'" % (filepath1, filepath2), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) (out, err) = p.communicate() if p.returncode: raise ShellCmdException(err)
def _shellcmd(self, command, cwd = None): if cwd is None: cwd = self.be.sourcedir p = subprocess.Popen("ssh %s 'cd %s && %s'" % (self.be.address, cwd, command), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) (out,err) = p.communicate() if p.returncode: if len(err) == 0: err = "command: %s \n%s" % (command, out) else: err = "command: %s \n%s" % (command, err) raise ShellCmdException(err) else: return out.strip()
def _shellcmd(self, command, cwd = None): if cwd is None: cwd = self.be.sourcedir p = subprocess.Popen(command, cwd = cwd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out,err) = p.communicate() if p.returncode: if len(err) == 0: err = "command: %s \n%s" % (command, out) else: err = "command: %s \n%s" % (command, err) logger.debug("localhostbecontroller: shellcmd error %s" % err) raise ShellCmdException(err) else: logger.debug("localhostbecontroller: shellcmd success") return out