Esempio n. 1
0
    def get(self, url_ext):
        self.check_for_root()

        logging.debug("charts_handler")
        logging.debug("Params: %s", url_ext)
        content = template.render('template_html/branding_bar.html',
                                  {'page': "Charts"})

        url_split = sup.url_split(url_ext)

        l_name = config.root_node()
        tracks_if = data_store.tracks(l_name)

        num_args = len(url_split)
        logging.debug("Num args: " + str(num_args) +
                      ', list: ' + str(url_split))
        if num_args == 0:
            #generate html containing top times for each track found
            logging.debug('list all')
            t_list = tracks_if.get_all()
            logging.debug('track list: ' + str(t_list))
            for t_entity in tracks_if.get_all():
                logging.debug('track: ' + t_entity.get_name())
                content += genTrackList(l_name,
                                        t_entity,
                                        base_url='./',
                                        list_gen=genFastestResultList)

        elif num_args == 1:
            #generate list of lap times for a specific track
            logging.debug('list by track')
            content += genTrackList(l_name,
                                    tracks_if.get_by_name(url_split[0]),
                                    base_url='./',
                                    list_gen=genFastestResultList)

        elif num_args == 2:
            #list all times for a specific track and car class
            logging.debug('list by track and car class')
            content += genClassList(l_name,
                                    url_split[0],
                                    url_split[1],
                                    base_url='../',
                                    list_gen=genResultList)

        elif num_args == 3:
            #list all the times for a specific track, car class, and driver
            logging.debug('list by track and car class and driver')
            content += genClassList(l_name,
                              url_split[0],
                              url_split[1],
                              base_url='../../',
                              d_name=url_split[2],
                              list_gen=genResultList,
                              template_html='template_html/driver_result.html')

        self.nav_bar_params = {'charts': 'class="active"'}
        self.render(content)
Esempio n. 2
0
    def get(self, url_ext):
        logging.debug("serverHandler")

        url_split = sup.url_split(url_ext)

        content = template.render('template_html/branding_bar.html',
                                  {'page': "Fluffy's Dedicated Servers"})

        martinsServerStatus = []  # ss.serverInfo().run()

        content += self.serversPage(url_split, martinsServerStatus)

        self.nav_bar_params = {'servers': 'class="active"'}
        self.render(content)
Esempio n. 3
0
    def get(self, url_ext):

        self.check_for_root()

        logging.info("admin_handler")
        logging.info(url_ext)
        page_txt = "Admin"

        content = template.render('template_html/branding_bar.html',
                                      {'page': page_txt})

        url_split = sup.url_split(url_ext)

        if len(url_split) == 0:
            content += template.render('template_html/admin.html', {})

        else:

            if url_split[0] == 'servers':
                content += self.serversPage(url_split[1:])

            elif url_split[0] == 'lap_insert':
                logging.info("lap_insert")

                content += self.lap_insert()

            elif url_split[0] == 'insert_dummy_data':
                logging.info("Inserting Dummy Data")

                dummy_data = sup.create_dictionary(config.input_labels(),
                                                   config.dummy_test_data())

                db_if = data_store.interface(config.root_node())
                for data in dummy_data:
                    db_if.add_lap_time(data)

                self.redirect('/admin/')

            elif url_split[0] == 'importfromfile':
                logging.debug("insert from file")

                content += template.render('template_html/importfromfile.html',
                                           {})

            else:
                self.redirect('/admin/')
                content += template.render('template_html/admin.html', {})

        self.render(content)
Esempio n. 4
0
    def get(self, url_ext):
        logging.debug(url_ext)

        self.check_for_root()

        url_split = sup.url_split(url_ext)
        url_root = ''.join(url_split[0:1])  # this works if the list is empty

        content = ""

        if (url_root in self.handlers):
            content = self.handlers[url_root](url_split[1:])
        else:
            self.redirect('/r/welcome')

        if (url_root == 'servers'):
            self.head_params['meta_extra'] = \
                """<meta http-equiv="cache-control" content="no-cache">
                   <meta http-equiv="pragma" content="no-cache">
                   <meta http-equiv="expires" content="-1000">
                   <meta http-equiv="refresh" content="200">"""

        self.nav_bar_params = {url_root: 'class="active"'}
        self.render(content)
Esempio n. 5
0
    def post(self, url_ext):

        logging.info("post")
        logging.info(url_ext)
        self.check_for_root()

        url_split = sup.url_split(url_ext)

        if len(url_split) == 0:
            self.redirect('/admin/')

        if url_split[0] == "lap_insert":
            logging.info("lap time submitted")

            lap_details = []
            lap_details['driverName'] = self.request.get("driverName")
            lap_details['carClass'] = self.request.get("carClass")
            lap_details['carName'] = self.request.get("carName")
            lap_details['trackName'] = self.request.get("trackName")
            lap_details['firstSec'] = float(self.request.get("firstSector"))
            lap_details['secondSec'] = float(self.request.get("secondSector"))
            lap_details['totalTime'] = float(self.request.get("totalTime"))
            logging.info(str(lap_details))

            db_if = data_store.interface(config.root_node())
            db_if.add_lap_time(lap_details)

            self.redirect('/admin/')

        elif url_split[0] == "importfromfile":
            logging.info("importfromfile")

            xmlfile = self.request.POST.get('xmlfile').file.read()
            results = ET.fromstring(xmlfile)

            db_if = data_store.interface(config.root_node())

            for result in results:
                db_if.add_lap_time(sup.translateXMLdictionary(result.attrib))

            self.redirect('/admin/')

        elif (
              (url_split[0] == "update_server") or
              (
                  (url_split[0] == "servers") and
                  (url_split[1] == "update_server")
              )
             ):

            logging.info("update_server")

            oldServerName = self.request.get("originalName")

            if self.request.get("button") == "delete":
                ss.interface().deleteServerByName(oldServerName)

            elif self.request.get("button") == "add":
                s = ss.interface().getServerByName(oldServerName)
                logging.info(s)
                if s is None:
                    logging.info("create new")
                    s = ss.serverSetup(name=self.request.get("nsame"))

                    logging.info("s is:" + str(s))

                s.name = self.request.get("name")
                s.track_name = self.request.get("track_name")
                s.car_class_name = self.request.get("car_class_name")
                s.description = self.request.get("description")

                if s.image != '':
                    s.imageBlob = ndb.BlobInfo(self.image)

                logging.info(str(s))
                s.put()

                self.redirect('/admin/servers/' + s.name)

            else:
                self.redirect('/admin/servers/')

        else:
            logging.info("other url:" + str(url_split))
            self.redirect('/admin/')