Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit af963470 authored by Nivesh Krishna's avatar Nivesh Krishna
Browse files

script to remove users from map file

parent c0a0fa26
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
import os
import time 

map_file = open(os.getenv('NEW_USER_LIST_MAP_PATH'), 'r+')
txt_file = open(os.getenv('NEW_USER_LIST_FILE_PATH'), 'r+')

txt_file_read = txt_file.readlines()
map_file_read = map_file.readlines()

hold_time = float(os.getenv('NUMBER_OF_DAYS_TO_HOLD', 10)) * 86400 
current_time = time.time()

for user in map_file_read:
    map_user = user.strip()
    
    for entry in txt_file_read:
        if map_user not in entry:
            continue

        created, txt_user = entry.split(',')
        txt_user = txt_user.strip()
        diff = current_time - float(created)
        
        if map_user == txt_user:
            print(f'user : {txt_user} - {diff/3600} hours')
            if (diff >= hold_time):
                print(f'remove user {txt_user}')