Esempio n. 1
0
    def handle(self, instance_id=None, target=None, *args, **options):
        if instance_id is None:
            raise CommandError("Instance ID not given.")

        init_spatialite = options["init_spatialite"]
        verbosity = options["verbosity"]
        traceback = options.get("traceback")

        create_instance(
            instance_id, target, init_spatialite, verbosity, traceback
        )
Esempio n. 2
0
def main():
    parser = OptionParser(usage=textwrap.dedent("""\
            %prog [options] <instance-name> [<target-directory>]

            Creates a new EOxServer instance with all necessary files and
            folder structure. Optionally, a SQLite database is initiated.
        """),
                          version=eoxserver.get_version())
    parser.add_option('-i',
                      '--init-spatialite',
                      '--init_spatialite',
                      dest='init_spatialite',
                      action='store_true',
                      default=False,
                      help='Flag to initialize the sqlite database.')
    parser.add_option('-v',
                      '--verbosity',
                      action='store',
                      dest='verbosity',
                      default='1',
                      type='choice',
                      choices=['0', '1', '2', '3'])
    parser.add_option('--traceback',
                      action='store_true',
                      help='Raise on exception')

    options, args = parser.parse_args()

    error_stream = OutputWrapper(sys.stderr, color_style().ERROR)

    if not args:
        error_stream.write("Mandatory argument 'instance-name' not given.\n")
        sys.exit(1)

    name = args[0]
    try:
        target = args[1]
    except IndexError:
        target = None

    try:
        create_instance(name, target, **options.__dict__)
    except Exception as e:
        if options.traceback:
            raise
        error_stream.write("%s: %s\n" % (e.__class__.__name__, e))
Esempio n. 3
0
def main():
    parser = OptionParser(
        usage=textwrap.dedent("""\
            %prog [options] <instance-name> [<target-directory>]

            Creates a new EOxServer instance with all necessary files and
            folder structure. Optionally, a SQLite database is initiated.
        """),
        version=eoxserver.get_version()
    )
    parser.add_option('-i', '--init-spatialite', '--init_spatialite',
        dest='init_spatialite', action='store_true', default=False,
        help='Flag to initialize the sqlite database.'
    )
    parser.add_option('-v', '--verbosity',
        action='store', dest='verbosity', default='1',
        type='choice', choices=['0', '1', '2', '3']
    )
    parser.add_option('--traceback',
        action='store_true', help='Raise on exception'
    )

    options, args = parser.parse_args()

    error_stream = OutputWrapper(sys.stderr, color_style().ERROR)

    if not args:
        error_stream.write("Mandatory argument 'instance-name' not given.\n")
        sys.exit(1)

    name = args[0]
    try:
        target = args[1]
    except IndexError:
        target = None

    try:
        create_instance(name, target, **options.__dict__)
    except Exception as e:
        if options.traceback:
            raise
        error_stream.write("%s: %s\n" % (e.__class__.__name__, e))