コード例 #1
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/html'

        # If the user clicks on the delete button
        if self.request.get('button') == 'Delete':
            check = self.request.get('hidden_id')
            myuser_key = ndb.Key('Gpu', check)
            myuser_key.delete()

            result = Gpu.query().fetch()
            logout = users.create_logout_url('/')

            # generate a map that contains everything that we need to pass to the template
            template_values = {'result': result, 'logout': logout}

            # asking jinja to render the template files with the template values
            template = JINJA_ENVIRONMENT.get_template('main.html')
            self.response.write(template.render(template_values))

        else:
            result = Gpu.query().fetch()
            logout = users.create_logout_url('/')

            # generate a map that contains everything that we need to pass to the template
            template_values = {'result': result, 'logout': logout}

            # asking jinja to render the template files with the template values
            template = JINJA_ENVIRONMENT.get_template('main.html')
            self.response.write(template.render(template_values))
コード例 #2
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/html'

        # If the user clicks on the Compare button
        if self.request.get('Button') == 'Compare':
            logout = users.create_logout_url('/')
            result = Gpu.query().fetch()
            list_of_devices_checked = []

            # Counter to ensure the user compares at least 2 GPUs
            counter = 0

            # Storing the values selected by the user
            for x in result:
                name = "checkbox_" + x.key.id()
                x_value = self.request.get(name)
                if x_value:
                    counter = counter + 1
                    myuser_key = ndb.Key('Gpu', x.key.id())
                    gpu = myuser_key.get()
                    list_of_devices_checked.append(gpu)

            # If the user has selected at least 2 GPUs to be compared
            if counter > 1:

                # generate a map that contains everything that we need to pass to the template
                template_values = {
                    'logout': logout,
                    'list_of_devices_checked': list_of_devices_checked
                }

                # asking jinja to render the template files with the template values
                template = JINJA_ENVIRONMENT.get_template(
                    'display_compare.html')
                self.response.write(template.render(template_values))

            # If the user has not selected at least 2 GPUs to be compared
            else:
                error_message = 'Please select atleast two gpu devices'
                result = Gpu.query().fetch()
                logout = users.create_logout_url('/')

                # generate a map that contains everything that we need to pass to the template
                template_values = {
                    'logout': logout,
                    'result': result,
                    'error_message': error_message,
                }

                # asking jinja to render the template files with the template values
                template = JINJA_ENVIRONMENT.get_template('compare.html')
                self.response.write(template.render(template_values))

        # If the user clicks on the Cancel button
        elif self.request.get('Button') == 'Cancel':
            self.redirect('/main')
コード例 #3
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/html'

        if self.request.get('button') == 'Submit':

            geometryShader = bool(self.request.get('search_geometryShader'))
            tesselationShader = bool(
                self.request.get('search_tesselationShader'))
            shaderInt16 = bool(self.request.get('search_shaderInt16'))
            sparseBinding = bool(self.request.get('search_sparseBinding'))
            textureCompressionETC2 = bool(
                self.request.get('search_textureCompression'))
            vertextPipelineStoresandAtomics = bool(
                self.request.get('search_vertexPipelineStoresAndAtomics'))

            mysearchlist = Gpu.query()

            if geometryShader:
                mysearchlist = mysearchlist.filter(Gpu.geometryShader == True)
            if tesselationShader:
                mysearchlist = mysearchlist.filter(
                    Gpu.tesselationShader == True)
            if shaderInt16:
                mysearchlist = mysearchlist.filter(Gpu.shaderInt16 == True)
            if sparseBinding:
                mysearchlist = mysearchlist.filter(Gpu.sparseBinding == True)
            if textureCompressionETC2:
                mysearchlist = mysearchlist.filter(
                    Gpu.textureCompressionETC2 == True)
            if vertextPipelineStoresandAtomics:
                mysearchlist = mysearchlist.filter(
                    Gpu.vertexPipelineStoresAndAtomics == True)

        for i in mysearchlist:
            self.response.write(i.name + '<br/>')
