• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python misc.execCmd函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _launchSupervdsm

 def _launchSupervdsm(self):
     self._authkey = str(uuid.uuid4())
     self._log.debug("Launching Super Vdsm")
     superVdsmCmd = [constants.EXT_PYTHON, SUPERVDSM,
                     self._authkey, str(os.getpid())]
     misc.execCmd(superVdsmCmd, sync=False)
     sleep(2)
开发者ID:openSUSE,项目名称:vdsm,代码行数:7,代码来源:supervdsm.py


示例2: removeBridge

 def removeBridge(self, bridge):
     ifdown(bridge.name)
     self._removeSourceRoute(bridge)
     execCmd([constants.EXT_BRCTL, 'delbr', bridge.name])
     self.configApplier.removeBridge(bridge.name)
     if bridge.port:
         bridge.port.remove()
开发者ID:hackxay,项目名称:vdsm,代码行数:7,代码来源:ifcfg.py


示例3: _killSupervdsm

 def _killSupervdsm(self):
     try:
         with open(PIDFILE, "r") as f:
             pid = int(f.read().strip())
         misc.execCmd([constants.EXT_KILL, "-9", str(pid)])
     except Exception, ex:
         self._log.debug("Could not kill old Super Vdsm %s", ex)
开发者ID:openSUSE,项目名称:vdsm,代码行数:7,代码来源:supervdsm.py


示例4: _removeFile

    def _removeFile(filename):
        """Remove file, umounting ovirt config files if needed."""

        mounts = open('/proc/mounts').read()
        if ' /config ext3' in mounts and ' %s ext3' % filename in mounts:
            execCmd([constants.EXT_UMOUNT, '-n', filename])
        utils.rmFile(filename)
        logging.debug("Removed file %s", filename)
开发者ID:lukas-bednar,项目名称:vdsm,代码行数:8,代码来源:ifcfg.py


示例5: removeBridge

 def removeBridge(self, bridge):
     DynamicSourceRoute.addInterfaceTracking(bridge)
     ifdown(bridge.name)
     self._removeSourceRoute(bridge)
     execCmd([constants.EXT_BRCTL, "delbr", bridge.name])
     self.configApplier.removeBridge(bridge.name)
     if bridge.port:
         bridge.port.remove()
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:8,代码来源:ifcfg.py


示例6: _persistentBackup

    def _persistentBackup(cls, filename):
        """ Persistently backup ifcfg-* config files """
        if os.path.exists("/usr/libexec/ovirt-functions"):
            execCmd([constants.EXT_SH, "/usr/libexec/ovirt-functions", "unmount_config", filename])
            logging.debug("unmounted %s using ovirt", filename)

        (dummy, basename) = os.path.split(filename)
        if os.path.exists(filename):
            content = open(filename).read()
        else:
            # For non-exists ifcfg-* file use predefined header
            content = cls.DELETED_HEADER + "\n"
        logging.debug("backing up %s: %s", basename, content)

        cls.writeBackupFile(netinfo.NET_CONF_BACK_DIR, basename, content)
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:15,代码来源:ifcfg.py


示例7: testExec

    def testExec(self):
        """
        Tests that execCmd execs and returns the correct ret code
        """
        ret, out, err = misc.execCmd([EXT_ECHO], sudo=False)

        self.assertEquals(ret, 0)
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:7,代码来源:miscTests.py


示例8: _genInitramfs

def _genInitramfs():
    logging.warning('Generating a temporary initramfs image')
    fd, path = tempfile.mkstemp()
    cmd = [_mkinitrd.cmd, "-f", path, _kernelVer]
    rc, out, err = execCmd(cmd)
    os.chmod(path, 0o644)
    return path
开发者ID:aiminickwong,项目名称:vdsm,代码行数:7,代码来源:virtTests.py


示例9: runScanArgs

def runScanArgs(*args):
    cmd = [_virtAlignmentScan.cmd]
    cmd.extend(args)
    # TODO: remove the environment variable when the issue in
    # virt-alignment-scan/libvirt is resolved
    # http://bugzilla.redhat.com/1151838
    return execCmd(cmd, env={'LIBGUESTFS_BACKEND': 'direct'})
开发者ID:kanalun,项目名称:vdsm,代码行数:7,代码来源:alignmentScan.py


示例10: writeLargeData

    def writeLargeData(self):
        data = """The Doctor: Davros, if you had created a virus in your
                              laboratory, something contagious and infectious
                              that killed on contact, a virus that would
                              destroy all other forms of life; would you allow
                              its use?
                  Davros: It is an interesting conjecture.
                  The Doctor: Would you do it?
                  Davros: The only living thing... The microscopic organism...
                          reigning supreme... A fascinating idea.
                  The Doctor: But would you do it?
                  Davros: Yes; yes. To hold in my hand, a capsule that
                          contained such power. To know that life and death on
                          such a scale was my choice. To know that the tiny
                          pressure on my thumb, enough to break the glass,
                          would end everything. Yes! I would do it! That power
                          would set me up above the gods! And through the
                          Daleks, I shall have that power! """
                  # (C) BBC - Doctor Who

        data = data * ((4096 / len(data)) * 2)
        self.assertTrue(data > 4096)
        p = misc.execCmd([EXT_CAT], sync=False)
        self.log.info("Writing data to std out")
        p.stdin.write(data)
        p.stdin.flush()
        self.log.info("Written data reading")
        self.assertEquals(p.stdout.read(len(data)), data)
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:28,代码来源:miscTests.py


示例11: __udevVersion

 def __udevVersion(self):
     cmd = [EXT_UDEVADM, '--version']
     rc, out, err = misc.execCmd(cmd, sudo=False)
     if rc:
         self.log.error("Udevadm version command failed rc=%s, "
                        " out=\"%s\", err=\"%s\"", rc, out, err)
         raise RuntimeError("Could not get udev version number")
     return int(out[0])
开发者ID:hackxay,项目名称:vdsm,代码行数:8,代码来源:supervdsmServer.py


示例12: test

 def test(self):
     args = [EXT_SLEEP, "4"]
     sproc = misc.execCmd(args, sync=False, sudo=False)
     try:
         self.assertEquals(misc.getCmdArgs(sproc.pid), tuple(args))
     finally:
         sproc.kill()
         sproc.wait()
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:8,代码来源:miscTests.py


示例13: _ifup

    def _ifup(netIf):
        rc, out, err = execCmd([constants.EXT_IFUP, netIf], raw=False)

        if rc != 0:
            # In /etc/sysconfig/network-scripts/ifup* the last line usually
            # contains the error reason.
            raise ConfigNetworkError(ne.ERR_FAILED_IFUP, out[-1] if out else "")
        return rc, out, err
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:8,代码来源:ifcfg.py


示例14: udevTrigger

 def udevTrigger(self, guid):
     self.__udevReloadRules(guid)
     cmd = [EXT_UDEVADM, 'trigger', '--verbose', '--action', 'change',
            '--property-match=DM_NAME=%s' % guid]
     rc, out, err = misc.execCmd(cmd, sudo=False)
     if rc:
         raise OSError(errno.EINVAL, "Could not trigger change for device \
                       %s, out %s\nerr %s" % (guid, out, err))
开发者ID:hackxay,项目名称:vdsm,代码行数:8,代码来源:supervdsmServer.py


示例15: testSudo

 def testSudo(self):
     """
     Tests that when running with sudo the user really is root (or other
     desired user).
     """
     cmd = [EXT_WHOAMI]
     checkSudo(cmd)
     ret, stdout, stderr = misc.execCmd(cmd, sudo=True)
     self.assertEquals(stdout[0], SUDO_USER)
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:9,代码来源:miscTests.py


示例16: testWaitCond

 def testWaitCond(self):
     ttl = 2
     p = misc.execCmd([EXT_SLEEP, str(ttl + 10)], sudo=False, sync=False)
     startTime = time.time()
     p.wait(cond=lambda: time.time() - startTime > ttl)
     duration = time.time() - startTime
     self.assertTrue(duration < (ttl + 2))
     self.assertTrue(duration > (ttl))
     p.kill()
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:9,代码来源:miscTests.py


示例17: testZombie

 def testZombie(self):
     args = [EXT_SLEEP, "0"]
     sproc = misc.execCmd(args, sync=False, sudo=False)
     sproc.kill()
     try:
         test = lambda: self.assertEquals(misc.getCmdArgs(sproc.pid),
                                          tuple())
         utils.retry(AssertionError, test, tries=10, sleep=0.1)
     finally:
         sproc.wait()
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:10,代码来源:miscTests.py


示例18: testStdOut

 def testStdOut(self):
     """
     Tests that execCmd correctly returns the standard output of the prog it
     executes.
     """
     line = "All I wanted was to have some pizza, hang out with dad, " + \
            "and not let your weirdness mess up my day"
     # (C) Nickolodeon - Invader Zim
     ret, stdout, stderr = misc.execCmd((EXT_ECHO, line), sudo=False)
     self.assertEquals(stdout[0], line)
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:10,代码来源:miscTests.py


示例19: testValidInputFalse

    def testValidInputFalse(self):
        """
        Test that is work when given valid but incorrect input.
        """
        count = 802
        with tempfile.NamedTemporaryFile() as f:
            cmd = [EXT_DD, "bs=1", "if=/dev/urandom", 'of=%s' % f.name,
                   'count=%d' % count]
            rc, out, err = misc.execCmd(cmd, sudo=False)

        self.assertFalse(misc.validateDDBytes(err, count + 1))
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:11,代码来源:miscTests.py


示例20: testNice

    def testNice(self):
        cmd = ["sleep", "10"]
        proc = misc.execCmd(cmd, sudo=False, nice=10, sync=False)

        def test():
            nice = utils.pidStat(proc.pid).nice
            self.assertEquals(nice, 10)

        utils.retry(AssertionError, test, tries=10, sleep=0.1)
        proc.kill()
        proc.wait()
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:11,代码来源:miscTests.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python storagetypes.make_key函数代码示例发布时间:2022-05-27
下一篇:
Python storage.Storage类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap