コード例 #1
0
def main(argv):

    #
    try:
        mydb = ehcdb.EHCDB()
        mydb.reset_db(False)
        print("have reset db")
    except Exception as err:
        #        temp = exception_info(err)
        print("bajs")
        print(err)
コード例 #2
0
ファイル: ehcGetEmailConfig.py プロジェクト: drnop/ehc
def main(argv):
    try:
        dbconn = ehcdb.EHCDB()
        dbresult = dbconn.getEmailConfig()
        configstring = dbresult["configstring"]
        rsp = {"result": "OK"}
        rsp.update({"configstring": configstring})
        print("Content-type:application/json\n\n")
        print(json.dumps(rsp))

    except Exception as err:
        print("Content-type:application/json\n\n")
        result = {"result": "Error", "info": "some error {}".format(str(err))}
        print(json.dumps(result))
コード例 #3
0
ファイル: ehcResetDB.py プロジェクト: drnop/ehc
def main(argv):
    debug_level = 0

    try:
        if 'REQUEST_METHOD' in os.environ:
            post = json.loads(str(sys.stdin.read()))
            fullreset = post["fullreset"]
            debug = False
        else:
            fullreset = True
            debug = True

        mydb = ehcdb.EHCDB()
        mydb.reset_db(fullreset)
        result = {"ehcResult": "OK", "fullreset": fullreset}
    except Exception as err:
        result = {"ehcResult": "Error {}".format(mylogger.exception_info(err))}
    print("Content-type:application/json\n\n")
    print(json.dumps(result))
コード例 #4
0
ファイル: ehcUpdateEmailConfig.py プロジェクト: drnop/ehc
def main(argv):

    post = str(sys.stdin.read())

    try:

        dbconn = ehcdb.EHCDB()
        dbconn.updateEmailConfig(post)
        dbresult = dbconn.getEmailConfig()
        configstring = dbresult["configstring"]
        rsp = {"result": "OK"}
        rsp.update({"configstring": configstring})
        print("Content-type:application/json\n\n")
        print(json.dumps(rsp))

    except Exception as err:
        print("Content-type:application/json\n\n")
        result = {"result": "Exception Error:" + exception_info(err)}
        print(json.dumps(result))
コード例 #5
0
ファイル: ehctestme.py プロジェクト: drnop/ehc
def main(argv):
    try:
        logger = ehclogger.LOGGER(prefix="EHC",logThreshold=7)
        post = str(sys.stdin.read())

        esaconfig = ""
        start = False
        for line in post.splitlines():
            if "<?xml" in line:
                start = True
            if start:
                esaconfig = esaconfig + line + '\n'
            if "</config>" in line:
                start = False

        logger.log_debug(3,esaconfig)
        dbconn = ehcdb.EHCDB()
        dbresult  = dbconn.getEmailConfig()
        configstring  = dbresult["configstring"]
        econfig = json.loads(configstring)
        approved_nameservers = str.split(econfig["approved_nameservers"],",")
        approved_mx_hostnames = str.split(econfig["approved_mx_hostnames"],",")
        ehc_instance = ehc.EHC(esaconfig)
        ehc_instance.get_licenses()
        ehc_instance.check_rules()
        ehc_instance.check_hat()
        ehc_instance.dmarc_check(econfig["domain_name"],approved_nameservers,approved_mx_hostnames)
        tests = ehc_instance.get_result()
        rsp = {"result":"OK"}
        rsp.update({"checks":tests})

    except Exception as err:
        exc_type, exc_obj, exc_tb = sys.exc_info()
        fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
        estring = "{} {} {} {}".format(err,exc_type, fname, exc_tb.tb_lineno)
        rsp = {"result":"Error:" + estring}    

    print("Content-type:application/json\n\n")
    print(json.dumps(rsp))
コード例 #6
0
import cgitb
cgitb.enable()

try:
    post = str(sys.stdin.read())

    esaconfig = ""
    start = False
    for line in post.splitlines():
        if "<?xml" in line:
            start = True
        if start:
            esaconfig = esaconfig + line + '\n'
        if "</config>" in line:
            start = False
    dbconn = ehcdb.EHCDB()
    dbresult = dbconn.getEmailConfig()
    if dbresult["result"] == "OK":
        configstring = dbresult["configstring"]
        econfig = json.loads(configstring)
        #        approved_nameservers = ["173.38.200.100"]
        #        approved_mx_hostnames = ["mx1.cisco.c3s2.iphmx.com","mx2.cisco.c3s2.iphmx.com"]
        approved_nameservers = str.split(econfig["approved_nameservers"], ",")
        approved_mx_hostnames = str.split(econfig["approved_mx_hostnames"],
                                          ",")
    else:
        raise Exception("Database Error")

    ehc = ehc.EHC(esaconfig)
    ehc.get_licenses()
    ehc.check_rules()