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


Python commands.getstatusoutput方法代码示例

本文整理汇总了Python中commands.getstatusoutput方法的典型用法代码示例。如果您正苦于以下问题:Python commands.getstatusoutput方法的具体用法?Python commands.getstatusoutput怎么用?Python commands.getstatusoutput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在commands的用法示例。


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

示例1: connect

# 需要导入模块: import commands [as 别名]
# 或者: from commands import getstatusoutput [as 别名]
def connect(self):
        """
        Establishes the actual connection to the referred RSE.
        As a quick and dirty impelementation we just use this method to check if the lcg tools are available.
        If we decide to use gfal, init should be done here.

        :raises RSEAccessDenied: Cannot connect.
        """

        status, lcglscommand = getstatusoutput('which lcg-ls')
        if status:
            raise exception.RSEAccessDenied('Cannot find lcg tools')
        endpoint_basepath = self.path2pfn(self.attributes['prefix'])
        status, result = getstatusoutput('%s -vv $LCGVO -b --srm-timeout 60 -D srmv2 -l %s' % (lcglscommand, endpoint_basepath))
        if status:
            if result == '':
                raise exception.RSEAccessDenied('Endpoint not reachable. lcg-ls failed with status code %s but no further details.' % (str(status)))
            else:
                raise exception.RSEAccessDenied('Endpoint not reachable : %s' % str(result)) 
开发者ID:rucio,项目名称:rucio,代码行数:21,代码来源:srm.py

示例2: _helper_installer

# 需要导入模块: import commands [as 别名]
# 或者: from commands import getstatusoutput [as 别名]
def _helper_installer(action):
    if action not in ('install', 'uninstall'):
        raise Exception('Wrong action: %s' % action)

    if IS_LINUX:
        if IS_SNAP:
            log.debug('Skipping install of helpers, '
                      'snap should have done that')
            return
        cmd = 'bitmask_helpers ' + action
        if STANDALONE:
            binary_path = os.path.join(here(), "bitmask")
            cmd = "%s %s" % (binary_path, cmd)
        if os.getuid() != 0:
            cmd = 'pkexec ' + cmd
        retcode, output = commands.getstatusoutput(cmd)
        if retcode != 0:
            log.error('Error installing/uninstalling helpers: %s' % output)
            log.error('Command was: %s' % cmd)
            raise Exception('Could not install/uninstall helpers')
    else:
        raise Exception('No install mechanism for this platform') 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:24,代码来源:privilege.py

示例3: codesignapp

# 需要导入模块: import commands [as 别名]
# 或者: from commands import getstatusoutput [as 别名]
def codesignapp(app_path):
    """
    Get codesign informatiob included in app
    About codesign: https://developer.apple.com/legacy/library/technotes/tn2250/_index.html#//apple_ref/doc/uid/DTS40009933
    Args:
        Mach-o path
    Returns:
        the content of codesign
    """
    cmd = "/usr/bin/codesign -dvvv %s" % app_path
    out = commands.getstatusoutput(cmd)
    if out and len(out) == 2 and out[0] == 0:
        out = out[1]
    else:
        out = ''
    return out 
开发者ID:NetEaseGame,项目名称:iOS-private-api-checker,代码行数:18,代码来源:codesign_utils.py

示例4: run

# 需要导入模块: import commands [as 别名]
# 或者: from commands import getstatusoutput [as 别名]
def run(self):

        # exec command
        print (self.command)

        # use terminal emulator?
        if self.use_term:
            commands.getstatusoutput(def_term + " -e 'bash -c \"" + self.command + "; read; \"'")
        
        else:
            commands.getstatusoutput(self.command)
            
        # callback
        if hasattr(self.callback, '__call__'):
           self.callback()

#
# Retarded Kill
# 
开发者ID:Frozenbox,项目名称:airmode,代码行数:21,代码来源:airmode.py

示例5: slot_monitor

