Exemplo n.º 1
0
def fun():
    global a
    ids = m1.get()
    passw = m2.get()

    if b.execute("select * from emp where id={} and pass='******'".format(
            ids, passw)):
        Label(a, text="Access Granted..").grid(row=6, column=1)

        res = b.fetchall()
        for row in res:
            ename = row[0]
            eid = row[1]
            epass = row[2]
            erole = row[3]
            ebal = row[4]
        if (erole == 'user'):
            a.withdraw()
            user(eid, epass, a)
        elif (erole == 'admin'):
            a.withdraw()
            admin(eid, epass, a)
        elif (erole == 'librarian'):
            a.withdraw()
            librarian(eid, epass, a)
    else:
        Label(a, text="Wrong Details!!! Try Again...").grid(row=6, column=2)
    x = datetime.datetime.now()
    x = str(x)
    x = x.split()
    b.execute(
        "delete from transdata where date1 < DATE_SUB('{}',INTERVAL 6 MONTH)".
        format(x[0]))
    a1.commit()
    a1.close()
Exemplo n.º 2
0
def runUntilItWorks(cmd, tries, errorString):
    myTries = 0
    while myTries <= tries:
        status, output = runcmd(cmd,0)
        if output == "error":
            myTries += 1
        else:
            return output
    user(errorString)
    return "error"
Exemplo n.º 3
0
 def testEmptyTableFalse(self):
     # Creamos el backlog
     _backlog = backlog()
     _backlog.insertBacklog('Backlog', 'Prueba', 2)
     findId = _backlog.findName('Backlog')
     idBacklog = findId[0].BL_idBacklog
     # Creamos el actor
     actor = role()
     actor.insertActor('Actor', 'Descripcion', idBacklog)
     result = actor.findNameActor('Actor', idBacklog)
     idActor = result[0].A_idActor
     # Creamos el usuario
     _user = user()
     _user.insertUser('fullname', 'userr', 'password1234',
                      '*****@*****.**', idActor)
     # Agregamos un usuario a team
     team_object = team()
     team_object.insertMiembro('userr', 'Actor', idBacklog)
     # Ejecutamos la funcion
     result = team_object.emptyTable()
     self.assertFalse(result)
     # Eliminamos los datos insertados
     team_object.deleteMiembro('userr', 'Actor', idBacklog)
     _user.deleteUser('userr')
     actor.deleteActor('Actor', idBacklog)
     _backlog.deleteProduct('Backlog')
Exemplo n.º 4
0
 def testgetTeam(self):
     # Creamos el backlog
     _backlog  = backlog()
     _backlog.insertBacklog('Backlog','Prueba',2)
     findId    = _backlog.findName('Backlog')
     idBacklog = findId[0].BL_idBacklog 
     # Creamos el actor 1
     actor = role()
     actor.insertActor('Actor1','Descripcion',idBacklog)
     result    = actor.findNameActor('Actor1',idBacklog)
     idActor   = result[0].A_idActor
     # Creamos el actor 2
     actor.insertActor('Actor2','Descripcion',idBacklog)
     result    = actor.findNameActor('Actor2',idBacklog)
     idActor   = result[0].A_idActor
     # Creamos el usuario 1
     _user = user()
     _user.insertUser('fullname','user1','password1234','*****@*****.**',idActor)
     # Creamos el usuario
     _user.insertUser('fullname','user2','password1232','*****@*****.**',idActor)
     # Ejecutamos la funcion
     team_object = team()
     team_object.insertMiembro('user1','Actor1',idBacklog)  
     team_object.insertMiembro('user2','Actor2',idBacklog)  
     team_object.getTeam(idBacklog)
     # Eliminamos los datos insertados
     team_object.deleteMiembro('user1','Actor1',idBacklog)
     _user.deleteUser('user1')
     actor.deleteActor('Actor1',idBacklog)
     team_object.deleteMiembro('user2','Actor2',idBacklog)
     _user.deleteUser('user2')
     actor.deleteActor('Actor2',idBacklog)
     _backlog.deleteProduct('Backlog')
