當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。