コード例 #1
0
def run_creation(options):
    global epp
    if epp is None:
        epp = ClientSession()
        epp.load_config()
        epp.set_auto_connect(0)  # set OFF auto connection
    command_name, epp_doc, stop = epp.create_eppdoc(options['command'])
    errors = epp.fetch_errors()
    if not epp_doc and not errors:
        errors = '%s %s' % (_T('Unknown command'),
                            command_name.encode(encoding))
    str_error = ''
    if errors:
        if type(command_name) == unicode:
            command_name = command_name.encode(encoding)
        if type(errors) == unicode: errors = errors.encode(encoding)
        if options['output'] == 'html':
            str_error = '<div class="fred_errors">\n<strong>%s errors:</strong>\n<pre>\n%s</pre><div>' % (
                command_name, escape_html(errors))
        elif options['output'] == 'php':
            str_error = '<?php\n$fred_error_create_name = %s;\n$fred_error_create_value = %s;\n%s\n?>' % (
                php_string(command_name), php_string(errors),
                epp.get_empty_php_code())
        elif options['output'] == 'xml':
            str_error = "<?xml version='1.0' encoding='%s'?>\n<errors>\n\t<error>%s</error>\n</errors>" % (
                encoding, errors)
        else:
            # default 'text'
            str_error = "%s: %s" % (_T('ERROR'), errors)
    return epp_doc, str_error
コード例 #2
0
ファイル: creator.py プロジェクト: mpvyard/fred-client
def run_creation(options):
    global epp
    command_name, errors, epp_doc = "", "", None
    if epp is None:
        epp = ClientSession()
        epp.load_config()
        if epp._conf.has_option("creator", "server_disclose_policy"):
            server_disclose_policy = epp._conf.get("creator",
                                                   "server_disclose_policy")
            if server_disclose_policy not in ("0", "1"):
                errors = "The variable 'server_disclose_policy' in config section [creator] has an unexpected value.\n"
            else:
                epp._epp_cmd.server_disclose_policy = int(
                    server_disclose_policy)
    if not errors:
        epp.set_auto_connect(0)  # set OFF auto connection
        command_name, epp_doc, stop = epp.create_eppdoc(options['command'])
        errors = epp.fetch_errors()
    if not epp_doc and not errors:
        errors = '%s %s' % (_T('Unknown command'),
                            command_name.encode(encoding))
    str_error = ''
    if errors:
        if type(command_name) == unicode:
            command_name = command_name.encode(encoding)
        if type(errors) == unicode: errors = errors.encode(encoding)
        if options['output'] == 'html':
            str_error = '<div class="fred_errors">\n<strong>%s errors:</strong>\n<pre>\n%s</pre><div>' % (
                command_name, escape_html(errors))
        elif options['output'] == 'php':
            str_error = '<?php\n$fred_error_create_name = %s;\n$fred_error_create_value = %s;\n%s\n?>' % (
                php_string(command_name), php_string(errors),
                epp.get_empty_php_code())
        elif options['output'] == 'xml':
            str_error = "<?xml version='1.0' encoding='%s'?>\n<errors>\n\t<error>%s</error>\n</errors>" % (
                encoding, errors)
        else:
            # default 'text'
            str_error = "%s: %s" % (_T('ERROR'), errors)
    return epp_doc, str_error
コード例 #3
0
ファイル: creator.py プロジェクト: kubicek/fred-client
def run_creation(options):
    global epp
    if epp is None:
        epp = ClientSession()
        epp.load_config()
        epp.set_auto_connect(0)  # set OFF auto connection
    command_name, epp_doc, stop = epp.create_eppdoc(options["command"])
    errors = epp.fetch_errors()
    if not epp_doc and not errors:
        errors = "%s %s" % (_T("Unknown command"), command_name.encode(encoding))
    str_error = ""
    if errors:
        if type(command_name) == unicode:
            command_name = command_name.encode(encoding)
        if type(errors) == unicode:
            errors = errors.encode(encoding)
        if options["output"] == "html":
            str_error = '<div class="fred_errors">\n<strong>%s errors:</strong>\n<pre>\n%s</pre><div>' % (
                command_name,
                escape_html(errors),
            )
        elif options["output"] == "php":
            str_error = "<?php\n$fred_error_create_name = %s;\n$fred_error_create_value = %s;\n%s\n?>" % (
                php_string(command_name),
                php_string(errors),
                epp.get_empty_php_code(),
            )
        elif options["output"] == "xml":
            str_error = "<?xml version='1.0' encoding='%s'?>\n<errors>\n\t<error>%s</error>\n</errors>" % (
                encoding,
                errors,
            )
        else:
            # default 'text'
            str_error = "%s: %s" % (_T("ERROR"), errors)
    return epp_doc, str_error