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


Python Popen.terminate_geterr方法代碼示例

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


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

示例1: get_slave_bricks_status

# 需要導入模塊: from resource import Popen [as 別名]
# 或者: from resource.Popen import terminate_geterr [as 別名]
def get_slave_bricks_status(host, vol):
    po = Popen(['gluster', '--xml', '--remote-host=' + host,
                'volume', 'status', vol, "detail"],
               stdout=PIPE, stderr=PIPE)
    vix = po.stdout.read()
    po.wait()
    po.terminate_geterr(fail_on_err=False)
    if po.returncode != 0:
        logging.info("Volume status command failed, unable to get "
                     "list of up nodes of %s, returning empty list: %s" %
                     (vol, po.returncode))
        return []
    vi = XET.fromstring(vix)
    if vi.find('opRet').text != '0':
        logging.info("Unable to get list of up nodes of %s, "
                     "returning empty list: %s" %
                     (vol, vi.find('opErrstr').text))
        return []

    up_hosts = set()

    try:
        for el in vi.findall('volStatus/volumes/volume/node'):
            if el.find('status').text == '1':
                up_hosts.add(el.find('hostname').text)
    except (ParseError, AttributeError, ValueError) as e:
        logging.info("Parsing failed to get list of up nodes of %s, "
                     "returning empty list: %s" % (vol, e))

    return list(up_hosts)
開發者ID:Byreddys,項目名稱:glusterfs,代碼行數:32,代碼來源:monitor.py

示例2: monitor

# 需要導入模塊: from resource import Popen [as 別名]
# 或者: from resource.Popen import terminate_geterr [as 別名]
def monitor(*resources):
    # Mount geo-rep management volume
    if gconf.meta_volume:
        mgmt_mnt = os.path.join(gconf.working_dir, gconf.meta_volume)
        if not os.path.exists(mgmt_mnt):
            try:
                os.makedirs(mgmt_mnt)
            except OSError:
                ex = sys.exc_info()[1]
                if ex.errno == EEXIST:
                    pass
                else:
                    raise

        if not os.path.ismount(mgmt_mnt):
            po = Popen(["mount", "-t", "glusterfs", "localhost:%s"
                        % gconf.meta_volume, mgmt_mnt], stdout=PIPE,
                       stderr=PIPE)
            po.wait()
            po.terminate_geterr()

    # Check if gsyncd restarted in pause state. If
    # yes, send SIGSTOP to negative of monitor pid
    # to go back to pause state.
    if gconf.pause_on_start:
        os.kill(-os.getpid(), signal.SIGSTOP)

    """oh yeah, actually Monitor is used as singleton, too"""
    return Monitor().multiplex(*distribute(*resources))
開發者ID:SourabhShenoy,項目名稱:glusterfs,代碼行數:31,代碼來源:monitor.py

示例3: __init__

# 需要導入模塊: from resource import Popen [as 別名]
# 或者: from resource.Popen import terminate_geterr [as 別名]
 def __init__(self, vol, host='localhost', prelude=[]):
     po = Popen(prelude + ['gluster', '--xml', '--remote-host=' + host, 'volume', 'info', vol],
                stdout=PIPE, stderr=PIPE)
     vix = po.stdout.read()
     po.wait()
     po.terminate_geterr()
     vi = XET.fromstring(vix)
     if vi.find('opRet').text != '0':
         if prelude:
             via = '(via %s) ' % prelude.join(' ')
         else:
             via = ' '
         raise GsyncdError('getting volume info of %s%s failed with errorcode %s',
                           (vol, via, vi.find('opErrno').text))
     self.tree = vi
     self.volume = vol
     self.host = host
開發者ID:Anna-Miya-Dan,項目名稱:glusterfs,代碼行數:19,代碼來源:monitor.py

示例4: __init__

# 需要導入模塊: from resource import Popen [as 別名]
# 或者: from resource.Popen import terminate_geterr [as 別名]
 def __init__(self, vol, host="localhost", prelude=[]):
     po = Popen(
         prelude + ["gluster", "--xml", "--remote-host=" + host, "volume", "info", vol], stdout=PIPE, stderr=PIPE
     )
     vix = po.stdout.read()
     po.wait()
     po.terminate_geterr()
     vi = XET.fromstring(vix)
     if vi.find("opRet").text != "0":
         if prelude:
             via = "(via %s) " % prelude.join(" ")
         else:
             via = " "
         raise GsyncdError(
             "getting volume info of %s%s " "failed with errorcode %s", (vol, via, vi.find("opErrno").text)
         )
     self.tree = vi
     self.volume = vol
     self.host = host
開發者ID:reesun,項目名稱:glusterfs,代碼行數:21,代碼來源:monitor.py


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