예제 #1
0
파일: mysql.py 프로젝트: quaddra/engage
def check_status(config, root_pw=None):
    if not os.path.exists(config.pid_file):
        logger.debug("%s: server not up - pid file '%s' not found" %
                     (config.package_name, config.pid_file))
        return False
    file = open(config.pid_file, "rb")
    data = file.read()
    file.close()
    pid = int(data)
    if iuprocess.is_process_alive(pid)==False:
        logger.debug("%s: server not up - process %d not alive" %
                     (config.package_name, pid))
        return False
    if root_pw==None: root_pw = config.admin_password
    cfg_filename = _make_config_file("mysqladmin", None, root_pw,
                                     config.port)
    args = [config.mysqladmin_path, "--defaults-file=%s" % cfg_filename,
            "--socket=%s" % config.socket_file,
            "ping"]
    re_map = {'alive': 'mysqld\\ is\\ alive'}
    try:
        (rc, map) = iuprocess.run_program_and_scan_results(args, re_map,
                                                           logger,
                                                           log_output=True)
    finally:
        os.remove(cfg_filename)
    if rc!=0 or map['alive']==False:
        logger.debug("%s: server not up - mysqladmin ping failed" %
                     config.package_name)
        return False
    else:
        logger.debug("%s: server up, pid is %d" %
                     (config.package_name, pid))
        return True
예제 #2
0
파일: aptget.py 프로젝트: quaddra/engage
def is_installed(package):
    if not os.path.exists(DPKG_QUERY_PATH):
        raise UserError(errors[ERR_DPKG_QUERY_NOT_FOUND],
                        msg_args={"path":DPKG_QUERY_PATH})
    (rc, map) = iuprocess.run_program_and_scan_results([DPKG_QUERY_PATH, "-s", package],
                                                       {"status_ok": "^" + re.escape("Status: install ok installed")},
                                                        logger, log_output=True)
    if rc==0 and map['status_ok']:
        return True
    else:
        return False
예제 #3
0
def check_installed(self, package):
    """Validate that a macports package is installed (e.g. in a post-install check)
    """
    port_exe = self.ctx.props.input_ports.macports.macports_exe
    action._check_file_exists(port_exe, self)
    (rc, map) = iuprocess.run_program_and_scan_results([port_exe, "installed", package],
                                                       {"found": re.escape(package) + ".*" + re.escape("(active)"),
                                                        'not_found': re.escape("None of the specified ports are installed.")},
                                                        self.ctx.logger,
                                                       log_output=True,
                                                       cwd=os.path.dirname(port_exe),
                                                       shell=True, env=ENV)
    if rc==0 and map['found']:
        return
    else:
        raise UserError(errors[ERR_POST_INSTALL],
                        msg_args={"pkg":package, "id":self.ctx.props.id})
예제 #4
0
 def run(self, package):
     port_exe = self.ctx.props.input_ports.macports.macports_exe
     action._check_file_exists(port_exe, self)
     logger.debug("PATH=%s, HOME=%s" % (ENV["PATH"], ENV["HOME"]))
     (rc, map) = iuprocess.run_program_and_scan_results([port_exe, "installed", package],
                                                        {"found": re.escape(package) + ".*" + re.escape("(active)"),
                                                         'not_found': re.escape("None of the specified ports are installed.")},
                                                         self.ctx.logger,
                                                        log_output=True,
                                                        cwd=os.path.dirname(port_exe),
                                                        shell=True, env=ENV)
     if rc==0 and map['found']:
         return True
     elif rc==0 and map['not_found']:
         return False
     else:
         raise UserError(errors[ERR_MACPORTS_PKG_QUERY],
                         msg_args={"pkg":package, "id":self.ctx.props.id})
예제 #5
0
 def run(self, user, password, command_text, re_map, return_codes=[0,],
         log_output=False):
     p = self.ctx.props
     cmd = [p.input_ports.mysql_admin.mysql_client_exe, "-u", user,
            "--password=%s" % password]
     self.ctx.logger.debug(' '.join([p.input_ports.mysql_admin.mysql_client_exe,
                                     "-u", "root",
                                     "--password=****"]))
     (rc, results) = procutils.run_program_and_scan_results(cmd, re_map,
                                                            self.ctx.logger,
                                                            input=command_text,
                                                            hide_command=True,
                                                            log_output=log_output)
     if rc not in return_codes:
         raise UserError(errors[ERR_MYSQL_CLIENT],
                         msg_args={"id":p.id,
                                   "cmd":' '.join(cmd)},
                         developer_msg="rc was %d, command was: '%s'" %
                         (rc, command_text))
     return results