Esempio n. 1
0
 def get(self):
     user = users.get_current_user()
     email_address = user.nickname()
     currentUser = GoogleUser.query().filter(
         GoogleUser.email == email_address).get()
     userColorImg = ""
     data = {
         "user_color":
         currentUser.color,
         "user_hobbies":
         currentUser.hobbies,
         "user_living_and_travel":
         currentUser.living_and_travel,
         "user_education_and_careers":
         currentUser.education_and_careers,
         "user_music":
         currentUser.music,
         "colorImage":
         getImage(currentUser.color),
         "hobbies_image":
         getImage(currentUser.hobbies),
         "living_and_travel_image":
         getImage(currentUser.living_and_travel),
         "education_and_careers_image":
         getImage(currentUser.education_and_careers),
         "music_image":
         getImage(currentUser.music),
         "connect_image":
         getImage("iphone")
     }
     results_page = jinja_env.get_template('pages/results.html')
     self.response.write(results_page.render(data))
Esempio n. 2
0
 def get(self):
     get = self.request.GET
     if 'img_id' in get :
        image = db.get(get['img_id'])
        if image.picture:
            self.response.headers['Content-Type'] = "image/png"
            self.response.out.write(image.picture)
        else:
            self.response.out.write("No image")
     elif 'img_alias' in get :
        image = getImage(get['img_alias'])
        if image :
            self.response.headers['Content-Type'] = "image/png"
            self.response.out.write(image.picture)
        else :
            self.response.out.write("No image")
     else:
         self.response.out.write("No image")
if __name__ == '__main__':

    images, http = getImagesFromGDrive()

    print("opencv version: %s" % cv2.__version__)

    # Process each photo
    for img_info in images:

        img = createImageFromGDriveObject(img_info, http)
        file_name = img_info['title']

        mylogger.info("Process %s" % file_name)

        # create image object
        try:
            dbimage = getImage(os.path.basename(file_name))
            dbimage.img = img
            dbimage.download_url = img_info["downloadUrl"]
            dbimage.img_link = img_info['webContentLink'].replace(
                '&export=download', '')
        except ValueError as e:
            print e
            continue

        # try to recognize image
        if dbimage.identifyDigits():
            mylogger.info("Result is %s" % dbimage.result)

        sess.commit()
if __name__ == '__main__':

    images, http = getImagesFromGDrive()
    
    # Process each photo
    for img_info in images:

        img = createImageFromGDriveObject (img_info, http)
        file_name = img_info['title']

        mylogger.info("Process %s" % file_name)

        # create image object     
        try:    
            dbimage = getImage(os.path.basename(file_name))
            dbimage.img = img
            dbimage.download_url = img_info["downloadUrl"]
            dbimage.img_link = img_info['webContentLink'].replace('&export=download','')
        except ValueError as e:
            print e
            continue
             
        # try to recognize image
        if dbimage.identifyDigits():
            mylogger.info("Result is %s" % dbimage.result)
        
        sess.commit()
    
    
Esempio n. 5
0
    def post(self):

        answer1 = self.request.get("template")
        answer2 = self.request.get("template2")
        answer3 = self.request.get("template3")
        answer4 = self.request.get("template4")
        answer5 = self.request.get("template5")

        answers_index = [
            looping_through("question1", answer1),
            looping_through("question2", answer2),
            looping_through("question3", answer3),
            looping_through("question4", answer4),
            looping_through("question5", answer5)
        ]
        list_colors = [0, 0, 0, 0]
        for index in answers_index:
            if (index == 0):
                list_colors[0] += 1
            elif (index == 1):
                list_colors[1] += 1
            elif (index == 2):
                list_colors[2] += 1
            else:
                list_colors[3] += 1
        max_value = 0
        if (list_colors.count(2) == 2):
            max_value = 2
        else:
            max_value = max(list_colors)

        user_color = ""

        if (list_colors.index(max_value) == 0):
            user_color = "Blue"
            color_interest = userInterests(
                hobbies=choosing_interests("blue_hobbies"),
                living_and_travel=choosing_interests("blue_living_and_travel"),
                education_and_careers=choosing_interests(
                    "blue_education_and_careers"),
                music=choosing_interests("blue_music"),
            )
        elif (list_colors.index(max_value) == 1):
            user_color = "Orange"
            color_interest = userInterests(
                hobbies=choosing_interests("orange_hobbies"),
                living_and_travel=choosing_interests(
                    "orange_living_and_travel"),
                education_and_careers=choosing_interests(
                    "orange_education_and_careers"),
                music=choosing_interests("orange_music"),
            )
        elif (list_colors.index(max_value) == 2):
            user_color = "Green"
            color_interest = userInterests(
                hobbies=choosing_interests("green_hobbies"),
                living_and_travel=choosing_interests(
                    "green_living_and_travel"),
                education_and_careers=choosing_interests(
                    "green_education_and_careers"),
                music=choosing_interests("green_music"),
            )
        elif (list_colors.index(max_value) == 3):
            user_color = "Gold"
            color_interest = userInterests(
                hobbies=choosing_interests("gold_hobbies"),
                living_and_travel=choosing_interests("gold_living_and_travel"),
                education_and_careers=choosing_interests(
                    "gold_education_and_careers"),
                music=choosing_interests("gold_music"),
            )

        user = users.get_current_user()
        email_address = user.nickname()
        color_interest.put()

        # user_array.put()
        currentUser = GoogleUser.query().filter(
            GoogleUser.email == email_address).get()
        currentUser.hasTakenTest = True
        currentUser.color = user_color
        currentUser.education_and_careers = color_interest.education_and_careers
        currentUser.hobbies = color_interest.hobbies
        currentUser.living_and_travel = color_interest.living_and_travel
        currentUser.music = color_interest.music

        currentUser.put()
        data = {
            "user_color":
            user_color,
            "user_hobbies":
            color_interest.hobbies,
            "user_living_and_travel":
            color_interest.living_and_travel,
            "user_education_and_careers":
            color_interest.education_and_careers,
            "user_music":
            color_interest.music,
            "colorImage":
            getImage(user_color),
            "hobbies_image":
            getImage(color_interest.hobbies),
            "living_and_travel_image":
            getImage(color_interest.living_and_travel),
            "education_and_careers_image":
            getImage(color_interest.education_and_careers),
            "music_image":
            getImage(color_interest.music),
            "connect_image":
            getImage("iphone")
            # "user_all_answers" : user_answers
        }

        results_template = jinja_env.get_template('pages/results.html')
        self.response.write(results_template.render(data))