当前位置: 首页>>代码示例>>Python>>正文


Python utils.shell_exec函数代码示例

本文整理汇总了Python中utils.shell_exec函数的典型用法代码示例。如果您正苦于以下问题:Python shell_exec函数的具体用法?Python shell_exec怎么用?Python shell_exec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了shell_exec函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: rc_update

    def rc_update (self, clobberSwitch=False) :
        """effects: do our part of rc update"""
        if not os.path.isdir (self.dir()) :
            return
        svninfo = SvnInfoSvn (None, self.dir())
        self = self.useSvnuser (svninfo.svnuser())
        self = self.resolveTags ()

        if self.tag() != svninfo.tag() :
            cmd = ["svn", "switch", self.m_url]
            if not clobberSwitch :
                status = "\n" + self.svn_status()
                if status.find ("\nM") != -1 or status.find ("\nC") != -1:
                    print "you currently have changes in package " + self.name()
                    print "either check them in, or switch versions manually using:"
                    print "  cd " + self.dir()
                    print "  " + " ".join(cmd)
                    #print "  " + string.join (cmd, " ")
                    return
                pass
            print "switching " + self.name() + " to " + self.tag()
            shell_exec (cmd, workDir=self.dir(), retries=2, noReturn=True)
            return

        if os.path.basename (os.path.dirname (self.m_url)) == "tags" :
            print "package " + self.name() + " already at version " + self.tag()
            return

        print "updating " + svninfo.name() + " from head"
        shell_exec (["svn", "update"], workDir=self.dir(), retries=2, noReturn=True)
        return
开发者ID:akels,项目名称:SUSYUpgradeAnalysis,代码行数:31,代码来源:svninfo.py

示例2: step_mount_partitions

    def step_mount_partitions(self, setup):
        self.step_mount_source(setup)

        # Mount the target partition
        for partition in setup.partitions:
            if(partition.mount_as is not None and partition.mount_as != ""):
                  if partition.mount_as == "/":
                        self.update_progress(total=4, current=3, message=_("Mounting %(partition)s on %(mountpoint)s") % {'partition':partition.partition.path, 'mountpoint':"/target/"})
                        print " ------ Mounting partition %s on %s" % (partition.partition.path, "/target/")
                        if partition.type == "fat32":
                            fs = "vfat"
                        else:
                            fs = partition.type
                        self.do_mount(partition.partition.path, "/target", fs, None)
                        break

        # Mount the other partitions
        for partition in setup.partitions:
            if(partition.mount_as is not None and partition.mount_as != "" and partition.mount_as != "/" and partition.mount_as != "swap"):
                print " ------ Mounting %s on %s" % (partition.partition.path, "/target" + partition.mount_as)
                shell_exec("mkdir -p /target" + partition.mount_as)
                if partition.type == "fat16" or partition.type == "fat32":
                    fs = "vfat"
                else:
                    fs = partition.type
                self.do_mount(partition.partition.path, "/target" + partition.mount_as, fs, None)
开发者ID:pombredanne,项目名称:linuxtrail,代码行数:26,代码来源:installer.py

示例3: manually_edit_partitions

def manually_edit_partitions():
    """ Edit only known disks in gparted, selected one first """
    model, itr = installer.go("treeview_disks").get_selection().get_selected()
    preferred = model[itr][-1] if itr else ''  # prefer disk currently selected and show it first in gparted
    disks = ' '.join(sorted((disk for disk, desc, sdd, detachable in installer.setup.disks), key=lambda disk: disk != preferred))
    shell_exec('umount -f ' + disks)  # umount disks (if possible) so gparted works out-of-the-box
    shell_exec('gparted {} &'.format(disks))
开发者ID:SolydXK,项目名称:live-installer-3,代码行数:7,代码来源:partitioning.py

