# Path: auth/kancolle.py
# class KancolleAuth:
#     def __init__(self, login_id, password):
#     def __del__(self):
#     def _request(self, url, method='GET', data=None, timeout_message='连接失败', timeout=10):
#     def _get_dmm_tokens(self):
#     def _get_ajax_token(self):
#     def _get_osapi_url(self):
#     def _get_world(self):
#     def _get_api_token(self):
#     def get_osapi(self):
#     def get_entry(self):


import asyncio
import aiohttp.web
import aiohttp_jinja2
from aiohttp_session import get_session
from auth.kancolle import KancolleAuth, OOIAuthException

        login_id = post.get('login_id', None)
        password = post.get('password', None)
        mode = int(post.get('mode', 1))

        session['mode'] = mode

        if login_id and password:
            kancolle = KancolleAuth(login_id, password)
            if mode in (1, 2, 3):
                try:
                    yield from kancolle.get_entry()
                    session['api_token'] = kancolle.api_token
                    session['api_starttime'] = kancolle.api_starttime
                    session['world_ip'] = kancolle.world_ip
                    if mode == 2:
                        return aiohttp.web.HTTPFound('/kcv')
                    elif mode == 3:
                        return aiohttp.web.HTTPFound('/poi')
                    else:
                        return aiohttp.web.HTTPFound('/kancolle')

                except OOIAuthException as e:
                    context = {'errmsg': e.message, 'mode': mode}
                    return aiohttp_jinja2.render_template('form.html', request, context)
            elif mode == 4:
                try:
                    osapi_url = yield from kancolle.get_osapi()
                    session['osapi_url'] = osapi_url
                    return aiohttp.web.HTTPFound('/connector')

# Path: auth/kancolle.py
# class KancolleAuth:
#     def __init__(self, login_id, password):
#     def __del__(self):
#     def _request(self, url, method='GET', data=None, timeout_message='连接失败', timeout=10):
#     def _get_dmm_tokens(self):
#     def _get_ajax_token(self):
#     def _get_osapi_url(self):
#     def _get_world(self):
#     def _get_api_token(self):
#     def get_osapi(self):
#     def get_entry(self):


# Path: handlers/frontend.py
import asyncio
import aiohttp.web
import aiohttp_jinja2
from aiohttp_session import get_session
from auth.kancolle import KancolleAuth, OOIAuthException


        login_id = post.get('login_id', None)
        password = post.get('password', None)
        mode = int(post.get('mode', 1))

        session['mode'] = mode

        if login_id and password:
            kancolle = KancolleAuth(login_id, password)
            if mode in (1, 2, 3):
                try:
                    yield from kancolle.get_entry()
                    session['api_token'] = kancolle.api_token
                    session['api_starttime'] = kancolle.api_starttime
                    session['world_ip'] = kancolle.world_ip
                    if mode == 2:
                        return aiohttp.web.HTTPFound('/kcv')
                    elif mode == 3:
                        return aiohttp.web.HTTPFound('/poi')
                    else:
                        return aiohttp.web.HTTPFound('/kancolle')

                except OOIAuthException as e:
                    context = {'errmsg': e.message, 'mode': mode}
                    return aiohttp_jinja2.render_template('form.html', request, context)
            elif mode == 4:
                try:
                    osapi_url = yield from kancolle.get_osapi()
                    session['osapi_url'] = osapi_url
                    return aiohttp.web.HTTPFound('/connector')

                except OOIAuthException as e: