Пример #1
0
    def go(self):

        options = self.get_options()
        if not options.contracts:
            disable_all()
            
        filenames = options.get_extra()
        #print options
        if len(filenames) == 0:
            raise_desc(UserError, 'Need at least one filename.', filenames=filenames)

        if len(filenames) > 1:
            raise_desc(NotImplementedError, 'Want only 1 filename.', filenames=filenames)

        filename = filenames[0]

        if options.out is None:
            out = os.path.dirname(filename)
            if not out:
                out = 'out-mcdp_plot'
        else:
            out = options.out
        mkdirs_thread_safe(out)
        possible = [p for p, _ in allplots]
        plots = expand_string(options.plots, list(possible))
        logger = self.logger  # HasLogger
        maindir = options.maindir
        extra_dirs = options.extra_dirs.split(':')
        use_cache = options.cache
        do_plots(logger, filename, plots, out, options.extra_params,
                maindir=maindir,
                extra_dirs=extra_dirs,
                 use_cache=use_cache) 
Пример #2
0
    def go(self):
        
        logger.setLevel(logging.DEBUG)

        options = self.get_options()
        
        if not options.contracts:
            logger.debug('Disabling PyContrats. Use --contracts to enable.')
            disable_all()
            
        if options.expect_nimp is not None:
            options.imp = True

        params = options.get_extra()

        if len(params) < 1:
            raise ValueError('Please specify model name.')

        model_name = params[0]

        # drop the extension
        if '.mcdp' in model_name or '/' in model_name:
            msg = 'The model name should not contain extension or /.'
            raise UserError(msg)

        max_steps = options.max_steps

        _exp_advanced = options.advanced
        expect_nres = options.expect_nres
        lower = options.lower
        upper = options.upper
        out_dir = options.out
        query_strings = params[1:]

        intervals = options.intervals
        imp = options.imp
        expect_nimp = options.expect_nimp
        make = options.make
        if make: imp = True

        plot = options.plot
        do_movie = options.movie

        expect_res = None

        config_dirs = options.config_dirs.split(":")
        maindir = options.maindir
        if options.cache:
            if out_dir is None:
                out_dir = 'out-mcdp_solve'
            cache_dir = os.path.join(out_dir, '_cached', 'solve')
        else:
            cache_dir = None

        solve_main(logger, config_dirs, maindir, cache_dir, model_name, lower, upper, out_dir, max_steps, query_strings,
                   intervals, _exp_advanced, expect_nres, imp, expect_nimp, plot, do_movie,
                   expect_res,
                   make)
Пример #3
0
    def go(self):
        logger.setLevel(logging.DEBUG)

        options = self.get_options()

        if not options.contracts:
            disable_all()

        params = options.get_extra()

        if len(params) < 1:
            raise ValueError("Please specify name.")

        config_dirs = options.config_dirs.split(":")
        maindir = options.maindir
        out_dir = options.out

        if out_dir is None:
            out_dir = os.path.join("out", "mcdp_render")

        if options.cache:
            cache_dir = os.path.join(out_dir, "_cached", "solve")
        else:
            cache_dir = None

        librarian = Librarian()
        for e in config_dirs:
            librarian.find_libraries(e)

        library = librarian.get_library_by_dir(maindir)
        if cache_dir is not None:
            library.use_cache_dir(cache_dir)

        docs = params

        if not docs:
            msg = "At least one argument required."
            raise_desc(UserError, msg)

        for docname in docs:
            basename = docname + "." + MCDPLibrary.ext_doc_md
            f = library._get_file_data(basename)
            data = f["data"]
            realpath = f["realpath"]

            generate_pdf = options.pdf
            render(library, docname, data, realpath, out_dir, generate_pdf)
Пример #4
0
    def go(self):
        from mocdp import logger
        logger.setLevel(logging.DEBUG)



        options = self.get_options()

        if not options.contracts:
            disable_all()

        params = options.get_extra()

        if len(params) < 1:
            raise ValueError('Please specify name.')

        name = params[0]

        config_dirs = options.config_dirs.split(":")
        maindir = options.maindir
        out_dir = options.out

        if out_dir is None:
            out_dir = os.path.join('out', 'mcdp_eval')

        if options.cache:
            cache_dir = os.path.join(out_dir, '_cached', 'solve')
        else:
            cache_dir = None

        librarian = Librarian()
        for e in config_dirs:
            librarian.find_libraries(e)

        library = librarian.get_library_by_dir(maindir)
        if cache_dir is not None:
            library.use_cache_dir(cache_dir)

        context = library._generate_context_with_hooks()
        c = library.load_constant(name, context)
        print(c)
