Esempio n. 1
0
 def __init__(self, db_filename=None):
     if db_filename:
         self._db_filename = db_filename
     else:
         self._db_filename = os.path.join(env.get_data_root(),
                                          "messages.db")
         #self._db_filename = os.path.join("/home/lordtias/git/ceibal-notifier", "messages.db")
     conn = self._connect()
     c = conn.cursor()
     c.executescript(init_db)
     self._close_connection(conn)
Esempio n. 2
0
 def __init__(self, db_filename=None):
     '''
     @param db_filename: Nombre/direccion del archivo DB.
     @summary: Constructor de la clase.
     '''
     if db_filename:
         self._db_filename = db_filename
     else:
         self._db_filename = os.path.join(env.get_data_root(), DB_FILE)
     conn = self._connect()
     c = conn.cursor()
     c.executescript(INIT_DB)
     self._close_connection(conn)
Esempio n. 3
0
    def _check_notification_is_unread(self, message):
        id = str(message['id'])

        file_name = os.path.join(env.get_data_root(), READ_FILE)
        try:
            fp = open(file_name, "r")
            notif_read_record = json.load(fp)
        except:
            print "No existe el archivo de registro ...."
            return True

        if fp is not None:
            fp.close()

        if id in notif_read_record:
            return notif_read_record[id] == 'unread'
        else:
            print "No encuentro id en el registro ..." + id
            return True
Esempio n. 4
0
    def _save_notification_read(self, id):
        file_name = os.path.join(env.get_data_root(), READ_FILE)
        try:
            # Cargo el diccionario desde el archivo json
            fp = open(file_name, "r")
            notif_read_record = json.load(fp)
            fp.close()

            # Borro el archivo json
            open(file_name, 'w').close()
            fp = open(file_name, 'r+')
        except:
            # El archivo json no existe, lo creo.
            fp = open(file_name, "w+")
            notif_read_record = {}

        notif_read_record[id] = 'read'
        json.dump(notif_read_record, fp)
        fp.flush()
        fp.close()
Esempio n. 5
0
 def __init__(self):
     if Messages.db is None:
         db_filename = os.path.join(env.get_data_root(), DB_FILE)
         Messages.db = Db(db_filename)
Esempio n. 6
0
 def __init__(self, db_filename=os.path.join(env.get_data_root(),DB_FILE)):
     self.db_filename = db_filename
     self.images = os.path.join(env.get_images_root(), IMAGEN_NOTOFY)