當前位置: 首頁>>代碼示例>>Python>>正文


Python Command.append方法代碼示例

本文整理匯總了Python中rpg.command.Command.append方法的典型用法代碼示例。如果您正苦於以下問題:Python Command.append方法的具體用法?Python Command.append怎麽用?Python Command.append使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rpg.command.Command的用法示例。


在下文中一共展示了Command.append方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_command_concat

# 需要導入模塊: from rpg.command import Command [as 別名]
# 或者: from rpg.command.Command import append [as 別名]
 def test_command_concat(self):
     cmd = Command("cd %s" % self.test_project_dir)
     cmd.append("cmake ..")
     cmd.append(["make", "make test"])
     self.assertRaises(TypeError, cmd.append, 4)
     expected = "cd %s\ncmake ..\nmake\nmake test" % self.test_project_dir
     self.assertEqual(expected, str(cmd))
開發者ID:regeciovad,項目名稱:rpg,代碼行數:9,代碼來源:test_command.py

示例2: patched

# 需要導入模塊: from rpg.command import Command [as 別名]
# 或者: from rpg.command.Command import append [as 別名]
 def patched(self, project_dir, spec, sack):
     if (project_dir / "CMakeLists.txt").is_file():
         spec.BuildRequires.add("cmake")
         logging.debug('CMakeLists.txt found')
         build = Command()
         build.append("cmake .")
         build.append("make")
         install = Command("make install DESTDIR=$RPM_BUILD_ROOT")
         spec.build = build
         spec.install = install
開發者ID:FLuptak,項目名稱:rpg,代碼行數:12,代碼來源:cmake.py

示例3: patched

# 需要導入模塊: from rpg.command import Command [as 別名]
# 或者: from rpg.command.Command import append [as 別名]
 def patched(self, project_dir, spec, sack):
     """ Appends commands to build Project with CMake build system """
     if (project_dir / "CMakeLists.txt").is_file():
         spec.BuildRequires.add("cmake")
         logging.debug("CMakeLists.txt found")
         build = Command()
         build.append("cmake .")
         build.append("%{make_build}")
         install = Command('make install DESTDIR="$RPM_BUILD_ROOT"')
         _parse(project_dir, spec)
         spec.build = build
         spec.install = install
開發者ID:jsilhan,項目名稱:rpg,代碼行數:14,代碼來源:cmake.py

示例4: patched

# 需要導入模塊: from rpg.command import Command [as 別名]
# 或者: from rpg.command.Command import append [as 別名]
 def patched(self, project_dir, spec, sack):
     """ Appends commands to build project with Autotools build system
         and appends dependencies """
     if (project_dir / "configure").is_file():
         logging.debug('configure found')
         spec.build.append(["%{configure}", "%{make_build}"])
         spec.install.append(['make install DESTDIR="$RPM_BUILD_ROOT"'])
     elif ((project_dir / "configure.ac").is_file() and
           (project_dir / "Makefile.am").is_file()):
         logging.debug('configure.ac and Makefile.am found')
         spec.BuildRequires.update(["autoconf", "automake", "libtool"])
         build = Command()
         if (project_dir / "autogen.sh").is_file():
             logging.debug('autogen.sh found')
             build.append("./autogen.sh")
         else:
             build.append("autoreconf --install --force")
         build.append("%{configure}")
         build.append("%{make_build}")
         spec.build = build
         spec.install = Command("make install DESTDIR=\"$RPM_BUILD_ROOT\"")
     elif (project_dir / "configure.ac").is_file():
         logging.warning('configure.ac found, Makefile.am missing')
     elif (project_dir / "Makefile.am").is_file():
         logging.warning('Makefile.am found, configure.ac missing')
開發者ID:LukasSlouka,項目名稱:rpg,代碼行數:27,代碼來源:autotools.py

示例5: patched

