Ejemplo n.º 1
0
def create_erd_route(model, version):

    ext = request.args.get('format') or 'png'

    filename = '{0}_{1}_dms_{2}_dmsa_{3}.{4}'.format(
        model, version, app.config['service_version'], __version__, ext)
    filepath = '/'.join([app.instance_path, filename])

    try:
        os.makedirs(app.instance_path)
    except OSError:
        pass

    try:
        erd.write(model, version, filepath, app.config['service'])
    except ImportError:
        return render_template('erd_500.html'), 500

    return redirect(url_for('erd_route', model=model, version=version,
                            filename=filename))
def create_erd_route(model, version):

    ext = request.args.get('format') or 'png'

    filename = '{0}_{1}_dms_{2}_dmsa_{3}.{4}'.format(
        model, version, get_service_version(app.config['service']),
        __version__, ext)
    filepath = '/'.join([app.instance_path, filename])

    try:
        os.makedirs(app.instance_path)
    except OSError:
        pass

    try:
        erd.write(model, version, filepath, app.config['service'])
    except ImportError:
        return render_template('erd_500.html'), 500

    return redirect(
        url_for('erd_route', model=model, version=version, filename=filename))
Ejemplo n.º 3
0
def main():
    import sys
    from docopt import docopt
    from dmsa import __version__

    # Parse command line arguments.
    args = docopt(__doc__, argv=sys.argv[1:], version=__version__)

    if args['ddl']:
        from dmsa import ddl

        output = ddl.generate(args['<model>'], args['<model_version>'],
                              args['<dialect>'], args['--tables'],
                              args['--constraints'], args['--indexes'],
                              args['--drop'], args['--delete-data'],
                              args['--nologging'], args['--logging'],
                              args['--service'])

        if args['--output']:
            f = open(args['--output'], 'w')
            f.write(output)
            f.close()
        else:
            return sys.stdout.write(output)

    elif args['erd']:
        from dmsa import erd
        try:
            return erd.write(args['<model>'], args['<model_version>'],
                             args['--output'], args['--service'])
        except ImportError:
            sys.stderr.write(
                'ERD not supported because ERAlchemy module not installed\n')
            sys.exit(1)

    elif args['serve']:
        from dmsa import service
        app = service.build_app(args['--service'])
        app.run(host=args['--host'],
                port=int(args['--port']),
                debug=args['--debug'])
Ejemplo n.º 4
0
def main():
    import sys
    from docopt import docopt
    from dmsa import __version__

    # Parse command line arguments.
    args = docopt(__doc__, argv=sys.argv[1:], version=__version__)

    if args['ddl']:
        from dmsa import ddl

        output = ddl.generate(args['<model>'], args['<model_version>'],
                              args['<dialect>'], args['--tables'],
                              args['--constraints'], args['--indexes'],
                              args['--drop'], args['--delete-data'],
                              args['--nologging'], args['--logging'],
                              args['--service'])

        if args['--output']:
            f = open(args['--output'], 'w')
            f.write(output)
            f.close()
        else:
            return sys.stdout.write(output)

    elif args['erd']:
        from dmsa import erd
        try:
            return erd.write(args['<model>'], args['<model_version>'],
                             args['--output'], args['--service'])
        except ImportError:
            sys.stderr.write(
                'ERD not supported because ERAlchemy module not installed\n')
            sys.exit(1)

    elif args['serve']:
        from dmsa import service
        app = service.build_app(args['--service'])
        app.run(host=args['--host'], port=int(args['--port']),
                debug=args['--debug'])
Ejemplo n.º 5
0
def test_all():
    try:
        erd.write('omop', '5.0.0', 'test_erd_out.png', SERVICE)
    except ImportError:
        raise SkipTest('Skipping erd test; ERLAlchemy package not installed')
    ok_(os.path.exists('test_erd_out.png'))