Hirdetés

Új hozzászólás Aktív témák

  • Hege1234

    addikt

    axioma, atty_hor köszönöm az ötleteket! :R

    így most már szépen ki tud lépni, de lehet csak azért mert így még csak 1 fájlban keres
    tesztelem olyan adattal ami csak a 2. vagy 3. fájlban lehetne, ott már lehet majd el fog vérezni megint..

    (csak, hogy itt az oldalon jobban átlátható legyen ezért most csak az app_key-t tettem bele a többit kiszedtem..)

    import re
    import time
    import glob

    log_file_pattern = ".\\drmfiles\\programok\\firefox-log\\log.txt.moz_log.*"

    tokens_to_find = 10
    found_tokens = set()

    while len(found_tokens) < tokens_to_find:
    log_files = glob.glob(log_file_pattern)
    found_all_tokens = True

    for file_path in log_files:
    cutted_file_path = re.findall(r'\\([^\\]+)$', file_path)[0].strip()
    if file_path in found_tokens:
    continue

    try:
    with open(file_path, 'r') as file:
    tdata = file.read()

    app_key = re.findall(r"header=.app_key..value=.(.*)..merge=0]", tdata)[0].strip()

    print(f"Token found in {cutted_file_path}: app_key: {app_key}\n")

    found_tokens.add(file_path)

    except (IndexError, FileNotFoundError):
    print(f"Token not found in {file_path}. Waiting for the next attempt.")
    found_all_tokens = False
    except Exception as e:
    print(f"Error processing {file_path}: {e}")
    found_all_tokens = False

    if found_all_tokens:
    break

    time.sleep(2)

Új hozzászólás Aktív témák