# -*- coding: utf-8 -*-

import db
import VG
import logger
import hashlib
import userinfo


def login(username, hostname, password):
    try:
        if hashlib.md5(password).hexdigest() == userinfo.info(username, 'password'):
            if userinfo.info(username, 'status') is 'desconectado':
                index = userinfo.registered(username)[1]
                VG.db_users[index]['status'] = 'conectado'
                VG.db_users[index]['hostname'] = hostname
                db.save('DB_Users', VG.db_users)
                logger.log('Usuario logeado a: ' + username).Logger()
            else:
                raise UnboundLocalError(username + '. Ya se enuentra conectado.')
        else:
            raise ValueError(username + '. Contraseña erronea.')

    except (TypeError, ValueError, UnboundLocalError) as e:
        logger.log(e).LogError()
        return e


def logout(username, hostname):
    try:
        if userinfo.info(username, 'hostname') == hostname:
            if userinfo.info(username, 'status') is 'conectado':
                index = userinfo.registered(username)[1]
                VG.db_users[index]['status'] = 'desconectado'
                VG.db_users[index]['hostname'] = ''
                db.save('DB_Users', VG.db_users)
                logger.log('Usuario deslogueado: ' + username).Logger()
            else:
                raise UnboundLocalError(username + '. Ya se enuentra desconectado.')
        else:
            raise ValueError(hostname + '. El host no coincide.')

    except (TypeError, ValueError, UnboundLocalError) as e:
        logger.log(e).LogError()
        return e

@@ -559,19 +559,17 @@
 ado a: '
- + 
++
 username
@@ -655,24 +655,25 @@
  '. Ya se en
+c
 uentra conec
@@ -871,17 +871,16 @@
 turn e%0A%0A
-%0A
 def logo
@@ -903,33 +903,24 @@
 tname):%0A
-    
+%09
 try:%0A
-        
+%09%09
 if useri
@@ -963,28 +963,19 @@
 stname:%0A
-            
+%09%09%09
 if useri
@@ -1019,32 +1019,20 @@
 ctado':%0A
-                
+%09%09%09%09
 index = 
@@ -1064,32 +1064,20 @@
 ame)%5B1%5D%0A
-                
+%09%09%09%09
 VG.db_us
@@ -1114,32 +1114,20 @@
 ectado'%0A
-                
+%09%09%09%09
 VG.db_us
@@ -1154,32 +1154,20 @@
 '%5D = ''%0A
-                
+%09%09%09%09
 db.save(
@@ -1191,32 +1191,20 @@
 _users)%0A
-                
+%09%09%09%09
 logger.l
@@ -1255,42 +1255,21 @@
 r()%0A
-            else:%0A                
+%09%09%09else:%0A%09%09%09%09
 rais
@@ -1337,34 +1337,19 @@
 .')%0A
-        else:%0A            
+%09%09else:%0A%09%09%09
 rais
@@ -1394,29 +1394,31 @@
 coincide.')%0A
-%0A    
+%09%09%09%09%09%0A%09
 except (Type
@@ -1457,32 +1457,26 @@
 rror) as e:%0A
-        
+%09%09
 logger.log(e
@@ -1484,29 +1484,23 @@
 .LogError()%0A
-        
+%09%09
 return e%0A

Update SessionHandler.py