# 需要导入模块: import commands [as 别名]
# 或者: from commands import getstatusoutput [as 别名]
def slot_monitor(self):
        
        if self.check_options(self.periferica_opt) == 0:
            pass
        
        elif self.intf_mode == "Monitor":
            status = commands.getstatusoutput('airmon-ng stop '  + self.periferica)
            if status[0] != 0:
                self.output(status[1], status[0])
            else:
                self.output("Monitor off: " + self.periferica, status[0])
        else:
            status = commands.getstatusoutput('airmon-ng check kill && echo y | airmon-ng start ' + self.periferica)
            if status[0] != 0:
                self.output(status[1], status[0])
            else:
                self.output("Monitor on: " + self.periferica, status[0])
        self.slot_reload_interfaces()

    #
    # Start Client Fragmentation Attack
    # 
开发者ID:Frozenbox,项目名称:airmode,代码行数:24,代码来源:airmode.py

示例6: slot_mac_change

# 需要导入模块: import commands [as 别名]
# 或者: from commands import getstatusoutput [as 别名]
def slot_mac_change(self):
        if self.check_options(self.change_mac_int_opt | self.change_mac_mac_opt | self.mymon_opn | self.intf_mode_opt) == 0:
            pass
        else:
            # backup of old MAC...
            commands.getstatusoutput('if [ -e ' + config_dir + '.macaddress-backup ]; then echo ""; else ifconfig ' + self.change_mac_int + ' | grep HWaddr | sed \'s/^.*HWaddr //\' > ' + config_dir + '.macaddress-backup; fi')
            status = commands.getstatusoutput('ifconfig ' + self.change_mac_int + ' down hw ether ' + self.change_mac_mac)
            if status[0] != 0:
                self.output(status[1], status[0])
                return
            status = commands.getstatusoutput('ifconfig ' + self.change_mac_int + ' up')
            if status[0] != 0:
                self.output(status[1], status[0])
                return
            self.output('Mac address of interface ' + self.change_mac_int + ' changed in ' + self.change_mac_mac, status[0])
            
    #
    # Enable ip forwarding
    # 
开发者ID:Frozenbox,项目名称:airmode,代码行数:21,代码来源:airmode.py

示例7: nfsExport

# 需要导入模块: import commands [as 别名]
# 或者: from commands import getstatusoutput [as 别名]
def nfsExport(self, config):
        dirpath = config["exportPath"]

        if not os.path.exists(dirpath):
            return codes.NOT_FOUND
        
        #exportcfg = "{path} *(rw,fsid=0,sync,no_root_squash)\n".format(path = dirpath)
        exportcfg = "{path} *(rw,sync,no_root_squash,nohide)\n".format(path = dirpath)
        fp = open(NFS_EXPORT_CONFIG, 'a')
        fp.write(exportcfg)
        fp.close()
        
        logging.debug("Re-exporting NFS mounts.")
        status, output = commands.getstatusoutput(NFS_EXPORT_FS)
        if status != 0:
            logging.error("NFS restart failed. {}".format(output))
            return codes.FAILED

        return codes.SUCCESS 
开发者ID:nadgowdas,项目名称:cargo,代码行数:21,代码来源:fsclient.py

示例8: checkAndGetNFSMeta

# 需要导入模块: import commands [as 别名]
# 或者: from commands import getstatusoutput [as 别名]
def checkAndGetNFSMeta(self, config):
        nfsMeta = dict() 
        volPath = config["volume"]

        status, output = commands.getstatusoutput(GET_ALL_NFS_MOUNTS)
        if status != 0:
            logging.error("mount list command failed. {}".format(output))
            return codes.FAILED
        
        if output == None:
            nfsMeta["is_nfs_mounted"] = False
            return (codes.SUCCESS, nfsMeta)

        nfsList = output.split("\n")
        for nfsmount in nfsList:
            mountPoint = nfsmount.split()[2]
            if volPath in mountPoint:
                nfsMeta["is_nfs_mounted"] = True
                nfsMeta["nfs_server"] = nfsmount.split()[0].split(":")[0]
                nfsMeta["nfs_exportpath"] = nfsmount.split()[0].split(":")[1]
                nfsMeta["nfs_mountpath"] = mountPoint
                return (codes.SUCCESS, nfsMeta) 
开发者ID:nadgowdas,项目名称:cargo,代码行数:24,代码来源:fsclient.py

示例9: download_file