コード例 #4
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/html'

        action = self.request.get('button')
        if action == 'Add GPU':
            name = self.request.get('name')
            manufacturer = self.request.get('manufacturer')
            dateIssued = datetime.strptime(self.request.get("dateIssued"),
                                           '%Y-%m-%d')
            geometryShader = self.request.get('geometryShader') == 'on'
            tesselationShader = self.request.get('tesselationShader') == 'on'
            shaderInt16 = self.request.get('shaderInt16') == 'on'
            sparseBinding = self.request.get('sparseBinding') == 'on'
            textureCompressionETC2 = self.request.get(
                'textureCompressionETC2') == 'on'
            vertexPipelineStoresAndAtomics = self.request.get(
                'vertexPipelineStoresAndAtomics') == 'on'

            options = Gpu.query()
            if geometryShader:
                options.filter(Gpu.geometryShader == True)

            if tesselationShader:
                options.filter(Gpu.tesselationShader == True)

            if shaderInt16:
                options.filter(Gpu.shaderInt16 == True)

            if sparseBinding:
                options.filter(Gpu.sparseBinding == True)

            if textureCompressionETC2:
                options.filter(Gpu.textureCompressionETC2 == True)

            if vertexPipelineStoresAndAtomics:
                options.filter(Gpu.vertexPipelineStoresAndAtomics == True)
            options = options.fetch()

            user = users.get_current_user()

            mygpu_key = ndb.Key('Gpu', name)
            mygpu = mygpu_key.get()

            mygpu.details.append(options)
            mygpu.put()
            template_values = {
                'options': options,
                'geometryShader': geometryShader,
                'tesselationShader': tesselationShader,
                'shaderInt16': shaderInt16,
                'sparseBinding': sparseBinding,
                'textureCompressionETC2': textureCompressionETC2,
                'vertexPipelineStoresAndAtomics':
                vertexPipelineStoresAndAtomics
            }

        template = JINJA_ENVIRONMENT.get_template('mainpage.html')
        self.response.write(template.render(template_values))
コード例 #5
0
    def get(self):
        # Retrieving information to display when the main page is loaded
        self.response.headers['Content-Type'] = 'text/html'
        result = Gpu.query().fetch()
        logout = users.create_logout_url('/')

        # generate a map that contains everything that we need to pass to the template
        template_values = {'result': result, 'logout': logout}

        # asking jinja to render the template files with the template values
        template = JINJA_ENVIRONMENT.get_template('main.html')
        self.response.write(template.render(template_values))
コード例 #6
0
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'
        result = Gpu.query().fetch()
        logout = users.create_logout_url('/')
        error_message = ''

        # generate a map that contains everything that we need to pass to the template
        template_values = {
            'logout': logout,
            'result': result,
            'error_message': error_message
        }

        # asking jinja to render the template files with the template values
        template = JINJA_ENVIRONMENT.get_template('compare.html')
        self.response.write(template.render(template_values))
コード例 #7
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/html'

        action = self.request.get('button')
        if action == 'Search':
            geometryShader = bool(self.request.get('geometryShader'))
            tesselationShader = bool(self.request.get('tesselationShader'))
            shaderInt16 = bool(self.request.get('shaderInt16'))
            sparseBinding = bool(self.request.get('sparseBinding'))
            textureCompressionETC2 = bool(
                self.request.get('textureCompressionETC2'))
            vertexPipelineStoresAndAtomics = bool(
                self.request.get('vertexPipelineStoresAndAtomics'))

            gpu_list = Gpu.query()

            if geometryShader:
                gpu_list = gpu_list.filter(Gpu.geometryShader == True)

            if tesselationShader:
                gpu_list = gpu_list.filter(Gpu.tesselationShader == True)

            if shaderInt16:
                gpu_list = gpu_list.filter(Gpu.shaderInt16 == True)

            if sparseBinding:
                gpu_list = gpu_list.filter(Gpu.sparseBinding == True)

            if textureCompressionETC2:
                gpu_list = gpu_list.filter(Gpu.textureCompressionETC2 == True)

            if vertexPipelineStoresAndAtomics:
                gpu_list = gpu_list.filter(
                    Gpu.vertexPipelineStoresAndAtomics == True)

            for i in gpu_list:
                self.response.write(i.name + '<br/>')
