# Path: mod/_config.py

# 
# Path: mod/_config.py

# 
# Path: mod/models/curriculum_cookie.py
# class Curriculum_CookieCache(Base):
#     __tablename__ = 'curriculum_cookie'
#     cid = Column(Integer, primary_key=True)
#     cookie = Column(String(10240), nullable=False)
#     date = Column(Integer, nullable=False)
#     last = Column(Integer, nullable=False)
#     time = Column(Integer, nullable=False)


from .._config import start_date
from .._config import term as default_term
from BeautifulSoup import BeautifulSoup
from config import CURR_URL, TIME_OUT,TERM_URL,JWC_URL
from tornado.httpclient import HTTPRequest, AsyncHTTPClient
from collections import OrderedDict
from ..models.curriculum_cookie import Curriculum_CookieCache
from sqlalchemy.orm.exc import NoResultFound
from time import time
import tornado.web
import tornado.gen
import urllib
import json
import re,sys,traceback
                    request_timeout=TIME_OUT)
                response = yield tornado.gen.Task(client.fetch, request)
                body = response.body
                if not body:
                    retjson['code'] = 408
                    retjson['content'] = 'time out'
                else:
                    pat = re.compile(ur'没有找到该学生信息', re.U)

                    match = pat.search(body)
                    if match:
                        retjson['code'] = 401
                        retjson['content'] = 'card number not exist'
                    else:
                        retjson['content'] = self.parser(body)
                        retjson['sidebar'] = self.sidebarparser(body)
                        
                        #url = "http://58.192.114.179/classroom/common/gettermlistex"
                        #client = AsyncHTTPClient()
                        #request = HTTPRequest(
                        #    url = url, 
                        #    method = "GET",
                        #    request_timeout=3
                        #)
                        #response = yield tornado.gen.Task(client.fetch, request)
                        #content = json.loads(response.body)
                        #termTemp = term.split('-')
                        #term = "20"+termTemp[0]+"-"+"20"+termTemp[1]+"-"+termTemp[2]
                        retjson['content']['startdate']={
                            'month': start_date.month - 1,

# Path: mod/_config.py

# 
# Path: mod/_config.py

# 
# Path: mod/models/curriculum_cookie.py
# class Curriculum_CookieCache(Base):
#     __tablename__ = 'curriculum_cookie'
#     cid = Column(Integer, primary_key=True)
#     cookie = Column(String(10240), nullable=False)
#     date = Column(Integer, nullable=False)
#     last = Column(Integer, nullable=False)
#     time = Column(Integer, nullable=False)


# Path: mod/curriculum/curriculum_handler.py
from .._config import start_date
from .._config import term as default_term
from BeautifulSoup import BeautifulSoup
from config import CURR_URL, TIME_OUT,TERM_URL,JWC_URL
from tornado.httpclient import HTTPRequest, AsyncHTTPClient
from collections import OrderedDict
from ..models.curriculum_cookie import Curriculum_CookieCache
from sqlalchemy.orm.exc import NoResultFound
from time import time
import tornado.web
import tornado.gen
import urllib
import json
import re,sys,traceback

                    request_timeout=TIME_OUT)
                response = yield tornado.gen.Task(client.fetch, request)
                body = response.body
                if not body:
                    retjson['code'] = 408
                    retjson['content'] = 'time out'
                else:
                    pat = re.compile(ur'没有找到该学生信息', re.U)

                    match = pat.search(body)
                    if match:
                        retjson['code'] = 401
                        retjson['content'] = 'card number not exist'
                    else:
                        retjson['content'] = self.parser(body)
                        retjson['sidebar'] = self.sidebarparser(body)
                        
                        #url = "http://58.192.114.179/classroom/common/gettermlistex"
                        #client = AsyncHTTPClient()
                        #request = HTTPRequest(
                        #    url = url, 
                        #    method = "GET",
                        #    request_timeout=3
                        #)
                        #response = yield tornado.gen.Task(client.fetch, request)
                        #content = json.loads(response.body)
                        #termTemp = term.split('-')
                        #term = "20"+termTemp[0]+"-"+"20"+termTemp[1]+"-"+termTemp[2]
                        retjson['content']['startdate']={
                            'month': start_date.month - 1,

                            'day'  : start_date.day