# 需要導入模塊: from rpg.command import Command [as 別名]
# 或者: from rpg.command.Command import append [as 別名]
 def patched(self, project_dir, spec, sack):
     if (project_dir / "pom.xml").is_file():
         logging.debug('pom.xml found')
         spec.BuildRequires.add("maven-local")
         spec.build = Command('%mvn_build -f')
         install = Command()
         install.append('xmvn-install -R .xmvn-reactor -n ' +
                        spec.Name + ' -d "$RPM_BUILD_ROOT"')
         install.append('jdir=target/site/apidocs; [ -d .xmvn/apidocs ] '
                        '&& jdir=.xmvn/apidocs; '
                        'if [ -d "${jdir}" ]; then '
                        'install -dm755 "$RPM_BUILD_ROOT"/usr/share/'
                        'javadoc/' + spec.Name + '; '
                        'cp -pr "${jdir}"/* "$RPM_BUILD_ROOT"/usr/share/'
                        'javadoc/' + spec.Name + '; '
                        'echo \'/usr/share/javadoc/' + spec.Name +
                        '\' >>.mfiles-javadoc; fi')
         spec.install = install
開發者ID:timhughes,項目名稱:rpg,代碼行數:20,代碼來源:maven.py

示例6: patched

# 需要導入模塊: from rpg.command import Command [as 別名]
# 或者: from rpg.command.Command import append [as 別名]
 def patched(self, project_dir, spec, sack):
     if (project_dir / "configure").is_file():
         logging.debug("configure found")
         build = Command()
         build.append("./configure")
         build.append("make")
         spec.build = build
         spec.install = Command('make install DESTDIR="$RPM_BUILD_ROOT"')
     elif (project_dir / "configure.ac").is_file() and (project_dir / "Makefile.am").is_file():
         logging.debug("configure.ac and Makefile.am found")
         spec.BuildRequires.add("autoconf")
         spec.BuildRequires.add("automake")
         spec.BuildRequires.add("libtool")
         f = (project_dir / "configure.ac").open()
         regex = re.compile(r"PKG_CHECK_MODULES\s*\(.*?,\s*(.*?)\s*?[,\)]", re.DOTALL)
         deps = _extract_dependencies(regex, f)
         for dep in deps:
             spec.BuildRequires.add(dep)
         build = Command()
         if (project_dir / "autogen.sh").is_file():
             logging.debug("autogen.sh found")
             build.append("./autogen.sh")
         else:
             build.append("autoreconf --install --force")
         build.append("./configure")
         build.append("make")
         spec.build = build
         spec.install = Command('make install DESTDIR="$RPM_BUILD_ROOT"')
     elif (project_dir / "configure.ac").is_file():
         logging.warning("configure.ac found, Makefile.am missing")
     elif (project_dir / "Makefile.am").is_file():
         logging.warning("Makefile.am found, configure.ac missing")
開發者ID:pan0007,項目名稱:test,代碼行數:34,代碼來源:autotools.py

示例7: SourceLoader

