# Path: crmsh/utils.py
# def ext_cmd(cmd, shell=True):
#     cmd = add_sudo(cmd)
#     if options.regression_tests:
#         print(".EXT", cmd)
#     logger.debug("invoke: %s", cmd)
#     return subprocess.call(cmd, shell=shell)
# 
# def show_dot_graph(dotfile, keep_file=False, desc="transition graph"):
#     cmd = "%s %s" % (config.core.dotty, dotfile)
#     if not keep_file:
#         cmd = "(%s; rm -f %s)" % (cmd, dotfile)
#     if options.regression_tests:
#         print(".EXT", cmd)
#     subprocess.Popen(cmd, shell=True, bufsize=0,
#                      stdin=None, stdout=None, stderr=None, close_fds=True)
#     logger.info("starting %s to show %s", config.core.dotty, desc)
# 
# def page_string(s):
#     'Page string rendered for TERM.'
#     if not s:
#         return
#     constants.need_reset = True
#     w, h = get_winsize()
#     if not need_pager(s, w, h):
#         print(term_render(s))
#     elif not config.core.pager or not can_ask() or options.batch:
#         print(term_render(s))
#     else:
#         pipe_string(get_pager_cmd(), term_render(s).encode('utf-8'))
#     constants.need_reset = False


import os
from tempfile import mkstemp
from lxml import etree
from . import tmpfiles
from . import xmlutil
from . import utils
from . import config
from .utils import ext_cmd, show_dot_graph, page_string
from . import log
        Return the status section node.
        '''
        if not self.origin:
            self.initialize()
        if (self.status_node is None or (self.origin == "live" and not self.modified)) and not self._load(self.origin):
            return None
        return self.status_node

    def list_changes(self):
        '''
        Dump a set of changes done.
        '''
        if not self.modified:
            return True
        for node in self.node_changes:
            print(node, self.node_changes[node])
        for op in self.op_changes:
            print(op, self.op_changes[op])
        for ticket in self.ticket_changes:
            print(ticket, self.ticket_changes[ticket])
        if self.quorum:
            print("quorum:", self.quorum)
        return True

    def show(self):
        '''
        Page the "pretty" XML of the status section.
        '''
        if self.get_status() is None:
            return False

# Path: crmsh/utils.py
# def ext_cmd(cmd, shell=True):
#     cmd = add_sudo(cmd)
#     if options.regression_tests:
#         print(".EXT", cmd)
#     logger.debug("invoke: %s", cmd)
#     return subprocess.call(cmd, shell=shell)
# 
# def show_dot_graph(dotfile, keep_file=False, desc="transition graph"):
#     cmd = "%s %s" % (config.core.dotty, dotfile)
#     if not keep_file:
#         cmd = "(%s; rm -f %s)" % (cmd, dotfile)
#     if options.regression_tests:
#         print(".EXT", cmd)
#     subprocess.Popen(cmd, shell=True, bufsize=0,
#                      stdin=None, stdout=None, stderr=None, close_fds=True)
#     logger.info("starting %s to show %s", config.core.dotty, desc)
# 
# def page_string(s):
#     'Page string rendered for TERM.'
#     if not s:
#         return
#     constants.need_reset = True
#     w, h = get_winsize()
#     if not need_pager(s, w, h):
#         print(term_render(s))
#     elif not config.core.pager or not can_ask() or options.batch:
#         print(term_render(s))
#     else:
#         pipe_string(get_pager_cmd(), term_render(s).encode('utf-8'))
#     constants.need_reset = False


# Path: crmsh/cibstatus.py
import os
from tempfile import mkstemp
from lxml import etree
from . import tmpfiles
from . import xmlutil
from . import utils
from . import config
from .utils import ext_cmd, show_dot_graph, page_string
from . import log

        Return the status section node.
        '''
        if not self.origin:
            self.initialize()
        if (self.status_node is None or (self.origin == "live" and not self.modified)) and not self._load(self.origin):
            return None
        return self.status_node

    def list_changes(self):
        '''
        Dump a set of changes done.
        '''
        if not self.modified:
            return True
        for node in self.node_changes:
            print(node, self.node_changes[node])
        for op in self.op_changes:
            print(op, self.op_changes[op])
        for ticket in self.ticket_changes:
            print(ticket, self.ticket_changes[ticket])
        if self.quorum:
            print("quorum:", self.quorum)
        return True

    def show(self):
        '''
        Page the "pretty" XML of the status section.
        '''
        if self.get_status() is None:
            return False

        page_string(xmlutil.xml_tostring(self.status_node, pretty_print=True))