コード例 #1
0
ファイル: web_resources.py プロジェクト: plaljx/ToMaTo
Web resources are resources that are only available to the webfrontend
They are defined via a fixed URL that usually points to a JSON document.

Current kinds of web resources:
 - default executable archives
 - custom element icons
"""

__author__ = 't-gerhard'

import json, urllib2
from urlparse import urljoin

from lib.settings import get_settings, Config
import settings as config_module
settings = get_settings(config_module)

from django.shortcuts import render
import time
from .lib import wrap_rpc
from .lib.references_web import techs
from .lib.exceptionhandling import wrap_and_handle_current_exception


def web_resources():
    return {
        'executable_archives': executable_archives(),
        'custom_element_icons': custom_element_icons()
    }

コード例 #2
0
from lib import settings
from lib import sqlitedb
from lib import http
import logging
import logging.config
import traceback
import version

config_file = "./conf/logging.conf"
logging.config.fileConfig(config_file)
logger = logging.getLogger("rotatelog")
logger.handlers[
    1].suffix = '%Y-%m-%d.log'  #auto set rotated log file name suffix daily

dtformat = '%Y-%m-%d %H:%M:%S'
cfg = settings.get_settings()


def decode(s):
    #$page_content = gzuncompress(base64_decode($content)); php ==> base64.b64decode -> decode('zlib') -> decode("utf8")
    npd = base64.b64decode(s)
    result = npd.decode('zlib')
    sn = result.decode("utf8")
    sn = sn.replace(""", '"')
    return sn


def main():
    logger.info(u"start check showdoc diff, ver: %s" % (version.version))
    #print cfg
    qry = sqlitedb.DBQuery(cfg['db'])
コード例 #3
0
ファイル: web_resources.py プロジェクト: GLab/ToMaTo
__author__ = "t-gerhard"

import json, urllib2
from urlparse import urljoin

from lib.settings import get_settings, Config
import settings as config_module

settings = get_settings(config_module)

from django.shortcuts import render
import time
from .lib import wrap_rpc
from .lib.reference_library import techs
from .lib.exceptionhandling import wrap_and_handle_current_exception


def web_resources():
    return {"executable_archives": executable_archives(), "custom_element_icons": custom_element_icons()}


def custom_element_icons(ignore_errors=True):
    url = settings.get_web_resource_location(Config.WEB_RESOURCE_CUSTOM_ELEMENT_ICONS)
    try:
        icon_setting_list = json.load(urllib2.urlopen(url))
        for l in icon_setting_list:
            l["url"] = urljoin(url, l["url"])
        return icon_setting_list
    except:
        if ignore_errors:
            return ()
コード例 #4
0
ファイル: debug.py プロジェクト: githubsoft/pymon
def is_debug():
    # Check if debugging is enabled
    debugging = get_settings()["debug"]

    return debugging