示例4: root_conf

    def root_conf(self):
        """effects: determine the root parameters used for compilation
        returns: the path to the configuration file generated
        failures: incompatible root installation"""
        if not self.m_root_conf:
            file = os.path.join(self.bin(), "root_config_" + self.arch())
            ROOTSYS = os.getenv("ROOTSYS")
            if ROOTSYS == None:
                if os.path.isfile(file):
                    ROOTSYS = get_field(file, "ROOTSYS")
                    if ROOTSYS and ROOTSYS != "":
                        raise RCError("no valid root version found, try setting up root using\n" +
                                      "  source " + ROOTSYS + "/bin/thisroot.sh")
                if os.path.isdir("/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase"):
                    raise RCError("no valid root version found, try setting up root using\n" +
                                  "  export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase\n" +
                                  "  source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh\n" +
                                  "  localSetupROOT")
                if shell_exec(["which", "root-config"], allowFail=True) != "":
                    raise RCError("no valid root version found, try setting up root using\n" +
                                  "  source `root-config --prefix`/bin/thisroot.sh")
                raise RCError("no valid root version found, please set up root")

            if os.path.isfile(file):
                myrootversion = get_field(file, "ROOT_VERSION")
                if not myrootversion:
                    set_field(file, "ROOT_VERSION", self.root_version())
                elif self.root_version() != myrootversion:
                    myrootsys = get_field(file, "ROOTSYS")
                    raise RCError("Root Version: " + self.root_version() + "\n" +
                                  "is not the same as previous version:\n" +
                                  "   " + myrootversion + "\n" +
                                  "either set up the correct root version e.g. via:\n" +
                                  "  source " + myrootsys + "/bin/thisroot.sh\n" +
                                  "or clean out the old object files via:\n" +
                                  "  rc clean")
                self.m_root_conf = file
                return file

            myarch = shell_exec(["root-config", "--etcdir"]) + "/Makefile.arch"
            if not os.path.isfile(myarch):
                myarch = os.getenv("ROOTSYS") + "/share/doc/root/test/Makefile.arch"
            if not os.path.isfile(myarch):
                shell_args = ["find", os.getenv("ROOTSYS") + "/.",
                              "-name", "Makefile.arch"]
                search = shell_exec(shell_args).strip().split("\n")
                if len(search) > 0:
                    myarch = search[0]
            if not os.path.isfile(myarch):
                raise RCError("failed to find Makefile.arch in " + os.getenv("ROOTSYS"))

            with open(file + "-", "w") as f:
                shell_args = ["make", "-f", self.dir() + "/Makefile-print",
                              "MAKEFILE_ARCH=" + myarch]
                rc = shell_exec(shell_args, stdout=f, returnRC=True)
            if rc != 0:
                raise RCError("could not determine compilation parameters")
            os.rename(file + "-", file)
            self.m_root_conf = file
        return self.m_root_conf
开发者ID:akels,项目名称:SUSYUpgradeAnalysis,代码行数:60,代码来源:workarea.py

示例5: svn_cp_tags

 def svn_cp_tags (self, tag, message):
     """effects: copy this url to the tags directory, as in 'svn cp
     -m >message< >url< >base_url</tags/>tag<'"""
     shell_exec (["svn", "cp", "-m", message, self.m_base + "/trunk",
                  self.m_base + "/tags/" + tag], noReturn=True,
                 retries=2)
     pass
开发者ID:akels,项目名称:SUSYUpgradeAnalysis,代码行数:7,代码来源:svninfo.py

示例6: copySource

 def copySource (self, target) :
     """effects: copy our source directory to the source directory
     of the target"""
     if self.srcdir() == target.srcdir():
         print "using " + self.name() + " source from release"
         pass
     else:
         print "copying " + self.name() + " source"
         ignore = [".svn", "*~"]
         if self.name() == "RootCore":
             ignore += ["bin", "include", "obj", "rootcore_config",
                        "root_config_*", "load_packages_info_*",
                        "load_packages_success", "data", "lib", "python",
                        "user_scripts"]
             pass
         rel_dir = self.m_wa.relPath (target.m_wa.area(), self.srcdir(), self.srcdir())
         if rel_dir[0] != "/" and rel_dir != ".":
             ignore.append (os.path.basename (rel_dir))
             pass
         if rel_dir != ".":
             shutil.copytree (self.srcdir(), target.srcdir(), symlinks = True,
                              ignore = shutil.ignore_patterns (*ignore))
             shell_exec (["chmod", "-R", "u+rw", target.srcdir()])
             pass
         pass
     pass
开发者ID:akels,项目名称:SUSYUpgradeAnalysis,代码行数:26,代码来源:package.py

示例7: mount_device

 def mount_device(self, device_path):
     # Check if mounted
     mount_point = get_mount_point(device_path)
     if mount_point == '':
         mount_point = TMP_MOUNTPOINT
         #print((">> mount %s ro on %s" % (device_path, mount_point)))
         shell_exec('mount --read-only {} {}'.format(device_path, mount_point))
     return mount_point
开发者ID:SolydXK,项目名称:live-installer-3,代码行数:8,代码来源:partitioning.py

示例8: svn_commit

 def svn_commit (self, message):
     """effects: commit this package, as with 'svn commit -m
     >message<'"""
     if not self.dir() :
         raise Exception ("no directory associated with the url")
     shell_exec (["git", "commit", "-a", "-m", message], workDir=self.m_dir,
                 noReturn=True)
     pass
开发者ID:akels,项目名称:SUSYUpgradeAnalysis,代码行数:8,代码来源:svninfo.py

示例9: do_mount

def do_mount(device, mountpoint, filesystem=None, options=None):
    if get_mount_point(device, mountpoint) == '':
        if options:
            if options[0:1] != '-':
                options = '-o ' + options
        else:
            options = ''
        filesystem = '-t ' + filesystem if filesystem else ''
        cmd = "mount {options} {filesystem} {device} {mountpoint}".format(**locals())
        shell_exec(cmd)
开发者ID:SolydXK,项目名称:live-installer-3,代码行数:10,代码来源:partitioning.py

示例10: stop

    def stop(self):
        """Stops vm. Destroys changes on it """
        if self.destroy_on_exit:
            if self.started:
                if self.use_libvirt:                
                    self.vm.destroy()
                else:
                    shell_exec('lxc-stop -n "{0}"'.format(self.lxc_name))

            self.fs.umount()
            shell_exec('rm -rf "{0}"'.format(self.fs.mpoint))
开发者ID:koder-ua,项目名称:vm_ut,代码行数:11,代码来源:vm.py

示例11: create_snapshot

    def create_snapshot(self):
        self.snapname = str(uuid.uuid1())
        self.snappath = os.path.join(self.mpoint, "snapshots", self.snapname)

        shell_exec('btrfs subvolume snapshot "{0}" "{1}"'.format(self.mpoint, self.mpoint))

        for subvolid, subvolume in self.subvolumes():
            if subvolume.endswith(self.snapname):
                break

        assert subvolume.endswith(self.snapname)
        self.subvolid = subvolid
开发者ID:koder-ua,项目名称:vm_ut,代码行数:12,代码来源:restorablefs.py

示例12: on_btnDelete_clicked

 def on_btnDelete_clicked(self, widget):
     selected_isos = self.tvUsbIsosHandler.getToggledValues(toggleColNr=0, valueColNr=2)
     if selected_isos:
         msg =  _("Are you sure you want to remove the selected ISO from the device?")
         answer = QuestionDialog(self.btnDelete.get_label(), msg)
         if answer:
             for iso in selected_isos:
                 iso_path = join(self.device["mount"], iso)
                 if exists(iso_path):
                     os.remove(iso_path)
                     self.log.write("Remove ISO: {}".format(iso_path))
             shell_exec("usb-creator -d {} -g".format(self.device["path"]))
             self.on_cmbDevice_changed()
             self.fill_treeview_usbcreator(self.device["mount"])
开发者ID:xaosfiftytwo,项目名称:usb-creator,代码行数:14,代码来源:usbcreator.py

示例13: rc_checkout

 def rc_checkout (self, shared=False) :
     """effects: do our part of rc checkout"""
     if os.path.isdir (self.dir()) :
         return
     print "checking out " + self.name()
     mkdir_p (os.path.dirname (self.dir()))
     if not self.m_url :
         raise RCError ("can not run rc checkout without git url")
     cmd = ["git", "clone"]
     if shared :
         cmd += ["--shared"]
         pass
     cmd += [self.m_url, self.dir()]
     shell_exec (cmd, noReturn=True)
     pass
开发者ID:akels,项目名称:SUSYUpgradeAnalysis,代码行数:15,代码来源:svninfo.py

示例14: addPkgDep

 def addPkgDep(self, name, required, caller, cycle, catalog, allowMiss, wa):
     if self.getPkg(name):
         return
     for pkg in cycle:
         if name == pkg:
             raise Exception("cyclical dependence involving packages: " +
                             string.join(cycle))
     pkg = catalog.getPkg(name)
     if not pkg:
         if allowMiss or not required:
             return
         message = ""
         if caller:
             message = "package " + name + " not known, required by " + caller
         else:
             message = "package " + name + " not known"
         shell_args = ["grep", "/" + name + "/tags", wa.dir() + "/all_packages"]
         known = shell_exec(shell_args, allowFail=True).split("\n")
         while len(known) > 0 and known[len(known) - 1] == "":
             known.remove("")
         if len(known) > 0:
             message += "\ntry checking it out with"
             for pkg in known:
                 message += "\n  rc checkout_pkg " + pkg
         raise RCError(message)
     for dep in pkg.harddep():
         addPkgDep(self, dep, True, name, cycle + [name], catalog, allowMiss, wa)
     for dep in pkg.trydep():
         addPkgDep(self, dep, False, name, cycle + [name], catalog, allowMiss, wa)
     self.addPkg(pkg)
开发者ID:akels,项目名称:SUSYUpgradeAnalysis,代码行数:30,代码来源:workarea.py

示例15: svn_status

 def svn_status (self, noReturn=False, update=False, allowNone=False):
     """effects: same as 'svn status'
     returns: the status (unless noReturn is specified)"""
     if update:
         raise RCError ("-u not supported for git status")
     return shell_exec (["git", "status", "-s"], workDir=self.m_dir,
                        noReturn=noReturn)
开发者ID:akels,项目名称:SUSYUpgradeAnalysis,代码行数:7,代码来源:svninfo.py


注:本文中的utils.shell_exec函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。