コード例 #8
0
ファイル: main.py プロジェクト: saadu25/Gpu-
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'
        user = users.get_current_user()
        if user == None:
            template_values = {
                'login_url': users.create_login_url(self.request.uri)
            }
            template = JINJA_ENVIRONMENT.get_template('loginpage_guest.html')
            self.response.write(template.render(template_values))
            return

        myuser_key = ndb.Key('MyUser', user.user_id())
        myuser = myuser_key.get()
        if myuser == None:
            myuser = MyUser(id=user.user_id())
            myuser.put()

        template_values = {
            'logout_url': users.create_logout_url(self.request.uri),
            'gpu': Gpu.query().fetch()
        }

        template = JINJA_ENVIRONMENT.get_template('login_page.html')
        self.response.write(template.render(template_values))
コード例 #9
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/html'

        # If the user clicks on the Search Button
        if self.request.get('button') == 'Search':
            geometryShader = self.request.get('checkbox_geometryShader')
            tesselationShader = self.request.get('checkbox_tesselationShader')
            shaderInt16 = self.request.get('checkbox_shaderInt16')
            sparseBinding = self.request.get('checkbox_sparseBinding')
            textureCompressionETC2 = self.request.get(
                'checkbox_textureCompressionETC2')
            vertexPipelineStoresAndAtomics = self.request.get(
                'checkbox_vertexPipelineStoresAndAtomics')

            result_of_querying = Gpu.query()

            # Displaying features for user to select from
            if geometryShader:
                result_of_querying = result_of_querying.filter(
                    Gpu.geometryShader == 'True')
            if tesselationShader:
                result_of_querying = result_of_querying.filter(
                    Gpu.tesselationShader == 'True')
            if shaderInt16:
                result_of_querying = result_of_querying.filter(
                    Gpu.shaderInt16 == 'True')
            if sparseBinding:
                result_of_querying = result_of_querying.filter(
                    Gpu.sparseBinding == 'True')
            if textureCompressionETC2:
                result_of_querying = result_of_querying.filter(
                    Gpu.textureCompressionETC2 == 'True')
            if vertexPipelineStoresAndAtomics:
                result_of_querying = result_of_querying.filter(
                    Gpu.vertexPipelineStoresAndAtomics == 'True')

            # Retrieving available GPUs based on the requested features
            result_of_querying = result_of_querying.fetch()

            # If there exists at least one GPU with the requested features
            if result_of_querying:
                logout = users.create_logout_url('/')
                message = ''

                # generate a map that contains everything that we need to pass to the template
                template_values = {
                    'result_of_querying': result_of_querying,
                    'logout': logout,
                    'message': message
                }

                # asking jinja to render the template files with the template values
                template = JINJA_ENVIRONMENT.get_template('display.html')
                self.response.write(template.render(template_values))

            # If there are no GPUs with the requested features
            else:
                result_of_querying = ''
                message = 'Sorry no GPU exists that supports the checked features'
                logout = users.create_logout_url('/')

                # generate a map that contains everything that we need to pass to the template
                template_values = {
                    'result_of_querying': result_of_querying,
                    'message': message,
                    'logout': logout
                }

                # asking jinja to render the template files with the template values
                template = JINJA_ENVIRONMENT.get_template('display.html')
                self.response.write(template.render(template_values))

        # If the user clicks on the Cancel Button
        elif self.request.get('button') == 'Cancel':
            self.redirect('/main')