def copy_out(self, sourcepaths, dstpath, uid=None, gid=None, mode="0644", sameuser=False): realsources = [os.path.abspath(self.path + "/" + path) for path in sourcepaths] if sameuser: from jurtlib.cmd import run args = self.manager.putcopycmd[:] args.extend(realsources) args.append(dstpath) run(args) else: self.manager.su().copyout(realsources, dstpath, uid=uid, gid=gid, mode=mode)
def copy_in(self, localsrcpath, rootdestpath, uid=None, gid=None, mode="0644", cheap=False, sameuser=False): realdestpath = os.path.abspath(self.path + "/" + rootdestpath) destpath = os.path.join(rootdestpath, os.path.basename(localsrcpath)) if sameuser: from jurtlib.cmd import run args = self.manager.putcopycmd[:] args.append(localsrcpath) args.append(realdestpath) run(args) else: self.manager.su().copy(localsrcpath, realdestpath, uid=uid, gid=gid, mode=mode) return destpath
def _medias_from_system(self): try: logger.debug("running %s", self.listmediascmd) output, _ = cmd.run(self.listmediascmd) except CommandError, e: raise PackageManagerError, ("failed to discover repository " "information from the system: %s" % (e))
def _get_packager(self): packager = self.packager if packager is None: args = self.rpmpackagercmd[:] try: output, _ = cmd.run(args) except cmd.CommandError, e: logger.error("error while getting packager macro: %s" % (e)) packager = self.defpackager else: if "PACKAGER_UNDEFINED" in output: packager = self.defpackager else: packager = output.strip()
def system_arch(self): output, _ = cmd.run(self.rpmarchcmd) return output.strip()
def update_repository_metadata(self, path): # FIXME filedeps! args = self.genhdlistcmd[:] args.append(path) cmd.run(args)
def update_repository_metadata(self, path): vars = {"path": path} args = [template_expand(arg, vars) for arg in self.spoolupdatecmd[:]] cmd.run(args)
def test_run(self): output, status = run(["true"]) self.assertEquals(output, "") self.assertEquals(status, 0)
def test_stderr(self): args = ["python", "-c", r"import sys; sys.stderr.write('oops\n');"] output, status = run(args) self.assertEquals(output, "oops\n") self.assertEquals(status, 0)
def test_error(self): output, status = run(["false"]) self.assertEquals(output, "") self.assertEquals(status, 1) self.assertRaises(CommandError, run, ["false"], error=True)