예제 #1
0
def criarConta(obj):
    cursor = conn.connection()
    cursor.execute('INSERT INTO Conta VALUES (?,?,?,?,?)',
                   obj.numero, obj.tipo, obj.dono, obj.saldo, obj.status)

    cursor.commit()
    cursor.close()
예제 #2
0
파일: topo.py 프로젝트: watry/yolo-cyril
	def runScript(self, scripts):
		pub.dbg(21, 'connecting '+self.get('name')+' @ '+str(self.get('ip')))
		session = conn.connection(self.get('ip'))
		if session.ready():
			pub.dbg(25, 'writing '+self.get('name'))
			for x in scripts:
				pub.dbg(4,  '>>>'+x)
			return session.write(scripts)
		return 2
예제 #3
0
파일: topo.py 프로젝트: watry/yolo-cyril
	def avaiable(self, obj_str=None):
		if self.get('ip') == None: # virtual device
			return True
		session = conn.connection(self.get('ip'))
		if not session.ready():
			return False
		if obj_str!=None:
			result = session.expect('get '+obj_str+' oper', 'up')
		session.close()
		return result
예제 #4
0
def pagarMensal(obj):
    if (obj.tipo == 1):
        obj.saldo -= 12
    else:
        obj.saldo -= 20

    cursor = conn.connection()
    cursor.execute('UPDATE Conta SET saldo = ? WHERE numero = ?',
                       obj.saldo, obj.numero)
    cursor.commit()
    cursor.close()
예제 #5
0
def fecharConta(obj):
    if (obj.saldo == 0):
        obj.status = False

        cursor = conn.connection()
        cursor.execute('UPDATE Conta SET status = 0 WHERE numero = ?', obj.numero)

        cursor.commit()
        cursor.close()
        
        return True
    return False
예제 #6
0
def checaNumero(obj):
    cursor = conn.connection()
    cursor.execute('SELECT numero FROM Conta WHERE numero = ?',obj.numero)

    reader = cursor.fetchone()

    x = False
    if reader:
        x = True
        
    cursor.close()
    return x
예제 #7
0
def pegaRegistro(obj):
    cursor = conn.connection()
    cursor.execute('SELECT * FROM Conta WHERE numero = ?',obj.numero)

    reader = cursor.fetchone()
    if reader:
        obj.tipo = reader[1]
        obj.dono = reader[2]
        obj.saldo = reader[3]
        obj.status = reader[4]

    cursor.close()
예제 #8
0
파일: topo.py 프로젝트: watry/yolo-cyril
	def isPortAvaiable(self, name, loc):
		p = self.query(name=name, loc=loc)
		n = self.query(name=p.get('loc'))
		obj_str="interfaces/eth/"+p.get('name')
		if n.get('ip') == None: # virtual device
			return True
		session = conn.connection(n.get('ip'))
		if not session.ready():
			return False
		result = session.expect('show '+obj_str+' all', 'oper: up')
		session.close()
		return result
예제 #9
0
def sacar(obj, x):
    if (x <= obj.saldo):
        obj.saldo -= x

        cursor = conn.connection()
        cursor.execute('UPDATE Conta SET saldo = ? WHERE numero = ?',
                       obj.saldo, obj.numero)

        cursor.commit()
        cursor.close()
        
        return True
    return False
예제 #10
0
def abrirConta(obj):
    if (obj.status == False):
        obj.status = True

        if (obj.tipo == 1):
            obj.saldo = 50
        else:
            obj.saldo = 150

        cursor = conn.connection()
        cursor.execute('UPDATE Conta SET status = 1, saldo = ? WHERE numero = ?',
                       obj.saldo, obj.numero)

        cursor.commit()
        cursor.close()
    
        return True
    return False
예제 #11
0
파일: topo.py 프로젝트: watry/yolo-cyril
	def askfor_old(self, typ):
		if typ=='elanid':
			i=0
			for x in self.get('elanoccupied_list'):
				session = conn.connection(self.get('ip'))
				if session.expect('get ccc/'+self.get('elan_list')[i]+' admin', 'down'):
					x=True
					continue
				if x==False:
					x=True
					return self.get('elan_list')[i]
				i+=1 
			return None
		if typ=='action_id':
			i=0
			for x in self.get('action_list'):
				if self.get('action_occupied_list')[i]==False:
					return self.get('elan_list')[i]
				i+=1
			return None
		else:
			assert()
예제 #12
0
from conn import connection

connection()