Example #1
0
    def load_renderers(cls):
        renderers = []
        # Add library path to sys.path
        LibraryPathManager.push_search_path(os.path.dirname(sys.executable))
        LibraryPathManager.add_search_path_if_not_exists(
            os.path.join(__path__, './Renderers/libs/'))

        # Change the current directory to that of the module. It's not safe to just
        # add the modules directory to sys.path, as that won't accept unicode paths
        # on Windows
        renderers_path = os.path.join(__path__, 'Renderers/')
        oldpath = os.getcwdu()
        os.chdir(os.path.join(__path__, '..'))
        try:
            module_list = [
                f for f in os.listdir(renderers_path)
                if f.endswith('Renderer.py')
            ]
            # Load each renderer
            for module_file in module_list:
                module_name = 'OmniMarkupLib.Renderers.' + module_file[:-3]
                cls._load_renderer(renderers, module_file, module_name)

        finally:
            # Restore the current directory
            os.chdir(oldpath)
            LibraryPathManager.pop_search_path()

        with cls.RW_LOCK.writelock:
            cls.RENDERERS = renderers
    def load_renderers(cls):
        renderers = []
        # Add library path to sys.path
        LibraryPathManager.push_search_path(os.path.dirname(sys.executable))
        LibraryPathManager.add_search_path_if_not_exists(os.path.join(__path__, './Renderers/libs/'))

        # Change the current directory to that of the module. It's not safe to just
        # add the modules directory to sys.path, as that won't accept unicode paths
        # on Windows
        renderers_path = os.path.join(__path__, 'Renderers/')
        oldpath = os.getcwdu()
        os.chdir(os.path.join(__path__, '..'))
        try:
            module_list = [f
                for f in os.listdir(renderers_path) if f.endswith('Renderer.py')
            ]
            # Load each renderer
            for module_file in module_list:
                module_name = 'OmniMarkupLib.Renderers.' + module_file[:-3]
                cls._load_renderer(renderers, module_file, module_name)

        finally:
            # Restore the current directory
            os.chdir(oldpath)
            LibraryPathManager.pop_search_path()

        with cls.RW_LOCK.writelock:
            cls.RENDERERS = renderers
Example #3
0
DEFAULT_TEMPLATE_FILES_DIR = os.path.normpath(os.path.join(__path__, '..', 'templates'))
USER_TEMPLATE_FILES_DIR = os.path.normpath(os.path.join(sublime.packages_path(),
                                           'User', 'OmniMarkupPreviewer', 'templates'))


def _mk_folders(folders):
    for folder in folders:
        if not os.path.exists(folder):
            try:
                os.makedirs(folder)
            except:
                pass

_mk_folders([USER_STATIC_FILES_DIR, USER_TEMPLATE_FILES_DIR])

LibraryPathManager.push_search_path(os.path.dirname(sys.executable))
LibraryPathManager.push_search_path(os.path.join(__path__, 'libs'))
try:
    from cherrypy import wsgiserver
    import bottle
    from bottle import Bottle, ServerAdapter
    from bottle import static_file, request, template
finally:
    LibraryPathManager.pop_search_path()
    LibraryPathManager.pop_search_path()

bottle.TEMPLATE_PATH = [USER_TEMPLATE_FILES_DIR, DEFAULT_TEMPLATE_FILES_DIR]


# Create a new app stack
app = Bottle()
Example #4
0
import re
import base64
from urlparse import urlparse
import threading
import inspect
import mimetypes
import sublime
from OmniMarkupLib.Setting import Setting
from OmniMarkupLib.Common import RWLock, RenderedMarkupCache, RenderedMarkupCacheEntry
from OmniMarkupLib import LibraryPathManager
from OmniMarkupLib import log

__file__ = os.path.normpath(os.path.abspath(__file__))
__path__ = os.path.dirname(__file__)

LibraryPathManager.push_search_path(os.path.dirname(sys.executable))
LibraryPathManager.push_search_path(os.path.join(__path__, 'libs'))
try:
    from bottle import template
finally:
    LibraryPathManager.pop_search_path()
    LibraryPathManager.pop_search_path()


class WorkerQueueItem(object):
    def __init__(self, timestamp=0, fullpath='untitled', lang='', text=''):
        self.timestamp = timestamp
        self.fullpath = fullpath or 'untitled'
        self.lang = lang
        self.text = text