Exemplo n.º 1
0
    def __init__(self, handlers=None, default_host="", transforms=None, wsgi=False, **settings):
        if not handlers:
            handlers = [
                (r"/_/api/changes", ChangeRequestHandler),
                (r"/_/api/?(.*)", APIRequestHandler),
                (r"/_/?(.*)", AssetsHandler, {"path": os.path.join(module_path(), '_')}),
                (r"/", RedirectHandler, {'url': '/_/index.html'}),
            ]
        if not settings:
            settings = {
                'debug': True,
                'template_path': os.path.join(module_path(), '_'),
            }
        if not default_host:
            default_host = '.*$'

        Application.__init__(self, handlers, default_host, transforms, wsgi, **settings)
        self.internal_handler_count = len(handlers)

        self.change_request_handlers = set()
        self.observer = ChangesObserver(changes_handler=self.change_happened)

        self.config_path = config_path()
        self.config = self.load_config()
        self.project = None
        for project in self.config.get('projects', []):
            if project.get('isCurrent'):
                self.project = project
                self.set_project(project)
                break
Exemplo n.º 2
0
 def config(self):
     if not hasattr(self, '_config'):
         path = config_path()
         if os.path.exists(path):
             self._config = Config.load(path)
         else:
             self._config = Config()
             self._config.path = path
     return self._config
Exemplo n.º 3
0
# coding:utf-8
import os
import sys
from pyf5.utils import config_path

VERSION = "4.3.0"

RELOADER_TAG = '<script id="_f5_script" src="/_/js/reloader.js"></script>'

DEFAULT_MUTE_LIST = [".git", ".idea"]

PRODUCTION_MODE = "production"
DEVELOPMENT_MODE = "development"
CURRENT_MODE = PRODUCTION_MODE if hasattr(sys, "frozen") else DEVELOPMENT_MODE

APP_FOLDER = None
if CURRENT_MODE == PRODUCTION_MODE:
    APP_FOLDER = os.path.dirname(unicode(sys.executable, sys.getfilesystemencoding()))
else:
    APP_FOLDER = os.path.dirname(unicode(__file__, sys.getfilesystemencoding()))

RESOURCE_FOLDER = os.path.join(APP_FOLDER, "_")

if not os.path.isdir(RESOURCE_FOLDER):
    RESOURCE_FOLDER = os.path.join(APP_FOLDER, "../Resources/_")

CONFIG_PATH = config_path(APP_FOLDER)
Exemplo n.º 4
0
RELOADER_TAG = '<script id="_f5_script" src="/_/js/reloader.js"></script>'

NODE_BIN_PATH = 'bundled/node.exe'
if not sys.platform.startswith('win'):
    NODE_BIN_PATH = 'bundled/node'

# 默认不监控变更的文件/目录
DEFAULT_MUTE_LIST = [
    '.git',
    '.idea',
]

PRODUCTION_MODE = 'production'
DEVELOPMENT_MODE = 'development'
CURRENT_MODE = PRODUCTION_MODE if hasattr(sys, "frozen") else DEVELOPMENT_MODE

APP_FOLDER = None
if CURRENT_MODE == PRODUCTION_MODE:
    APP_FOLDER = os.path.dirname(
        unicode(sys.executable, sys.getfilesystemencoding()))
else:
    APP_FOLDER = os.path.dirname(unicode(__file__,
                                         sys.getfilesystemencoding()))

RESOURCE_FOLDER = os.path.join(APP_FOLDER, '_')

if not os.path.isdir(RESOURCE_FOLDER):
    RESOURCE_FOLDER = os.path.join(APP_FOLDER, '../Resources/_')

CONFIG_PATH = config_path(APP_FOLDER)
Exemplo n.º 5
0
Arquivo: api.py Projeto: no2key/PyF5
 def setup(self):
     self.config_path = config_path()
     self.config = self.application.config
     self.projects = self.config.projects