Beispiel #1
0
 def get(self, id):
     try:
         s = int(id)
         r = model.GameReplay.get_by_id(s)
     except ValueError:
         r = model.GameReplay.all().filter('game =', id).get()
         if r:
             self.redirect('/replay/%s' % r.key().id())
             return
     if not r:
         self.error(404)
         return
     if not r:
         self.error(404)
         return
     vars = {
         'server': etc.server(),
         'gserver': etc.gserver(),
     }
     vars['key'] = etc.map_key()
     vars['replay'] = r
     if self.request.query_string == 'chat_only':
         vars['record'] = zlib.decompress(r.replay)
         self.renderPage('replay_chat.html', vars)
     else:
         vars['record'] = zlib.decompress(r.replay).replace('\"', '\\"')
         self.renderPage('index.html', vars)
Beispiel #2
0
    def get(self):
        user = model.User.auth(userlib.GoogleUser, self.request, self)

        if user == 'internal_work':
            return

        if user:
            session = model.Session.gen_session(user)
            utils.Cookie.set('gssession', str(session))

            vars = {
                'auth_type': 'google',
                'user': user,
                'session': session,
                'your_key': user.key(),
                'access_friends': False,
                'key': etc.map_key(),
                'server': etc.server(),
                'gserver': etc.gserver(),
                'settings': user.getSettingsAsArray(),
                'hide_bottom': True,
            }
            if not user.tutorial_done:
                vars['run_tutorial'] = True

            self.renderPage('index.html', vars)
        else:
            self.renderText('Please reload the page in few seconds.')
Beispiel #3
0
    def post(self):
        user = model.User.auth(userlib.FBUser, self.request, self)

        if user == 'internal_work':
            return
        elif user:
            session = model.Session.gen_session(user)
            utils.Cookie.set('gssession', str(session))

            vars = {
                'auth_type': 'fb',
                'user': user,
                'session': session,
                'your_key': user.key(),
                'access_friends': user.access_friends(),
                'key': etc.map_key(),
                'server': etc.server(),
                'gserver': etc.gserver(),
                'settings': user.getSettingsAsArray(),
                'fb_app_id': userlib.FBUser.APP_ID,
                'access_token': user.auth_user.access_token,
            }
            if not user.tutorial_done:
                vars['run_tutorial'] = True

            self.renderPage('index.html', vars)
        else:
            self.renderText('Incorrect authorization')
Beispiel #4
0
    def get(self):
        user = model.User.auth(userlib.OdnkUser, self.request, self)
        if user:
            session = model.Session.gen_session(user)
            utils.Cookie.set('gssession', str(session))

            vars = {
                'auth_type': 'odnk',
                'user': user,
                'session': session,
                'your_key': user.key(),
                'access_friends': user.access_friends(),
                'key': etc.map_key(),
                'server': etc.server(),
                'gserver': etc.gserver(),
                'odnk_api_server': user.auth_user.api_server,
                'odnk_apiconnection': user.auth_user.apiconnection,
                'settings': user.getSettingsAsArray()
            }
            if not user.tutorial_done:
                vars['run_tutorial'] = True

            self.renderPage('index.html', vars)
        else:
            self.renderText('Incorrect authorization')
Beispiel #5
0
    def get(self):
        try:
            user = model.User.auth(userlib.MMUser, self.request, self)
        except userlib.MMNotInstalledException:
            self.renderPage('mm_install.html')
        else:
            if user:
                session = model.Session.gen_session(user)
                utils.Cookie.set('gssession', str(session))

                vars = {
                    'auth_type': 'mm',
                    'user': user,
                    'session': session,
                    'your_key': user.key(),
                    'access_friends': user.access_friends(),
                    'key': etc.map_key(),
                    'server': etc.server(),
                    'gserver': etc.gserver(),
                    'settings': user.getSettingsAsArray(),
                    'mm_app_id': userlib.MMUser.MM_APP_ID,
                    'mm_private_key': userlib.MMUser.MM_PRIVATE_KEY
                }
                if not user.tutorial_done:
                    vars['run_tutorial'] = True

                self.renderPage('index.html', vars)
            else:
                self.renderText('Incorrect authorization')
Beispiel #6
0
def request_twisted_webdoor(params, _deferred=False):
    global TWISTED_WEBDOOR
    if not TWISTED_WEBDOOR: # lazy init
        TWISTED_WEBDOOR = 'http://' + etc.server() + ':1080/thedoors.php?keyphrase=' + etc.TWISTED_PWD_OUT + '&'
    try:
        err = False
        url = TWISTED_WEBDOOR + urllib.urlencode(params)
        logging.info(url)
        response = urllib2.urlopen(url)
    except urllib2.URLError:
        err = True
    if response.code != 200 or err:
        if _deferred:
            return
        raise Exception("Cannot open url")
    html = response.read()
    return html