Пример #5
0
    def go(self):

        options = self.get_options()
        if not options.contracts:
            disable_all()

        filenames = options.get_extra()
        #print options
        if len(filenames) == 0:
            raise_desc(UserError,
                       'Need at least one filename.',
                       filenames=filenames)

        if len(filenames) > 1:
            raise_desc(NotImplementedError,
                       'Want only 1 filename.',
                       filenames=filenames)

        filename = filenames[0]

        if options.out is None:
            out = os.path.dirname(filename)
            if not out:
                out = 'out-mcdp_plot'
        else:
            out = options.out
        mkdirs_thread_safe(out)
        logger = self.logger  # HasLogger
        maindir = options.maindir
        extra_dirs = options.extra_dirs.split(':')
        use_cache = options.cache
        do_plots(logger,
                 filename,
                 options.plots,
                 out,
                 options.extra_params,
                 maindir=maindir,
                 extra_dirs=extra_dirs,
                 use_cache=use_cache)
Пример #6
0
Файл: eval.py Проект: rusi/mcdp
    def go(self):
        from mcdp import logger
        logger.setLevel(logging.DEBUG)

        options = self.get_options()

        if not options.contracts:
            disable_all()

        params = options.get_extra()

        if len(params) < 1:
            raise ValueError('Please specify name.')

        name = params[0]

        config_dirs = options.config_dirs.split(":")
        maindir = options.maindir
        out_dir = options.out

        if out_dir is None:
            out_dir = os.path.join('out', 'mcdp_eval')

        if options.cache:
            cache_dir = os.path.join(out_dir, '_cached', 'solve')
        else:
            cache_dir = None

        librarian = Librarian()
        for e in config_dirs:
            librarian.find_libraries(e)

        library = librarian.get_library_by_dir(maindir)
        if cache_dir is not None:
            library.use_cache_dir(cache_dir)

        context = library._generate_context_with_hooks()
        c = library.load_constant(name, context)
        print(c)
Пример #7
0
    def go(self):
        logger.setLevel(logging.DEBUG)

        options = self.get_options()

        symbols = self.options.symbols
        if symbols is not None:
            symbols = open(symbols).read()
        else:
            symbols = ''

        if not options.contracts:
            disable_all()

        stylesheet = options.stylesheet
        # make sure it exists
        get_css_filename('compiled/%s' % stylesheet)

        params = options.get_extra()

        if len(params) < 1:
            raise ValueError('Please specify name.')

        config_dirs = options.config_dirs.split(":")
        maindir = options.maindir
        out_dir = options.out

        if options.cache:
            cache_dir = os.path.join(out_dir, '_cached', 'solve')
        else:
            cache_dir = None

        librarian = Librarian()
        for e in config_dirs:
            librarian.find_libraries(e)

        library = librarian.get_library_by_dir(maindir)
        if cache_dir is not None:
            library.use_cache_dir(cache_dir)

        docs = params

        if not docs:
            msg = 'At least one argument required.'
            raise_desc(UserError, msg)

        for docname in docs:
            if '/' in docname:
                docname0 = os.path.split(docname)[-1]
                logger.info("Using %r rather than %r" % (docname0, docname))
                docname = docname0
            suffix = '.' + MCDPConstants.ext_doc_md
            if docname.endswith(suffix):
                docname = docname.replace(suffix, '')
            basename = docname + suffix
            f = library._get_file_data(basename)
            data = f['data']
            realpath = f['realpath']

            generate_pdf = options.pdf_figures
            if out_dir is None:
                use_out_dir = os.path.dirname(realpath)
            else:
                use_out_dir = os.path.join('out', 'mcdp_render')

            raise_errors = not options.forgiving
            use_mathjax = bool(options.mathjax)

            html_filename = render(library,
                                   docname,
                                   data,
                                   realpath,
                                   use_out_dir,
                                   generate_pdf,
                                   stylesheet=stylesheet,
                                   symbols=symbols,
                                   raise_errors=raise_errors,
                                   use_mathjax=use_mathjax)
            if options.pdf:
                run_prince(html_filename)