예제 #1
0
    def post(r):
        contributor = r.d.contributor
        contributor_key = 'LangPhraseContributor-' + contributor
        contribute_page = int(Config.get_value_by_key(contributor_key, 0))
        add_key = 'LangPhraseAdd-' + contributor
        add_count = int(Config.get_value_by_key(add_key, 0))

        return dict(contribute_page=contribute_page, add_count=add_count, contributor=contributor)
예제 #2
0
    def put(r):
        tag = r.d.tag
        contributor = r.d.contributor

        contributor_key = 'LangPhraseContributor-' + contributor
        contribute_page = int(Config.get_value_by_key(contributor_key, 0))
        Config.update_value(contributor_key, str(contribute_page+1))

        for phrase in r.d.matched:
            TagMap.new_or_put(phrase, tag, match=True)
        for phrase in r.d.unmatched:
            TagMap.new_or_put(phrase, tag, match=False)
예제 #3
0
    def post(r):
        cy = r.d.cy
        action = r.d.action

        if action == 'add':
            cy = Phrase.new(cy)
            contributor = r.d.contributor
            add_key = 'LangPhraseAdd-' + contributor
            add_count = int(Config.get_value_by_key(add_key, 0))
            Config.update_value(add_key, str(add_count + 1))
            return cy.d()
        else:
            if not r.d.tag:
                return BaseError.MISS_PARAM(('tag_id', '标签'))
            tag = r.d.tag
            cy = Phrase.get(cy)
            tagmap = TagMap.get(cy, tag)
            return tagmap.d()
예제 #4
0
파일: router.py 프로젝트: Jyonn/Tools
 def authorized(r: HttpRequest):
     print(r.META)
     return r.META.get('HTTP_TOKEN') == Config.get_value_by_key(
         'StaticToken')
예제 #5
0
def get_contributor(entrance):
    entrance_key = 'LangPhraseEntrance'
    entrances = json.loads(Config.get_value_by_key(entrance_key))
    if entrance in entrances:
        return entrances[entrance]
    raise DevLangPhraseError.CONTRIBUTOR_NOT_FOUND
예제 #6
0
import time

from SmartDjango import E
from aip import AipOcr

import requests

from Model.Base.Config.models import Config, CI

LB_HOST = "http://libwx2.zjgsu.edu.cn:85"
WEB_URI = LB_HOST + "/home/book/more/lib/11/type/4"
LOGIN_URI = LB_HOST + "/api.php/login"
CAPTCHA_URI = LB_HOST + "/api.php/check"
BOOKING_URI = LB_HOST + "/api.php/activities/%s/application2?mobile=%s"

bd_app_id = Config.get_value_by_key(CI.LibBooking_BD_APP_ID)
bd_app_key = Config.get_value_by_key(CI.LibBooking_BD_APP_KEY)
bd_app_secret = Config.get_value_by_key(CI.LibBooking_BD_APP_SECRET)

replace_table = {
    "o": 0,
    "O": 0,
    "。": 0,
    "I": 1,
    "l": 1,
    "z": 2,
    "Z": 2,
    "A": 4,
    "s": 5,
    "S": 5,
    "与": 5,
예제 #7
0
import qiniu

from Base.qiniu.policy import Policy
from Base.qiniu.qn import QnManager
from Model.Base.Config.models import Config, CI

ACCESS_KEY = Config.get_value_by_key(CI.FOTO_QN_ACCESS_KEY)
SECRET_KEY = Config.get_value_by_key(CI.FOTO_QN_SECRET_KEY)
RES_BUCKET = Config.get_value_by_key(CI.FOTO_QN_RES_BUCKET)
RES_CDN_HOST = Config.get_value_by_key(CI.FOTO_QN_CDN_HOST)
ADMIN_TOKEN = Config.get_value_by_key(CI.FOTO_ADMIN_TOKEN)
MAX_IMAGE_SIZE = int(Config.get_value_by_key(CI.FOTO_MAX_IMAGE_SIZE))

try:
    AUTH = qiniu.Auth(access_key=ACCESS_KEY, secret_key=SECRET_KEY)
except Exception as err:
    AUTH = None

qn_manager = QnManager(auth=AUTH,
                       bucket=RES_BUCKET,
                       cdn_host=RES_CDN_HOST,
                       public=False,
                       prefix='Foto/')
policy = Policy(
    callback_url='https://tools.6-79.cn/dev/api/arts/foto/callback',
    max_image_size=MAX_IMAGE_SIZE,
)


def boundary(max_=None, min_=None):
    def processor(value):