Ejemplo n.º 1
0
    def go(self):
        options = self.get_options()
        dirname = options.dir
        if dirname is None:
            package = dir_from_package_name('mcdp_data')
            libraries = os.path.join(package, 'libraries')
            msg = ('Option "-d" not passed, so I will open the default libraries '
                   'shipped with PyMCDP. These might not be writable depending on your setup.')
            logger.info(msg)
            dirname = libraries

        wa = WebApp(dirname)
        msg = """Welcome to PyMCDP!
        
To access the interface, open your browser at the address
    
    http://127.0.0.1:%s/
    
Use Chrome, Firefox, or Opera - Internet Explorer is not supported.
""" % options.port

        if options.delete_cache:
            logger.info('Deleting cache...')
            wa._refresh_library(None)
        logger.info(msg)
        wa.serve(port=options.port)
Ejemplo n.º 2
0
def get_markdown_css():
    from mcdp_library.utils.dir_from_package_nam import dir_from_package_name

    package = dir_from_package_name('mcdp_web')
    fn = os.path.join(package, 'static', 'css', 'markdown.css')
    with open(fn) as f:
        css = f.read()
    return css
Ejemplo n.º 3
0
def get_language_css():
    from mcdp_library.utils.dir_from_package_nam import dir_from_package_name
    mcdp_dev_warning('TODO: remove from mcdp_web')
    package = dir_from_package_name('mcdp_web')
    fn = os.path.join(package, 'static', 'css', 'mcdp_language_highlight.css')
    with open(fn) as f:
        css = f.read()
    return css
Ejemplo n.º 4
0
 def render_markdown_doc(self, docname):
     package = dir_from_package_name('mcdp_data')
     docs = os.path.join(package, 'docs')
     f = os.path.join(docs, '%s.md' % docname)
     import codecs
     data = codecs.open(f, encoding='utf-8').read()  # XXX
     data_str = data.encode('utf-8')
     html = render_markdown(data_str)
     html_u = unicode(html, 'utf-8')
     return {'contents': html_u}
Ejemplo n.º 5
0
 def _get_default_imagepath(self):
     base = dir_from_package_name('mcdp_report')
     imagepath = os.path.join(base, 'icons')
     if not os.path.exists(imagepath):
         raise ValueError('Icons path does not exist: %r' % imagepath)
     return imagepath