# 需要導入模塊: from rpg.command import Command [as 別名]
# 或者: from rpg.command.Command import append [as 別名]
class SourceLoader(object):

    def __init__(self):
        self.prep = Command()

    def extract(self, arch, extract, compr):
        """ Extracts files from archive """

        prep = Command()
        if compr[0] == "tar":
            tar_compr = ""
            if compr[1] == "xz":
                tar_compr = "J"
            elif compr[1] == "gz":
                tar_compr = "z"
            elif compr[1] == "bz2":
                tar_compr = "j"
            elif compr[1] == "lz":
                tar_compr = "--lzip "
            elif compr[1] == "xz":
                tar_compr = "z"
            elif compr[1] == "lzma":
                tar_compr = "--lzma "
            else:
                raise SystemExit("Internal error: Unknown compression \
                    method: " + compr)
            prep.append("tar " + tar_compr + "xf " +
                        arch + " -C " + extract)
        elif compr[0] == "tgz":
            prep.append("tar xzf " + arch + " -C " + extract)
        elif compr[0] == "tbz2":
            prep.append("tar xjf " + arch + " -C " + extract)
        elif compr[0] == "zip":
            prep.append("unzip " + arch + " -d " + extract)
        elif compr[0] == "rar":
            prep.append("unrar x " + arch + " " + extract)
        elif compr[0] == "7z":
            prep.append("7z x " + arch + " -o " + extract)
        else:
            raise SystemExit("Internal error: Unknown compression \
                method: " + compr[0] + "." + compr[1])
        prep.execute()
        self.prep.append(str(prep))

    def copy_dir(self, path, ex_dir):
        """ Copies directory tree and adds command to
            prep macro """

        prep = Command("cp -rf " + path + " " + ex_dir)
        prep.execute()
        self.prep.append(str(prep))

    def process(self, ext_dir):
        i = 0
        direc = ""
        for path in Path(ext_dir).iterdir():
            i += 1
            direc = str(path)
        if i < 2:
            if isdir(direc):
                Command('mv ' + direc + '/* ' + ext_dir +
                        'rmdir ' + direc)

    def load_sources(self, source_path, extraction_dir):
        """Extracts archive to extraction_dir and adds a flag for %prep section
        to create root directory if necessary. If argument is a directory,
        copy the directory to desired location. May raise IOError """

        logging.debug('load_sources({}, {}) called'
                      .format(str(source_path), str(extraction_dir)))
        path = str(source_path)
        extraction_dir = str(extraction_dir)
        if isfile(path):
            compression = self.get_compression_method(path)
            if not compression:
                raise IOError("Input source archive '{}' is incompatible!"
                              .format(path))
            self.extract(path, extraction_dir, compression)
        elif isdir(path):
            self.copy_dir(path, extraction_dir)
        else:
            raise IOError("Input source archive/directory '{}' doesn't exists!"
                          .format(path))
        self.process(extraction_dir)
        return self.prep

    @staticmethod
    def create_archive(path, output_dir):
        """ Creates archive from folder """

        name = str(path) + ".tar.gz"
        if isdir(str(output_dir)) or \
                isfile(str(output_dir)):
            Command("tar czf " + name + " " + str(output_dir)).execute()
            return name
        else:
            raise IOError("File/directory was not found!")

    @staticmethod
    def get_compression_method(name):
#.........這裏部分代碼省略.........
開發者ID:Shootervm,項目名稱:rpg,代碼行數:103,代碼來源:source_loader.py

示例8: extract

# 需要導入模塊: from rpg.command import Command [as 別名]
# 或者: from rpg.command.Command import append [as 別名]
    def extract(self, arch, extract, compr):
        """ Extracts files from archive """

        prep = Command()
        if compr[0] == "tar":
            tar_compr = ""
            if compr[1] == "xz":
                tar_compr = "J"
            elif compr[1] == "gz":
                tar_compr = "z"
            elif compr[1] == "bz2":
                tar_compr = "j"
            elif compr[1] == "lz":
                tar_compr = "--lzip "
            elif compr[1] == "xz":
                tar_compr = "z"
            elif compr[1] == "lzma":
                tar_compr = "--lzma "
            else:
                raise SystemExit("Internal error: Unknown compression \
                    method: " + compr)
            prep.append("tar " + tar_compr + "xf " +
                        arch + " -C " + extract)
        elif compr[0] == "tgz":
            prep.append("tar xzf " + arch + " -C " + extract)
        elif compr[0] == "tbz2":
            prep.append("tar xjf " + arch + " -C " + extract)
        elif compr[0] == "zip":
            prep.append("unzip " + arch + " -d " + extract)
        elif compr[0] == "rar":
            prep.append("unrar x " + arch + " " + extract)
        elif compr[0] == "7z":
            prep.append("7z x " + arch + " -o " + extract)
        else:
            raise SystemExit("Internal error: Unknown compression \
                method: " + compr[0] + "." + compr[1])
        prep.execute()
        self.prep.append(str(prep))
開發者ID:Shootervm,項目名稱:rpg,代碼行數:40,代碼來源:source_loader.py


注:本文中的rpg.command.Command.append方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。