Exemple #1
0
	def POST(self):
		""" receive beacon """
		user_data = web.input(uuid=None, ip=None)
		if user_data.uuid==None or user_data.ip == None:
			print("INCOMPLETE")
			return
		print("Received "+user_data.uuid+" at "+user_data.ip)  
		db.addEntry(user_data.uuid,user_data.ip)
 def POST(self):
     """ receive beacon """
     user_data = web.input(uuid=None, ip=None)
     if user_data.uuid==None or user_data.ip == None:
         print("INCOMPLETE")
         return
     print("Received "+user_data.uuid+" at "+user_data.ip)
     
     items = ('name', 'uri', 'mimetype')
     
     try:
         assets_url = urllib2.urlopen("http://%s/api/assets" % user_data.ip, timeout = 2)
     except urllib2.URLError as e:
         asset_array = []
     else:
         assets_data = json.loads(assets_url.read())
         asset_array = filter(None, [{name: asset_item[name] for name in items} if asset_item['is_active'] else None for asset_item in assets_data])
     db.addEntry(user_data.uuid,user_data.ip,json.dumps(asset_array))
Exemple #3
0
    def POST(self):
        """ receive beacon """
        user_data = web.input(uuid=None, ip=None)
        if user_data.uuid == None or user_data.ip == None:
            print("INCOMPLETE")
            return
        print("Received " + user_data.uuid + " at " + user_data.ip)

        items = ('name', 'uri', 'mimetype')

        try:
            assets_url = urllib2.urlopen("http://%s/api/assets" % user_data.ip,
                                         timeout=2)
        except urllib2.URLError as e:
            asset_array = []
        else:
            assets_data = json.loads(assets_url.read())
            asset_array = filter(
                None, [{name: asset_item[name]
                        for name in items} if asset_item['is_active'] else None
                       for asset_item in assets_data])
        db.addEntry(user_data.uuid, user_data.ip, json.dumps(asset_array))
Exemple #4
0
 def addEntry_popup(self):
     orderGroupBox = QGroupBox("Add An Entry")
     tablename = QComboBox()
     tablename.addItems(db.getTables())
     hid = QLineEdit()
     row = QLineEdit()
     col = QLineEdit()
     coord1x = QLineEdit()
     coord1y = QLineEdit()
     coord2x = QLineEdit()
     coord2y = QLineEdit()
     coord3x = QLineEdit()
     coord3y = QLineEdit()
     coord4x = QLineEdit()
     coord4y = QLineEdit()
     centx = QLineEdit()
     centy = QLineEdit()
     layout = QFormLayout()
     layout.addRow(QLabel("Table"), tablename)
     layout.addRow(QLabel("ID"), hid)
     layout.addRow(QLabel("row"), row)
     layout.addRow(QLabel("col"), col)
     layout.addRow(QLabel("coord1x"), coord1x)
     layout.addRow(QLabel("coord1y"), coord1y)
     layout.addRow(QLabel("coord2x"), coord2x)
     layout.addRow(QLabel("coord2y"), coord2y)
     layout.addRow(QLabel("coord3x"), coord3x)
     layout.addRow(QLabel("coord3y"), coord3y)
     layout.addRow(QLabel("coord4x"), coord4x)
     layout.addRow(QLabel("coord4y"), coord4y)
     layout.addRow(QLabel("centx"), centx)
     layout.addRow(QLabel("centy"), centy)
     orderGroupBox.setLayout(layout)
     orderButtonBox = QDialogButtonBox(QDialogButtonBox.Ok
                                       | QDialogButtonBox.Cancel)
     mainOrderLayout = QVBoxLayout()
     central_widget = QWidget()
     central_widget.setLayout(mainOrderLayout)
     mainOrderLayout.addWidget(orderGroupBox)
     mainOrderLayout.addWidget(orderButtonBox)
     self.setCentralWidget(central_widget)
     self.show()
     orderButtonBox.accepted.connect(
         lambda: db.addEntry(tablename.currentText(), hid.text(), row.text(
         ), col.text(), coord1x.text(), coord1y.text(), coord2x.text(
         ), coord2y.text(), coord3x.text(), coord3y.text(), coord4x.text(),
                             coord4y.text(), centx.text(), centy.text()))
     orderButtonBox.accepted.connect(self.close)
     orderButtonBox.rejected.connect(self.close)
Exemple #5
0
def displayEndGame(screen, clock, avatarNum, bCount, ourHUD):
    """
    Final end game screen, connects to SQL database hosted with AWS and displays recent games.
    """
    nameSwitch = {1: "Jason", 2: "Kunal", 3: "Wes", 4: "Heidi"} 
    db.addEntry(nameSwitch[avatarNum], ourHUD.getCreditScore(), ourHUD.getBalance(), ourHUD.getHapiness())

    while (True):
        if (bCount >= 0 and bCount < 10): 
            backgroundImg = pygame.image.load('Assets/background_image.png')
            screen.blit(backgroundImg, (0, 0))
        if (bCount >= 10 and bCount < 20):
            backgroundImg = pygame.image.load('Assets/background_image_1.png')
            screen.blit(backgroundImg, (0, 0))
        if (bCount >= 20 and bCount < 30):
            backgroundImg = pygame.image.load('Assets/background_image_2.png')
            screen.blit(backgroundImg, (0, 0))

        grayBG = pygame.Surface((600, 400))
        grayBG.set_alpha(128)
        grayBG.fill((105, 105, 105))
        screen.blit(grayBG, (100, 125))

        leaders = db.getEntries()
        numSwitch = {"Jason" : 1, "Kunal" : 2, "Wes" : 3, "Heidi" : 4} 
        person1 = pygame.image.load('Assets/person' + str(numSwitch[leaders[0]['name']]) +'.png')
        person2 = pygame.image.load('Assets/person' + str(numSwitch[leaders[1]['name']]) +'.png')
        person3 = pygame.image.load('Assets/person' + str(numSwitch[leaders[2]['name']]) +'.png')

        screen.blit(person1, (175, 150))
        screen.blit(person2, (175, 275))
        screen.blit(person3, (175, 400))

        fontTitlerecent = pygame.font.Font("Assets/Minecraft.ttf", 48)
        textTitlerecent = fontTitlerecent.render("Recent Games", True, (0, 0, 0))
        screen.blit(textTitlerecent, (225, 75))

        fontTitle1name = pygame.font.Font("Assets/Minecraft.ttf", 32)
        textTitle1name = fontTitle1name.render(leaders[0]['name'], True, (0, 0, 0))
        screen.blit(textTitle1name, (325, 175))

        fontTitle1 = pygame.font.Font("Assets/Minecraft.ttf", 32)
        textTitle1 = fontTitle1.render("$ %s" % leaders[0]['balance'], True, (0, 0, 0))
        screen.blit(textTitle1, (500, 175))

        fontTitle2name = pygame.font.Font("Assets/Minecraft.ttf", 32)
        textTitle2name = fontTitle2name.render(leaders[1]['name'], True, (0, 0, 0))
        screen.blit(textTitle2name, (325, 300))

        fontTitle2 = pygame.font.Font("Assets/Minecraft.ttf", 32)
        textTitle2 = fontTitle2.render("$ %s" % leaders[1]['balance'], True, (0, 0, 0))
        screen.blit(textTitle2, (500, 300))

        fontTitle3name = pygame.font.Font("Assets/Minecraft.ttf", 32)
        textTitle3name = fontTitle3name.render(leaders[2]['name'], True, (0, 0, 0))
        screen.blit(textTitle3name, (325, 425))

        fontTitle3 = pygame.font.Font("Assets/Minecraft.ttf", 32)
        textTitle3 = fontTitle3.render("$ %s" % leaders[2]['balance'], True, (0, 0, 0))
        screen.blit(textTitle3, (500, 425))

        bCount = bCount + 1
        if (bCount == 30):
            bCount = 0
        time_passed = clock.tick(50)
        for event in pygame.event.get():
            if (event.type == pygame.QUIT):
                return False
        pygame.display.update()
Exemple #6
0
def create():
     title = request.args['entryTitle']
     entry = request.args['entryText']

     db.addEntry(session['user'],title,entry)
     return redirect('/')
Exemple #7
0
def handleEntryRequest():
    if request.method=='GET':
        return json.dumps(db.getEntries())
    else:
        return `db.addEntry(request.json['name'])`