Exemplo n.º 5
0
 def testEmptyTableFalse(self):
     # Creamos el backlog
     _backlog  = backlog()
     _backlog.insertBacklog('Backlog','Prueba',2)
     findId    = _backlog.findName('Backlog')
     idBacklog = findId[0].BL_idBacklog 
     # Creamos el actor
     actor = role()
     actor.insertActor('Actor','Descripcion',idBacklog)
     result    = actor.findNameActor('Actor',idBacklog)
     idActor   = result[0].A_idActor
     # Creamos el usuario
     _user = user()
     _user.insertUser('fullname','userr','password1234','*****@*****.**',idActor)
     # Agregamos un usuario a team
     team_object = team()
     team_object.insertMiembro('userr','Actor',idBacklog)
     # Ejecutamos la funcion
     result = team_object.emptyTable()
     self.assertFalse(result)
     # Eliminamos los datos insertados
     team_object.deleteMiembro('userr','Actor',idBacklog)
     _user.deleteUser('userr')
     actor.deleteActor('Actor',idBacklog)
     _backlog.deleteProduct('Backlog')
Exemplo n.º 6
0
  def testupdatePathologicalBackgroundOtherNotMaxLen(self):
  	user_controller = user()
  	pb_controller = pathologicalBackground()

  	user_controller.insertUser(12345678,'doctortest','pass','name','last','*****@*****.**',1)
  	pb_controller.insertPathologicalBackground(12345678,'current_condition','surgical_history',
						'transfusional_history','allergies','traumatic_history','hospitalizations','addictions','other')
  	result = pb_controller.updatePathologicalBackground(12345678,'current_condition2','surgical_history2',
						'transfusional_history2','allergies2','traumatic_history2','hospitalizations2','addictions2','other'+
						'otherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherother'+
						'otherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherother'+
						'otherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherother'+
						'otherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherother'+
						'otherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherother'+
						'otherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherother'+
						'otherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherother'+
						'otherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherother'+
						'otherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherother'+
						'otherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherother'+
						'otherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherother'+
						'otherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherother'+
						'otherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherother'+
						'otherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherother'+
						'otherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherother'+
						'otherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherotherother')
  	pb_controller.deletePathologicalBackground(12345678)
  	user_controller.deleteUser('doctortest')
  	self.assertFalse(result)
Exemplo n.º 7
0
	def testDeleteUser(self):
		user_controller = user()
		role_controller = role()
		role_controller.createRole('rol')
		user_controller.insertUser(12345678,'user','pass','name','last','*****@*****.**','rol')
		user_controller.deleteUser('user')
		role_controller.deleteRole(5)
def register():
    """Register"""
    if email_address_match(request.get_json()['email_address'], mycursor,
                           'table1', db):
        return jsonify('This email address is already used')
    if user_match(request.get_json()['username'], mycursor, 'table1', db):
        return jsonify('This username is already used')
    else:
        mycursor.execute(
            "INSERT INTO table1(username, password, email_address) VALUES(%s,%s,%s)",
            (request.get_json()['username'], request.get_json()['password'],
             request.get_json()['email_address']))
        db.commit()

        current_user = user(request.get_json()['email_address'],
                            request.get_json()['username'],
                            request.get_json()['password'])
        current_user.get_authorization(mycursor, 'table1', db)
        store_current_user.append(current_user)
        log(store_current_user, 'register', mycursor, 'log', db)

        msg = Message('Registration',
                      sender='*****@*****.**',
                      recipients=[current_user.email_address])
        msg.body = (
            f"Hello {current_user.username},\n\nYour account was successfully created!\n\nAPI team"
        )
        mail.send(msg)

        return jsonify('Successfully registered')
 def testEmptyTableFalse(self):
     # Creamos el backlog
     _backlog  = backlog()
     _backlog.insertBacklog('Backlog','Prueba',2)
     findId    = _backlog.findName('Backlog')
     idBacklog = findId[0].BL_idBacklog 
     # Creamos el actor
     actor = role()
     actor.insertActor('Actor','Descripcion',idBacklog)
     result    = actor.findNameActor('Actor',idBacklog)
     idActor   = result[0].A_idActor
     # Creamos el usuario
     _user = user()
     _user.insertUser('fullname','userr','password1234','*****@*****.**',idActor)
     # Creamos el sprint
     aSprint      = sprints()
     aSprint.insertSprint(1,'Descripcion sprint',idBacklog, TODAY, TOMORROW, STATES[1])
     # Agregamos un usuario a team
     team_object = team()
     team_object.insertMiembro('userr','Actor',idBacklog)
     # Creamos el subEquipo
     subequipo_object = subEquipoClass()
     # Agregamos el usuario al subEquipo
     subequipo_object.insertMiembroSubEquipo('userr','Actor')
     # Ejecutamos la funcion
     result = subequipo_object.emptyTable()
     self.assertTrue(result)
Exemplo n.º 10
0
 def testgetTeam(self):
     # Creamos el backlog
     _backlog = backlog()
     _backlog.insertBacklog('Backlog', 'Prueba', 2)
     findId = _backlog.findName('Backlog')
     idBacklog = findId[0].BL_idBacklog
     # Creamos el actor 1
     actor = role()
     actor.insertActor('Actor1', 'Descripcion', idBacklog)
     result = actor.findNameActor('Actor1', idBacklog)
     idActor = result[0].A_idActor
     # Creamos el actor 2
     actor.insertActor('Actor2', 'Descripcion', idBacklog)
     result = actor.findNameActor('Actor2', idBacklog)
     idActor = result[0].A_idActor
     # Creamos el usuario 1
     _user = user()
     _user.insertUser('fullname', 'user1', 'password1234',
                      '*****@*****.**', idActor)
     # Creamos el usuario
     _user.insertUser('fullname', 'user2', 'password1232',
                      '*****@*****.**', idActor)
     # Ejecutamos la funcion
     team_object = team()
     team_object.insertMiembro('user1', 'Actor1', idBacklog)
     team_object.insertMiembro('user2', 'Actor2', idBacklog)
     team_object.getTeam(idBacklog)
     # Eliminamos los datos insertados
     team_object.deleteMiembro('user1', 'Actor1', idBacklog)
     _user.deleteUser('user1')
     actor.deleteActor('Actor1', idBacklog)
     team_object.deleteMiembro('user2', 'Actor2', idBacklog)
     _user.deleteUser('user2')
     actor.deleteActor('Actor2', idBacklog)
     _backlog.deleteProduct('Backlog')
Exemplo n.º 11
0
	def testInsertPasswordNotStr(self):
		user_controller = user()
		role_controller = role()
		role_controller.createRole('rol')
		result = user_controller.insertUser(666666,'user',1,'name','last','*****@*****.**','rol')
		user_controller.deleteUser('user')
		role_controller.deleteRole(5)
		self.assertFalse(result['result'])
Exemplo n.º 12
0
	def testInsertUserTrue(self):
		user_controller = user()
		role_controller = role()
		role_controller.createRole('rol')
		result = user_controller.insertUser(12345678,'user','pass','name','last','*****@*****.**','rol')
		user_controller.deleteUser('user')
		role_controller.deleteRole(5)
		self.assertTrue(result['result'])
Exemplo n.º 13
0
	def testInsertCItooLong(self):
		user_controller = user()
		role_controller = role()
		role_controller.createRole('rol')
		result = user_controller.insertUser(1000000000,'user','pass','name','last','*****@*****.**','rol')
		user_controller.deleteUser('user')
		role_controller.deleteRole(5)
		self.assertFalse(result['result'])
Exemplo n.º 14
0
	def testInsertUsernameTooLong(self):
		user_controller = user()
		role_controller = role()
		role_controller.createRole('rol')
		result = user_controller.insertUser(666666,'ImtoodamnlongImtoodamnlongImtoodammlongImtoodamnlong','pass','name','last','*****@*****.**','rol')
		user_controller.deleteUser('user')
		role_controller.deleteRole(5)
		self.assertFalse(result['result'])
Exemplo n.º 15
0
	def testInsertUsernameNull(self):
		user_controller = user()
		role_controller = role()
		role_controller.createRole('rol')
		result = user_controller.insertUser(666666,None,'pass','name','last','*****@*****.**','rol')
		user_controller.deleteUser('user')
		role_controller.deleteRole(5)
		self.assertFalse(result['result'])
Exemplo n.º 16
0
	def testInsertLastNameNoLenght(self):
		user_controller = user()
		role_controller = role()
		role_controller.createRole('rol')
		result = user_controller.insertUser(666666,'user','pass','name','','*****@*****.**','rol')
		user_controller.deleteUser('user')
		role_controller.deleteRole(5)
		self.assertFalse(result['result'])
Exemplo n.º 17
0
def set_user(cur_id):
    '''
    Добавляем нового пользователя
    :param cur_id: id пользователя
    '''
    if cur_id in requests_dict.keys():
        return
    else:
        requests_dict[cur_id] = user(cur_id)
Exemplo n.º 18
0
	def testExistUserCiTrue(self): #exists
		user_controller = user()
		role_controller = role()
		role_controller.createRole('rol')
		user_controller.insertUser(12345678,'user','pass','name','last','*****@*****.**','rol')
		result = user_controller.existUserCi(12345678)
		user_controller.deleteUser('user')
		role_controller.deleteRole(5)
		self.assertTrue(result)
