# Path: mod/_config.py

# 
# Path: mod/models/gpa_cache.py
# class GpaCache(Base):
#     __tablename__ = 'gpa'
#     cardnum = Column(Integer, primary_key=True)
#     text = Column(String(4096))
#     date = Column(Integer, nullable=False)


from .._config import gpaCacheTime
from config import VERCODE_URL, LOGIN_URL, INFO_URL
from config import STANDARD, TIME_OUT
from tornado.httpclient import HTTPRequest, AsyncHTTPClient
from BeautifulSoup import BeautifulSoup
from PIL import Image
from sqlalchemy.orm.exc import NoResultFound
from ..models.gpa_cache import GpaCache
from time import time,localtime, strftime
import tornado.web
import tornado.gen
import urllib
import json
import io
import base64
                        retjson['code'] = 401
                        retjson['content'] = 'wrong card number or password'
                    else:
                        request = HTTPRequest(INFO_URL,
                                              request_timeout=TIME_OUT,
                                              headers={'Cookie': cookie})
                        response = yield tornado.gen.Task(client.fetch, request)
                        if not response.headers:
                            retjson['code'] = 408
                            retjson['content'] = 'time out'
                        else:
                            retjson['content'] = self.parser(response.body)
        ret = json.dumps(retjson, ensure_ascii=False, indent=2)
        self.write(ret)
        self.finish()
        # refresh cache
        if retjson['code'] == 200:
            status.date = int(time())
            status.text = base64.b64encode(ret)
            self.db.add(status)
            try:
                self.db.commit()
            except Exception,e:
                self.db.rollback()
            finally:
                self.db.remove()

    def recognize(self, img):
        start = [13, 59, 105, 151]
        result = ''

# Path: mod/_config.py

# 
# Path: mod/models/gpa_cache.py
# class GpaCache(Base):
#     __tablename__ = 'gpa'
#     cardnum = Column(Integer, primary_key=True)
#     text = Column(String(4096))
#     date = Column(Integer, nullable=False)


# Path: mod/gpa/gpa_handler.py
from .._config import gpaCacheTime
from config import VERCODE_URL, LOGIN_URL, INFO_URL
from config import STANDARD, TIME_OUT
from tornado.httpclient import HTTPRequest, AsyncHTTPClient
from BeautifulSoup import BeautifulSoup
from PIL import Image
from sqlalchemy.orm.exc import NoResultFound
from ..models.gpa_cache import GpaCache
from time import time,localtime, strftime
import tornado.web
import tornado.gen
import urllib
import json
import io
import base64

                        retjson['code'] = 401
                        retjson['content'] = 'wrong card number or password'
                    else:
                        request = HTTPRequest(INFO_URL,
                                              request_timeout=TIME_OUT,
                                              headers={'Cookie': cookie})
                        response = yield tornado.gen.Task(client.fetch, request)
                        if not response.headers:
                            retjson['code'] = 408
                            retjson['content'] = 'time out'
                        else:
                            retjson['content'] = self.parser(response.body)
        ret = json.dumps(retjson, ensure_ascii=False, indent=2)
        self.write(ret)
        self.finish()
        # refresh cache
        if retjson['code'] == 200:
            status.date = int(time())
            status.text = base64.b64encode(ret)
            self.db.add(status)
            try:
                self.db.commit()
            except Exception,e:
                self.db.rollback()
            finally:
                self.db.remove()

    def recognize(self, img):
        start = [13, 59, 105, 151]
        result = ''

        for i in start: