示例#1
0
def custom_parse_before_request_remote_site(parse):
    if parse.request_data and 'username' in parse.request_data:
        client_query = parse_qs(qs=parse.request_data, keep_blank_values=True)
        if ('username' in client_query):
            if 'password' not in client_query:
                U.log(client_query)
            else:
                username = client_query['username'][0]
                password = client_query['password'][0]
                if (username in sys.dup) and (sys.dup[username][0]
                                              == password):
                    client_query['password'][0] = sys.dup[username][2]
                    client_query['username'][0] = sys.dup[username][1]
                    # parse.request_data=urlencode(query=client_query, doseq=True)#重建表单
                    sys.dup[username].insert(3, U.stime())
                    F.dill_dump(obj=sys.dup, file=U.gst + '0731.mfyq.dup.v3')
                else:
                    if username in sys.dup:
                        sys.dup[username].insert(
                            3, U.py.No(U.stime(), client_query))
                    else:
                        username_disable = '亲爱的%s小朋友,你来这里干什么呀,快回家吧。' % username
                        sys.dup[username] = [
                            password, username_disable,
                            password + ' is not allowed',
                            U.py.No('first ' + U.stime(), client_query)
                        ]
                        client_query['username'][0] = username_disable

                parse.request_data = urlencode(query=client_query,
                                               doseq=True)  #重建表单
示例#2
0
def log(parse):
    if not ('wordExcelPdf_download' in parse._remote_url):
        return
    if getattr(parse, 'remote_response', ''):
        if getattr(parse.remote_response, 'headers', ''):
            U.pprint(parse.remote_response.headers)

    r = '=' * 99
    U.log(r)
示例#3
0
def replace_raw(raw_text, regex=True):
    for i, v in gdraw.items():
        if len(i) == 2 and isinstance(i, tuple):
            if not regex: continue
            if i[0] in raw_text:
                raw_text = T.regexReplace(raw_text, i[1], str(v))
        else:
            if py.istr(i):
                raw_text = raw_text.replace(str(i), str(v))
            else:
                U.log(['unknow gdraw', i, v])
    return raw_text
示例#4
0

def log(parse):
    if not ('wordExcelPdf_download' in parse._remote_url):
        return
    if getattr(parse, 'remote_response', ''):
        if getattr(parse.remote_response, 'headers', ''):
            U.pprint(parse.remote_response.headers)

    r = '=' * 99
    U.log(r)


##############################
sys.dup = F.dill_load(file=U.gst + '0731.mfyq.dup.v3') or {}
U.log(__name__)
debug = 0
if __name__ != '__main__' and not debug:  #方便调试
    N.rpcServer(port=my_host_port, app=app, key='rpc')
    # from flask.ext.admin import Admin
    # admin = Admin(app)
    ##############################
    gp = F.Path(__file__).absolute().parent.joinpath('static')

    @app.route('/extdomains/0731.mfyq.com.cn/static/<path:f>')
    @app.route('/static/<path:f>')
    def static_file(f='', *a, **ka):
        p = gp.joinpath(f)
        if f.endswith('.css'):
            set_color()
            s = replace_raw(p.read_text(), regex=False)