Exemplo n.º 19
0
	def testInsertUsernameAlreadyExists(self):
		user_controller = user()
		role_controller = role()
		role_controller.createRole('rol')
		user_controller.insertUser(666666,'user','pass','name','last','*****@*****.**','rol')
		result = user_controller.insertUser(6666666,'user','pass2','name2','last2','*****@*****.**','rol')
		user_controller.deleteUser('user')
		role_controller.deleteRole(5)
		self.assertFalse(result['result'])
Exemplo n.º 20
0
	def testExistUserCiNotValidArgument(self):
		user_controller = user()
		role_controller = role()
		role_controller.createRole('rol')
		user_controller.insertUser(12345678,'user','pass','name','last','*****@*****.**','rol')
		result = user_controller.existUser('12345678')
		user_controller.deleteUser('user')
		role_controller.deleteRole(5)
		self.assertFalse(result)
Exemplo n.º 21
0
	def testGetUserFalse(self): #dont exists return empty list
		user_controller = user()
		role_controller = role()
		role_controller.createRole('rol')
		user_controller.insertUser(12345678,'user','pass','name','last','*****@*****.**','rol')
		result = user_controller.getUserByCi(666666)
		user_controller.deleteUser('user')
		role_controller.deleteRole(5)
		self.assertEqual(result,[])
Exemplo n.º 22
0
def get_user(request):
    if request.method == 'GET':
        users = user.objects.all()
        serializer = UserSerializer(users, many=True)
        return Response(serializer.data)
    elif request.method == 'POST':
        user = user(uin=request.POST.get('uin'))
        serializer = UserSerializer(user)
        return Response(serializer.data)
Exemplo n.º 23
0
def create_user(request):
    if request.method == 'POST':
        user = user(uin=request.POST.get('uin'),
                name=request.POST.get('name'),
                headurl=request.POST.get('headurl'),
                sex=request.POST.get('sex'))
        user.save()
        serializer = UserSerializer(user)
        return Response(serializer.data)
Exemplo n.º 24
0
	def testDeleteNPBNotExists(self):
		user_controller = user()
		npb_controller = nonPathologicalBackground()

		user_controller.insertUser(12345678,'doctortest','pass','name','last','*****@*****.**',1)
		result = npb_controller.deleteNonPathologicalBackground(12345678)

		self.assertFalse(result)
		user_controller.deleteUser('doctortest')
Exemplo n.º 25
0
	def testInsertNPBBoolCI(self):
		user_controller = user()
		npb_controller = nonPathologicalBackground()

		user_controller.insertUser(12345678,'doctortest','pass','name','last','*****@*****.**',1)
		result = npb_controller.insertNonPathologicalBackground(False,'test','test','test','test','test','test','test','test','test')
		
		self.assertFalse(result)
		user_controller.deleteUser('doctortest')
Exemplo n.º 26
0
	def testDeleteUserFalse(self): #dont exists dont delete
		user_controller = user()
		role_controller = role()
		role_controller.createRole('rol')
		user_controller.insertUser(12345678,'user','pass','name','last','*****@*****.**','rol')
		result = user_controller.deleteUser('user666')
		user_controller.deleteUser('user')
		role_controller.deleteRole(5)
		self.assertFalse(result)
Exemplo n.º 27
0
	def testGetUserCiTrue(self): #exists get it
		user_controller = user()
		role_controller = role()
		role_controller.createRole('rol')
		user_controller.insertUser(12345678,'user','pass','name','last','*****@*****.**','rol')
		result = user_controller.getUserByCi(12345678)
		user_controller.deleteUser('user')
		role_controller.deleteRole(5)
		self.assertEqual(result.username,'user')
Exemplo n.º 28
0
	def testInsertCIalredyExists(self):
		user_controller = user()
		role_controller = role()
		role_controller.createRole('rol')
		user_controller.insertUser(666666,'user1','pass1','name1','last1','*****@*****.**','rol')
		result = user_controller.insertUser(666666,'user2','pass2','name2','last2','*****@*****.**','rol')
		user_controller.deleteUser('user1')
		user_controller.deleteUser('user2')
		role_controller.deleteRole(5)
		self.assertFalse(result['result'])
Exemplo n.º 29
0
	def nameUser (self) :
		print ("Enter name:")
		name = input(">>> ")
		print ("X or O?")
		symbol = input(">>> ")
		while ((symbol != "X") and (symbol != "O") ) :
			print ("X or O?")
			symbol = input(">>> ")
		
		self._user = user (name, symbol, 0, 0, 0)
