Ejemplo n.º 1
0
 def initialize(self):
     """
     初始化
     """
     # 初始化日志
     # 数据初始化
     self.request_data = RequestData()
     self.response_data = ResponseData()
     self.processer = Processer(self.logger)
Ejemplo n.º 2
0
    def __init__(self, dir):
        self.db = FileDB(dir)
        self.record_id = 0
        self.journal_id = 0
        self.rollover = False

        info('Open new journal')
        self.open_journal(self.journal_id)
        Processer.__init__(self)
Ejemplo n.º 3
0
class MainHandler(tornado.web.RequestHandler):
    """
    服务处理类
    """

    logger = EasyLog()
    logger.init_log("../logs/poi")

    def initialize(self):
        """
        初始化
        """
        # 初始化日志
        # 数据初始化
        self.request_data = RequestData()
        self.response_data = ResponseData()
        self.processer = Processer(self.logger)

    def get(self):
        """
        处理get请求
        """
        return self.run()

    def post(self):
        """
        处理post请求
        """
        return self.run()

    def run(self):
        """
        处理post请求
        """
        # 解析传入参数
        self.request_data.reset()
        self.request_data.aid = self.get_argument('globalId')
        self.request_data.content = urllib2.unquote(
            str(self.get_argument('content')))
        self.request_data.city_id = self.get_argument('city_id', default="")
        self.request_data.city_name = self.get_argument('city_name',
                                                        default="")
        self.request_data.debug = False if self.get_argument(
            'debug', "false") == 'false' else True
        #self.log_req()
        # 创造传出参数
        self.response_data.reset()
        start_time = datetime.datetime.now()
        self.processer.run(self.request_data, self.response_data)
        end_time = datetime.datetime.now()
        run_time = "运行时间:" + str(end_time - start_time) + "微秒"
        MainHandler.logger.info(run_time)
        #self.log_res()
        self.write(self.response_data.package())

    def log_req(self):
        """
        打印请求日志信息
        """
        ip = self.request.remote_ip
        path = self.request.uri
        #body = self.request.body
        body = self.request_data.tostr()
        request = "Request[" + ip + "]" + "[" + path + "]" + "[" + body + "]"
        MainHandler.logger.info(request)

    def log_res(self):
        """
        打印响应日志信息
        """
        ip = self.request.remote_ip
        path = self.request.uri
        body = self.response_data.tostr()
        response = "Response[" + ip + "]" + "[" + path + "]" + "[" + body + "]"
        MainHandler.logger.info(response)
Ejemplo n.º 4
0
 def start(self):
     info('Starting journal rollover Timer')
     Timer(300, self.rollover_handler).start()
     Processer.start(self)
Ejemplo n.º 5
0
from processer import Processer

pro = Processer(postings=[{'my': [(1,2),(2,4),(3,5)]}])
pro.rank('my my my, My name is Xonas')
Ejemplo n.º 6
0
from processer import Processer
from tkinter import *
import pandas as pd

proAutor = Processer(postings_path='../index/indexes/authors_index.json')
proTitulo = Processer(postings_path='../index/indexes/titles_index.json')
proGeral = Processer(postings_path='../index/indexes/general_index.json')

pageData = pd.read_csv('../classifier/data/data.csv')

root = Tk()
root.geometry("1000x600")  #You want the size of the app to be 500x500
root.resizable(0, 0)  #Don't allow resizing in the x or y direction


def bAutorFunc():
    frame.config({'borderwidth': 2})
    myResult = proAutor.rank((eAutor.get() + '.author').lower(),
                             idf=bool(varcheck.get()))
    r1.set(
        str((pageData['link'][myResult[0][0]]) + '    Score: ' +
            str(myResult[0][1])))
    r2.set(
        str((pageData['link'][myResult[1][0]]) + '    Score: ' +
            str(myResult[1][1])))
    r3.set(
        str((pageData['link'][myResult[2][0]]) + '    Score: ' +
            str(myResult[2][1])))
    r4.set(
        str((pageData['link'][myResult[3][0]]) + '    Score: ' +
            str(myResult[3][1])))