# 需要导入模块: import commands [as 别名]
# 或者: from commands import getstatusoutput [as 别名]
def download_file(url, tgt_dir):
    if (not osp.exists(tgt_dir)):
        raise Exception("tgt_dir %s not found" % tgt_dir)
    fn = url.split('/')[-1] # hack hack hack
    full_fn = osp.join(tgt_dir, fn)
    if (osp.exists(full_fn)):
        print("%s exists already, skip downloading" % full_fn)
        return full_fn
    cmd = 'wget -O %s %s' % (full_fn, url)
    print("Downloading %s to %s" % (fn, tgt_dir))
    stt = time.time()
    status, msg = commands.getstatusoutput(cmd)
    if (status != 0):
        raise Exception("Downloading from %s failed: %s" % (url, msg))
    print("Downloading took %.3f seconds" % (time.time() - stt))
    return full_fn 
开发者ID:chenwuperth,项目名称:rgz_rcnn,代码行数:18,代码来源:download_data.py

示例10: shell

# 需要导入模块: import commands [as 别名]
# 或者: from commands import getstatusoutput [as 别名]
def shell():
    command_ls = 'ls -al /opt'
    command_docker = 'docker ps -a'

    # 使用os.system()模块
    ros = os.system(command_ls)
    print '\n\nos.system() : ', ros

    # 使用os.popen()模块
    output = os.popen(command_docker)
    result = output.read()
    print '\n\nos.popen() : ', result

    # 使用commands模块
    (status, output) = commands.getstatusoutput(command_docker)
    print '\n\ncommands : ', status, output 
开发者ID:tomoncle,项目名称:Python-notes,代码行数:18,代码来源:study_os.py

示例11: generate_analytics_id

# 需要导入模块: import commands [as 别名]
# 或者: from commands import getstatusoutput [as 别名]
def generate_analytics_id():
  getstatusoutput("mkdir -p  ~/.config/alibuild")
  err, output = getstatusoutput("uuidgen >  ~/.config/alibuild/analytics-uuid")
  # If an error is found while generating the unique user ID, we disable
  # the analytics on the machine.
  if err:
    debug("Could not generate unique ID for user. Disabling analytics")
    getstatusoutput("touch ~/.config/alibuild/disable-analytics")
    return False
  return True 
开发者ID:alisw,项目名称:alibuild,代码行数:12,代码来源:analytics.py

示例12: enable_analytics

# 需要导入模块: import commands [as 别名]
# 或者: from commands import getstatusoutput [as 别名]
def enable_analytics():
  if exists(expanduser("~/.config/alibuild/disable-analytics")):
    unlink(expanduser("~/.config/alibuild/disable-analytics"))
  if not exists(expanduser("~/.config/alibuild/analytics-uuid")):
    generate_analytics_id()

# We do it in getstatusoutput because python makedirs can actually fail
# if one of the intermediate directories is not writeable. 
开发者ID:alisw,项目名称:alibuild,代码行数:10,代码来源:analytics.py

示例13: disable_analytics

# 需要导入模块: import commands [as 别名]
# 或者: from commands import getstatusoutput [as 别名]
def disable_analytics():
  getstatusoutput("mkdir -p ~/.config/alibuild && touch ~/.config/alibuild/disable-analytics")
  return False 
开发者ID:alisw,项目名称:alibuild,代码行数:5,代码来源:analytics.py

示例14: systemInfo

# 需要导入模块: import commands [as 别名]
# 或者: from commands import getstatusoutput [as 别名]
def systemInfo():
  _,out = getstatusoutput("env")
  debug("Environment:\n"+out)
  _,out = getstatusoutput("uname -a")
  debug("uname -a: "+out)
  _,out = getstatusoutput("mount")
  debug("Mounts:\n"+out)
  _,out = getstatusoutput("df")
  debug("Disk free:\n"+out)
  for f in ["/etc/lsb-release", "/etc/redhat-release", "/etc/os-release"]:
    err,out = getstatusoutput("cat "+f)
    if not err:
      debug(f+":\n"+out) 
开发者ID:alisw,项目名称:alibuild,代码行数:15,代码来源:doctor.py

示例15: gzip

# 需要导入模块: import commands [as 别名]
# 或者: from commands import getstatusoutput [as 别名]
def gzip():
  return getstatusoutput("which pigz")[0] and "gzip" or "pigz" 
开发者ID:alisw,项目名称:alibuild,代码行数:4,代码来源:build.py


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