Exemplo n.º 30
0
	def testInsertAppointment(self):
		user_controller = user()
		fecha = date(2016,7,1)
		appointment_controller = appointment()
		user_controller.insertUser(12345678,'doctortest','pass','name','last','*****@*****.**',1)
		user_controller.insertUser(66666666,'pacientetest','pass','name','last','*****@*****.**',2)
		appointment_controller.insertAppointment(66666666,12345678,fecha,'descripcion')
		user_controller.deleteUser('doctortest')
		user_controller.deleteUser('pacientetest')
		appointment_controller.deleteAppointment(2)
Exemplo n.º 31
0
	def testUpdateFBAllNone(self):
		user_controller = user()
		family_background_controller = familyBackground()
		
		user_controller.insertUser(12345678,'doctortest','pass','name','last','*****@*****.**',1)
		result = family_background_controller.insertFamilyBackground(12345678, None, None, None, None, None, None, 'test')

		self.assertTrue(result)
		user_controller.deleteUser('doctortest')
		family_background_controller.deleteFamilyBackground(12345678)
Exemplo n.º 32
0
	def testInsertFBZeroCI(self):
		user_controller = user()
		family_background_controller = familyBackground()
		
		user_controller.insertUser(12345678,'doctortest','pass','name','last','*****@*****.**',1)
		result = family_background_controller.insertFamilyBackground(0, True, False, True, False, True, False, 'test')

		self.assertFalse(result)
		user_controller.deleteUser('doctortest')
		family_background_controller.deleteFamilyBackground(12345678)
Exemplo n.º 33
0
	def testInsertAppointmentNotValidDate(self):
		user_controller = user()
		fecha = date(2016,7,1)
		appointment_controller = appointment()
		user_controller.insertUser(12345678,'doctortest','pass','name','last','*****@*****.**',1)
		user_controller.insertUser(66666666,'pacientetest','pass','name','last','*****@*****.**',2)
		result = appointment_controller.insertAppointment(66666666,12345678,'2016-08-01','descripcion')
		user_controller.deleteUser('doctortest')
		user_controller.deleteUser('pacientetest')
		appointment_controller.deleteAppointment(2)
		self.assertFalse(result)
Exemplo n.º 34
0
	def testUpdateFBFloatOther(self):
		user_controller = user()
		family_background_controller = familyBackground()
		
		user_controller.insertUser(12345678,'doctortest','pass','name','last','*****@*****.**',1)
		family_background_controller.insertFamilyBackground(12345678, True, False, True, False, True, False, 'test')
		result = family_background_controller.updateFamilyBackground(12345678, True, False, True, False, True, False, 1.2)

		self.assertFalse(result)
		user_controller.deleteUser('doctortest')
		family_background_controller.deleteFamilyBackground(12345678)
Exemplo n.º 35
0
	def testUpdateUserPasswordTooLong(self):
		user_controller = user()
		role_controller = role()
		role_controller.createRole('rol1')
		role_controller.createRole('rol2')
		user_controller.insertUser(12345678,'user','pass','name','last','*****@*****.**','rol1')
		result = user_controller.updateUser('user','Imtoodamnloooooong','name','last','*****@*****.**','rol1')
		user_controller.deleteUser('user')
		role_controller.deleteRole(5)
		role_controller.deleteRole(6)
		self.assertFalse(result['result'])
Exemplo n.º 36
0
	def testUpdateUserLastNameNull(self):
		user_controller = user()
		role_controller = role()
		role_controller.createRole('rol1')
		role_controller.createRole('rol2')
		user_controller.insertUser(12345678,'user','pass','name','last','*****@*****.**','rol1')
		result = user_controller.updateUser('user','pass','name',None,'*****@*****.**','rol1')
		user_controller.deleteUser('user')
		role_controller.deleteRole(5)
		role_controller.deleteRole(6)
		self.assertFalse(result['result'])
Exemplo n.º 37
0
 def testActualizar(self):
     # Creamos el backlog
     _backlog = backlog()
     _backlog.insertBacklog('Backlog', 'Prueba', 2)
     findId = _backlog.findName('Backlog')
     idBacklog = findId[0].BL_idBacklog
     # Creamos el actor 1
     actor = role()
     actor.insertActor('Actor1', 'Desarrollador', idBacklog)
     result = actor.findNameActor('Actor1', idBacklog)
     idActor = result[0].A_idActor
     # Creamos el actor 2
     actor.insertActor('Actor2', 'Desarrollador', idBacklog)
     result = actor.findNameActor('Actor2', idBacklog)
     idActor = result[0].A_idActor
     # Creamos el actor 3
     actor.insertActor('Actor3', 'Scrum master', idBacklog)
     result = actor.findNameActor('Actor3', idBacklog)
     idActor = result[0].A_idActor
     # Creamos el usuario 1
     _user = user()
     _user.insertUser('fullname', 'user1', 'password1234',
                      '*****@*****.**', idActor)
     # Creamos el usuario 2
     _user.insertUser('fullname', 'user2', 'password1232',
                      '*****@*****.**', idActor)
     # Creamos el usuario 3
     _user.insertUser('fullname', 'user3', 'password1233',
                      '*****@*****.**', idActor)
     # Agregamos los usuarios al equipo
     team_object = team()
     team_object.insertMiembro('user1', 'Desarrollador', idBacklog)
     team_object.insertMiembro('user2', 'Desarrollador', idBacklog)
     # Obtenemos los miembros del equipo
     teamList = team_object.getTeam(idBacklog)
     userList = _user.getAllUsers()
     # Creamos la lista
     lista = [{
         'miembro': team.EQ_username,
         'rol': team.EQ_rol
     } for team in teamList]
     team_object.insertMiembro('user3', 'Scrum master', idBacklog)
     team_object.actualizar(lista, idBacklog)
     # Eliminamos los datos insertados
     team_object.deleteMiembro('user1', 'Actor1', idBacklog)
     _user.deleteUser('user1')
     actor.deleteActor('Actor1', idBacklog)
     team_object.deleteMiembro('user2', 'Actor2', idBacklog)
     _user.deleteUser('user2')
     actor.deleteActor('Actor2', idBacklog)
     team_object.deleteMiembro('user3', 'Actor3', idBacklog)
     _user.deleteUser('user3')
     actor.deleteActor('Actor3', idBacklog)
     _backlog.deleteProduct('Backlog')
Exemplo n.º 38
0
	def testUpdateNPBBoolOther(self):
		user_controller = user()
		npb_controller = nonPathologicalBackground()

		user_controller.insertUser(12345678,'doctortest','pass','name','last','*****@*****.**',1)
		npb_controller.updateNonPathologicalBackground(12345678,'test','test','test','test','test','test','test','test','test')
		result = npb_controller.updateNonPathologicalBackground(12345678,'test','test','test','test','test','test','test','test',False)

		self.assertFalse(result)
		npb_controller.deleteNonPathologicalBackground(12345678)
		user_controller.deleteUser('doctortest')
Exemplo n.º 39
0
    def get_user(self, name, create_new=False):
        for my_user in self.users:
            if my_user.name == name:
                return my_user

        if create_new == True:
            my_user = user(name)
            self.add_user(my_user)
            return my_user
        else:
            return None
Exemplo n.º 40
0
    def nameUser(self):
        """
		asks the user for there name and a valid symbol
		"""
        print("Enter name:")
        name = input(">>> ")
        print("X or O?")
        symbol = input(">>> ")
        while ((symbol != "X") and (symbol != "O")):
            print("X or O?")
            symbol = input(">>> ")

        self._user = user(name, symbol, 0, 0, 0)
Exemplo n.º 41
0
def fetch_user() -> user:
    generate_user = requests.get('https://randomuser.me/api/')

    if generate_user.status_code == 200:
        data = generate_user.json()
        random_fullname = data['results'][0]['name']['first'] + \
            ' ' + data['results'][0]['name']['last']
        random_email = data['results'][0]['email']
        random_password = password_generator.generate_password(random.randint(6, 12), random.randint(1, 4))
        new_user = user(random_fullname, random_email, random_password)
        return new_user
    else:
        print(generate_user.status_code + '-Error')
Exemplo n.º 42
0
 def query_one_user(self, username):
     sql = "select * from user where username = '******'" % (username)
     user_list = []  #用户对象的列表
     # 执行查询
     result = self.db_helper.do_query(sql)
     if not result:
         print("查询结果为空")
         return None
     for row in result:
         username = row[0]
         userpw = row[1]
         user_list.append(user(username, userpw))
     return user_list
Exemplo n.º 43
0
 def query_all_user(self):
     sql = 'select * from user'
     user_list = []  #用户对象的列表
     # 执行查询
     result = self.db_helper.do_query(sql)
     if not result:
         print("查询结果为空")
         return None
     for row in result:
         username = row[0]
         userpw = row[1]
         user_list.append(user(username, userpw))
     return user_list
