Ejemplo n.º 1
0
Archivo: crawl.py Proyecto: cmbi/whynot
def crawl_lines (databank, filepath, lines):

    present_entries_bypdbid = entries_by_pdbid(get_present_entries(databank['name']))
    record_pdbids = entries_by_pdbid(storage.find('entries',{'databank_name':databank['name']}, {'pdbid':1}))
    pattern = parse_regex(databank['regex'])

    # If it's a disk file take its mtime, for urls take current time.
    mtime = time()
    if os.path.isfile (filepath):
        mtime = os.path.getmtime (filepath)

    for line in lines:

        # Only use lines that match the databank's pattern
        m = pattern.search (line)
        if not m:
            continue

        entry = {
            'databank_name': databank['name'],
            'pdbid': m.group(1).lower(),
            'filepath': filepath,
            'mtime': mtime
        }
        if entry['pdbid'] in present_entries_bypdbid:
            continue

        if entry['pdbid'] in record_pdbids:
            storage.update('entries', {'databank_name':databank['name'], 'pdbid':entry['pdbid']}, entry)
        else:
            storage.insert('entries', entry)
Ejemplo n.º 2
0
Archivo: crawl.py Proyecto: cmbi/whynot
def crawl_files (databank, pathnames):

    present_entries_bypdbid = entries_by_pdbid (get_present_entries (databank ['name']))
    record_pdbids = entries_by_pdbid (storage.find ('entries', {'databank_name': databank ['name']}, {'pdbid':1}))
    pattern = parse_regex (databank['regex'])

    for f in pathnames:

        # Only use files that match the databank's pattern.
        m = pattern.search(f)
        if not m:
            continue

        # For disk files take their mtimes, for urls take current time.
        mtime = time ()
        if os.path.isfile (f):
            mtime = os.path.getmtime (f)

        entry = {
            'databank_name': databank['name'],
            'pdbid': m.group(1).lower(),
            'filepath': f,
            'mtime': mtime
        }
        if entry ['pdbid'] in present_entries_bypdbid:
            continue

        if entry ['pdbid'] in record_pdbids:
            storage.update ('entries', {'databank_name': databank ['name'], 'pdbid': entry ['pdbid']}, entry)
        else:
            storage.insert ('entries', entry)
Ejemplo n.º 3
0
def update_entry(entry):

    databank_name = entry['databank_name']
    pdbid = entry['pdbid']

    if storage.find_one('entries', {
            'databank_name': databank_name,
            'pdbid': pdbid
    }):

        storage.update('entries', {
            'databank_name': databank_name,
            'pdbid': pdbid
        }, entry)
    else:
        storage.insert('entries', entry)
Ejemplo n.º 4
0
def crawl_lines(databank, filepath, lines):

    present_entries_bypdbid = entries_by_pdbid(
        get_present_entries(databank['name']))
    record_pdbids = entries_by_pdbid(
        storage.find('entries', {'databank_name': databank['name']},
                     {'pdbid': 1}))
    pattern = parse_regex(databank['regex'])

    # If it's a disk file take its mtime, for urls take current time.
    mtime = time()
    if os.path.isfile(filepath):
        mtime = os.path.getmtime(filepath)

    for line in lines:

        # Only use lines that match the databank's pattern
        m = pattern.search(line)
        if not m:
            continue

        entry = {
            'databank_name': databank['name'],
            'pdbid': m.group(1).lower(),
            'filepath': filepath,
            'mtime': mtime
        }
        if entry['pdbid'] in present_entries_bypdbid:
            continue

        if entry['pdbid'] in record_pdbids:
            storage.update('entries', {
                'databank_name': databank['name'],
                'pdbid': entry['pdbid']
            }, entry)
        else:
            storage.insert('entries', entry)
Ejemplo n.º 5
0
def crawl_files(databank, pathnames):

    present_entries_bypdbid = entries_by_pdbid(
        get_present_entries(databank['name']))
    record_pdbids = entries_by_pdbid(
        storage.find('entries', {'databank_name': databank['name']},
                     {'pdbid': 1}))
    pattern = parse_regex(databank['regex'])

    for f in pathnames:

        # Only use files that match the databank's pattern.
        m = pattern.search(f)
        if not m:
            continue

        # For disk files take their mtimes, for urls take current time.
        mtime = time()
        if os.path.isfile(f):
            mtime = os.path.getmtime(f)

        entry = {
            'databank_name': databank['name'],
            'pdbid': m.group(1).lower(),
            'filepath': f,
            'mtime': mtime
        }
        if entry['pdbid'] in present_entries_bypdbid:
            continue

        if entry['pdbid'] in record_pdbids:
            storage.update('entries', {
                'databank_name': databank['name'],
                'pdbid': entry['pdbid']
            }, entry)
        else:
            storage.insert('entries', entry)
Ejemplo n.º 6
0
 def checkForUpdates (self):
     storage.update ()
