Exemple #1
0
def main():
    msg_invalid = check_python_version()
    if msg_invalid:
        print msg_invalid
    else:
        if not sys.stdin.isatty():
            send_docs(options['bar'], split_docs(sys.stdin.read())) # commands from pipe
        else:
            if not options['help'] and len(sys.argv) > 1:
                send_docs(options['bar']) # commands from argv
            else:
                from console import help_option
                print '%s: %s [OPTIONS] [filenames]\n\n%s\n%s\n%s\n%s:\n%s\n\n%s\n'%(_T('Usage'), 'fred_sender.py',
                _T('Module for sending files to the EPP server.'),
                help_option,
                _T("""  -o OUTPUT_TYPE, --output=OUTPUT_TYPE
                   Display output as text (default), html, xml, php (Beware! For experimental only!)"""),
                _T('EXAMPLES'),
"""
  ./fred_create.py info_domain nic.cz > cmd1.xml
  ./fred_create.py info_contact reg-id pokus > cmd2.xml
  ./fred_sender.py cmd1.xml cmd2.xml
  ./fred_sender.py -s epp_host -l cs cmd1.xml cmd2.xml
    
  echo -en "check_domain nic.cz\\ninfo_domain nic.cz" | ./fred_create.py | ./fred_sender.py""",
   _T('See README for more information.'))
Exemple #2
0
def main():
    msg_invalid = check_python_version()
    if msg_invalid:
        print msg_invalid
    else:
        if len(sys.argv) > 1:
            command = " ".join(option_args)
            if options["range"]:
                epp_doc = str_error = ""
                m = re.match("([^\[]+)\[(\d+)(?:\s*,\s*(\d+))?\]", options["range"])
                if m:
                    min = 0
                    anchor = m.group(1)
                    if m.group(3) is None:
                        max = int(m.group(2))
                    else:
                        min = int(m.group(2))
                        max = int(m.group(3))
                    for n in range(min, max):
                        options["command"] = re.sub(anchor, "%s%d" % (anchor, n), command)
                        epp_doc, str_error = run_creation(options)
                        display(epp_doc, str_error)
                else:
                    print "<?xml encoding='%s'?><errors>Invalid range pattern: %s</errors>" % (
                        encoding,
                        options["range"],
                    )
            else:
                options["command"] = command
                epp_doc, str_error = run_creation(options)
                display(epp_doc, str_error)
        elif not sys.stdin.isatty():
            for cmd in re.split("[\r\n]+", sys.stdin.read()):
                command = cmd.strip()
                if command:
                    options["command"] = command
                    epp_doc, str_error = run_creation(options)
                    display(epp_doc, str_error)
        else:
            print "%s: %s command params\n\n%s\n\n%s%s\n\n  %s\n" % (
                _T("Usage"),
                "fred_create.py",
                _T("Create EPP XML document from command line parameters."),
                _T("EXAMPLES"),
                """
./fred_create.py info_domain nic.cz
./fred_create.py info_contact cid:regid
echo -en "check_domain nic.cz\\ninfo_domain nic.cz" | ./fred_create.py
cat file-with-commands.txt | ./fred_create.py
""",
                _T("See README for more information."),
            )
Exemple #3
0
def main():
    msg_invalid = check_python_version()
    if msg_invalid:
        print msg_invalid
    else:
        if len(sys.argv) > 1:
            command = ' '.join(option_args)
            if options['range']:
                epp_doc = str_error = ''
                m = re.match('([^\[]+)\[(\d+)(?:\s*,\s*(\d+))?\]',
                             options['range'])
                if m:
                    min = 0
                    anchor = m.group(1)
                    if m.group(3) is None:
                        max = int(m.group(2))
                    else:
                        min = int(m.group(2))
                        max = int(m.group(3))
                    for n in range(min, max):
                        options['command'] = re.sub(anchor,
                                                    '%s%d' % (anchor, n),
                                                    command)
                        epp_doc, str_error = run_creation(options)
                        display(epp_doc, str_error)
                else:
                    print "<?xml encoding='%s'?><errors>Invalid range pattern: %s</errors>" % (
                        encoding, options['range'])
            else:
                options['command'] = command
                epp_doc, str_error = run_creation(options)
                display(epp_doc, str_error)
        elif not sys.stdin.isatty():
            for cmd in re.split('[\r\n]+', sys.stdin.read()):
                command = cmd.strip()
                if command:
                    options['command'] = command
                    epp_doc, str_error = run_creation(options)
                    display(epp_doc, str_error)
        else:
            print '%s: %s command params\n\n%s\n\n%s%s\n\n  %s\n' % (
                _T('Usage'), 'fred_create.py',
                _T('Create EPP XML document from command line parameters.'),
                _T('EXAMPLES'), """
./fred_create.py info_domain nic.cz
./fred_create.py info_contact cid:regid
echo -en "check_domain nic.cz\\ninfo_domain nic.cz" | ./fred_create.py
cat file-with-commands.txt | ./fred_create.py
""", _T('See README for more information.'))
Exemple #4
0
    epp.save_history(readline)
    epp.display() # display logout messages

def check_options(epp):
    'Check options what needs epp object for validate.'
    retval = 1
    if options['verbose']:
        if epp.parse_verbose_value(options['verbose']) is None:
            retval = 0
            print epp.fetch_errors()
            print _T("""Usage: %s [OPTIONS...]
Try '%s --help' for more information.""") % (script_name, script_name)
    return retval

if __name__ == '__main__':
    msg_invalid = __init__.check_python_version()
    if msg_invalid:
        print msg_invalid
    else:
        if options['help']:
            print '%s: %s [OPTIONS...]\n%s\n%s\n' % (_T('Usage'), 'fred_console',
            help_option,
            _T('See README for more information.'))
        elif options['version']:
            epp = fred.ClientSession()
            print epp.version()
        else:
            if option_errors:
                print option_errors
            else:
                main(options)
Exemple #5
0
    epp.save_history(readline)
    epp.display() # display logout messages

def check_options(epp):
    'Check options what needs epp object for validate.'
    retval=1
    if options['verbose']:
        if epp.parse_verbose_value(options['verbose']) is None:
            retval=0
            print epp.fetch_errors()
            print _T("""Usage: %s [OPTIONS...]
Try '%s --help' for more information.""")%(script_name, script_name)
    return retval

if __name__ == '__main__':
    msg_invalid = __init__.check_python_version()
    if msg_invalid:
        print msg_invalid
    else:
        if options['help']:
            print '%s: %s [OPTIONS...]\n%s\n%s\n'%(_T('Usage'), 'fred_console',
            help_option,
            _T('See README for more information.'))
        elif options['version']:
            epp = fred.ClientSession()
            print epp.version()
        else:
            if option_errors:
                print option_errors
            else:
                main(options)