Exemplo n.º 44
0
 def check_login(self):
     usr = self.le_usr.text()
     pwd = self.le_pwd.text()
     query = "SELECT user, password FROM labs.userlab WHERE user ='******' AND password = '******';" % (
         usr, pwd)
     data = "SELECT user, usertype, email FROM labs.userlab WHERE user ='******';" % (
         usr)
     if self.bbdd.run_query(query):
         self.user = user(self.bbdd.run_query(data))
         self.control = controller_login(self.user)
         self.close()
     else:
         self.label_error.setText(
             '<html><head/><body><p align="center"><span style=" font-weight:600; color:#ff0000;">Contraseña o usuario incorrecto!</span></p></body></html>'
         )
Exemplo n.º 45
0
def query_and_insert_user(userid, zonepy):
    session = DBSession()
    if (len(
            session.query(User).filter(User.userId == userid, User.zonepy
                                       == zonepy).all()) != 0):
        session.close()
        return False
    else:
        new_user = user(userid=userid, zonepy=zonepy)
        try:
            new_user.update_detail_info()
        except:
            return False
        insert_user(new_user)
        session.close()
        return True
Exemplo n.º 46
0
 def addUser(self, name, country, cpu, ip, lan=False):
     if name != "":
     
         #does this user already exist? if so, do not add it again!
         for x in self.userList:
             if x.name == name:
                 x.country = country
                 x.cpu = cpu
                 x.ip = ip
                 x.lan = lan
                 return True
                 
         self.userList.append(user(self.parent_window, self, name, country, cpu, ip, lan))
         return True
     else:
         return False
Exemplo n.º 47
0
def recieve_mes(message):
    if not users.keys().__contains__(message.chat.id):
        users[message.chat.id] = user(message.text)
    if message.text == "/help":
        bot.send_message(
            message.chat.id,
            "Я ищу товары по разным магазинам, просто напиши мне название товара и его его найду",
            reply_markup=prepare_reply_keyboard())
    elif message.text == "/start":
        bot.send_message(
            message.chat.id,
            "Я ищу товары по разным магазинам, просто напиши мне название товара и его его найду",
            reply_markup=prepare_reply_keyboard())
    else:
        users[message.chat.id] = message.text
        bot.send_message(message.chat.id,
                         "Вот где я могу поискать нужный вам товар",
                         reply_markup=prepare_keyboard())
def login():
    """Login"""
    if store_current_user.__len__() > 0:
        return jsonify('You are already logged in')

    if row_from_table('IP',
                      get('https://api.ipify.org').text, mycursor,
                      'banned_ip_addresses', db):
        return jsonify('This IP is banned')
    else:
        if match(request.get_json()['username'],
                 request.get_json()['password'], mycursor, 'table1', db):
            current_user = user(request.get_json()['username'],
                                request.get_json()['password'])
            current_user.get_authorization(mycursor, 'table1', db)
            store_current_user.append(current_user)
            log(store_current_user, 'login', mycursor, 'log', db)
            return {
                "Successfully logged in": current_user.username,
                "Your authorization is:": current_user.authorization
            }
        else:
            return jsonify('Username or password doesn\'t match')
Exemplo n.º 49
0
    def search(email):

        conn = userdao.connection()
        cursor = conn.cursor()
        u = user()
        print conn
        print cursor
        sql = "select * from std where email='%s'" % (email)
        cursor.execute(sql)
        result = cursor.fetchall()
        if (len(result) > 0):
            print "row insert successfully"
            print "------------------------------------------------------------------------------------"
            print "| Id   |\tName\t|\tAge\t|\tEmail\t\t\t\t   |"
            print "------------------------------------------------------------------------------------"
            for col in result:
                id = "%s" % col[0]
                name = "%s" % col[1]
                age = "%s" % col[2]
                email = "%s" % col[3]
                u.id = id
                u.name = name
                u.age = age
                u.email = email
                print "|", " ", id, " " * (
                    2 - len(id)), "|", "  ", name, " " * (
                        15 - len(name)), "|", "  ", age, " " * (
                            9 - len(age)), "|", "  ", email, " " * (
                                30 - len(email)), "|"
                # print "\t%d\t|\t%s\t\t|\t%s\t|\t%s\t\t|"%(id,name,age,email)
                print "------------------------------------------------------------------------------------"

        else:
            print "Please Enter Valid details"
        conn.close()
        return u
Exemplo n.º 50
0
def getUsers():
    try:
        conn = pyodbc.connect(
            'DRIVER={SQL Server};SERVER=kapydatabase.database.windows.net,1433',
            user='******',
            password='******',
            database='kapymvc1')
        cursor = conn.cursor()
        sql1 = "SELECT Id, Email FROM dbo.AspNetUsers WHERE emailConfirmed =1"
        try:
            users = []
            cursor.execute(sql1)
            for row in cursor.fetchall():
                users.append(user(row[0], row[1]))
                print row[0]
                print row[1]
            print 'success get users'
            return users
        except:
            conn.rollback()
            print "failed get data"

    except:
        print "connection failed"