print(f.insert("prueba11","seguridad",['1','Prueba1',2]),'esperando 0')
print(f.insert("prueba11","seguridad",['Prueba2','2',3]),'esperando 0')
print(f.insert("prueba11","seguridad",['Prueba3','3',4]),'esperando 0')
print(f.insert("prueba11","seguridad",['Prueba4','4',5]),'esperando 0')
print(f.insert("prueba11","seguridad",['Prueba5','5',6]),'esperando 0')
print(f.insert("prueba11","seguridad",['Pruebá6','1',7]),'esperando 0')
print(f.extractTable("prueba11","seguridad"))
print(f.insert("prueba11","seguridad2",[1]), 'esperando 0')
print(f.insert("prueba11","seguridad2",[2]), 'esperando 0')
print(f.insert("prueba11","seguridad2",[3]), 'esperando 0')
print(f.insert("prueba11","seguridad2",[4]), 'esperando 0')
print(f.insert("prueba11","seguridad2",[5]), 'esperando 0')
print(f.insert("prueba11","seguridad2",[6]), 'esperando 0')
print(f.insert("prueba11","seguridad2",[7]), 'esperando 0')
# print(f.quitarmodoSeguro("prueba11","seguridad"),'esperando 0')
print(f.update("prueba11","seguridad",{0:'Prueba'},['Pruebá6','1']),'esperando 0')
print(f.checksumDatabase("prueba11",'SHA256'))
print(f.checksumDatabase("prueba11",'MD5'))
print(f.checksumTable("prueba11","seguridad","MD5"), "checksum MD5 prueba11 seguridad")
print(f.checksumDatabase("prueba11",'SHA256'), "checksum sha256 prueba11")
print(f.checksumDatabase("prueba11",'MD5'), "checksum MD5 prueba11")
print(f.checksumTable("prueba11","seguridad","MD5"), "checksum MD5 prueba11 seguridad")
print(f.checksumDatabase("BD2",'MD5'), "checksum MD5 BD2")
print(f.checksumTable("BD2","Cliente","MD5"), "checksumTable Cliente")
print(f.checksumTable("BD2","Factura","SHA256"),"cecksumTable Acceso")
print(f.delete("BD2","Factura",[85274644]), 'esperando 0')
print(f.checksumDatabase("BD2",'MD5'), "checksum2 MD5 BD2")
print(f.delete("BD2","Producto",[42527769]), 'esperando 0')
print(f.checksumDatabase("BD2",'MD5'), "checksum3 MD5 BD2")
print("Estado PKS:",f.alterAddPK("BD2","Orden",[0]), 'esperando 0')
print(f.checksumDatabase("BD2",'MD5'), "checksum4 MD5 BD2")
Ejemplo n.º 8
0
      f.insert("TEST", "seguridad", ['Prueba2', '2', False]), '/ 0')
print("INSERT INTO TABLE: ",
      f.insert("TEST", "seguridad", ['Prueba3', '3', False]), '/ 0')
print("INSERT INTO TABLE: ",
      f.insert("TEST", "seguridad", ['Prueba4', '4', False]), '/ 0')
print("INSERT INTO TABLE: ",
      f.insert("TEST", "seguridad", ['Prueba5', '5', False]), '/ 0')
print("INSERT INTO TABLE: ",
      f.insert("TEST", "seguridad", ['Pruebá6', '1', False]), '/ 0\n')

print("ALTER TABLE MODE (TO json): ",
      f.alterTableMode("TEST", "seguridad", "json"), '/ 0')
print("ALTER TABLE MODE (TO avl): ",
      f.alterTableMode("TEST", "seguridad", "avl"), '/ 0')
print("UPDATE TABLE: ",
      f.update("TEST", "seguridad", {0: 'Prueba'}, ['Pruebá6', '1']), '/ 0\n')

print("CHECKSUM DATABASE (SHA256): ", f.checksumDatabase("TEST", 'SHA256'))
print("CHECKSUM DATABASE (MD5): ", f.checksumDatabase("TEST", 'MD5'))
print("CHECKSUM DATABASE (MGR): ", f.checksumDatabase("TEST", 'MGR'),
      '/ None\n')

print("CHECKSUM TABLE (SHA256): ",
      f.checksumTable("TEST", "seguridad", "SHA256"))
print("CHECKSUM TABLE (SHA256 AGAIN): ",
      f.checksumTable("TEST", "seguridad", "SHA256"))
print("CHECKSUM TABLE (MD5): ", f.checksumTable("TEST", "seguridad", "MD5"))
print("CHECKSUM TABLE (MD5 AGAIN): ",
      f.checksumTable("TEST", "seguridad", "MD5"))
print("CHECKSUM TABLE (MGR): ", f.checksumTable("TEST", "seguridad", "MGR"),
      "\n")
print("LOAD CSV:", j.loadCSV("Estudiantes.csv", "calificacion", "loadCSV"),
      "Esperado: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]")

print("\n---- Extract Row ----")
print("EXTRACT ROW:", j.extractRow('calificacion', 'loadCSV', [42663506]))
print(
    "Esperado:",
    "['42663506', 'Rebecca', 'Sanchez', '83', '*****@*****.**', '47522796', 'Belgium', 'Straubing'] "
)
print("EXTRACT ROW:", j.extractRow('calificacion', 'loadCSV', [1]),
      "Esperado: []")

print("\n---- Update ----")
print("UPDATE TUPLA:",
      j.update('calificacion', 'loadCSV', {
          1: "Andree",
          2: "Avalos"
      }, [8106195]), "Esperado:",
      0)  #Aqui no encuentra la llave por concatenacion de "|"
print(
    "UPDATE TUPLA:",
    j.update('calificacion1', 'loadCSV', {
        1: "Andree",
        2: "Avalos"
    }, [8106195]), "Esperado:", 2)
print(
    "UPDATE TUPLA:",
    j.update('calificacion', 'loadCSV1', {
        1: "Andree",
        2: "Avalos"
    }, [8106195]), "Esperado:", 3)
print("UPDATE TUPLA:",
Ejemplo n.º 10
0
def update_entry(entry):

    databank_name = entry['databank_name']
    pdbid = entry['pdbid']

    storage.update('entries', {'databank_name': databank_name, 'pdbid': pdbid}, entry)