Exemplo n.º 51
0
def create_user():
    args = request.form
    if not ("who" in args.keys()): return form_create_user()

    who = args["who"]  #[args[zw] for zw in ["who"]]

    who = who.strip()

    try:
        u = load_user(who)
        return with_go_back(f"The user {who} already exists")
    except:
        pass

    u = user(who)
    mn = gen_mnemonic()

    _, _, key = gen_keys(mn)
    u.key = key.hex()
    u.save()

    return with_go_back(
        f"Created the user {who}.<br>Your mnemonic is<br><p>{mn}</p><br>About mnemonics: This combination of words is more secure and easier to remember than most passwords and not stored on our servers (if you can trust the host that is). This means that we absolutely cannot recover lost mnemonics and every transaction has to be signed with this mnemonic. So please store it somewhere you can be sure you wont loose it.<br>On the other hand, everybody who has the mnemonic can trade your mnemonic, so also make sure, nobody sees this mnemonic. The best way of storing a mnemonic is: Write it on a piece of paper and stick it into a save. <br><br>For more advanced users: You can use the same mnemonic to do (most) blockchain stuff"
    )
Exemplo n.º 52
0
 def adduser(self, user_name):
     u = user(user_name, len(self.user) + 1)
     self.user.append(u)
Exemplo n.º 53
0
 def uQ(self):
     user()
Exemplo n.º 54
0
	def setUp (self) :
		""" setup for the tests to run"""
		self.user = user("Bob", "X", 1, 1, 1)
		self.board = Board()
		self.point = Point(1,2)
import pickle
from student import *
from teacher import *
from book import *
from user import *
import datetime
import numpy as np

student_list = []
teacher_list = []
book_list = []
u = user()


def search():
    load_book()
    with open("Booklist.pkl", "rb") as f:
        sbin = int(input("Enter SBIN No."))
        while True:
            try:
                obj = pickle.load(f)
                for book in obj:
                    if book.sbin == sbin:
                        print("*" * 50)
                        print("Book Available ", book.title)
                        print("No. of copies are ", book.copies)
                else:
                    print("Book not found")
            except EOFError:
                print("Search is completed")
                break
Exemplo n.º 56
0
import sys
from user import *

who = input("Who do you want to add?\n")
id = input("Please enter the corresponding id\n")

u = user(who, id)

print(u)

while input("Is this ok?, enter 'y' to save,strg+c to cancel") != "y":
    pass

u.save()
Exemplo n.º 57
0
import sys
from user import *

from gen_mnemonic import gen_mnemonic
from gen_keys import gen_keys

who = input("Who do you want to add?\n")
#id=input("Please enter the corresponding id\n")

u = user(who)

print(u)

while input(
        "Is this ok?, enter 'y' to continue generating keys,strg+c to cancel"
) != "y":
    pass

mn = gen_mnemonic()
print(
    "I generated your mnemonic. Remember it, it is not recoverable and you need it to sign all your transactions!"
)
print("The mnemonic is:")
print("")
print(mn)
print("")

_, _, key = gen_keys(mn)

u.key = key.hex()
Exemplo n.º 58
0
 def fire2(self):
     user()
Exemplo n.º 59
0
from sync_database import *
from admin import *
from user import *


if __name__ == '__main__':
    sync_from_user()
    sync_from_main()
    sync_from_age()
    while True:
        print("\n\n******* WELCOME ********\n1.USER\n2.ADMIN\n3.EXIT")
        choice = check_input("enter the option :", 1)
        if choice == 1:
            user()
        elif choice == 2:
            admin()
            sync_to_main()
        elif choice == 3:
            print("***Thank You***")
            exit(0)
        else:
            print("---re_enter the choice_____")
            continue
Exemplo n.º 60
0
# 9-3

class user():
    def __init__(self, first_name, last_name):
        self.first_name = first_name
        self.last_name = last_name
    
    def user_name(self):
        print("Current user is " + self.first_name + " " + self.last_name)
    
    
    def greeting(self):
        print("hello " + self.first_name + " " + self.last_name + "!")

user1 = user('Wei', 'Wang')
user1.user_name()
user1.greeting()

print("\n")
user2 = user('Xiao', 'Wu')
user2.user_name()
user2.greeting()

print("\n")
user3 = user('Kong', 'Wu')
user3.user_name()
user3.greeting()


# In[33]: