update to modified_users.py fixes load times and other issues. Thanks to xwindows.

This commit is contained in:
deepend committed 2022-12-31 20:00:02 +00:00
1 parent ca38d62131
commit 05c820f908
4 files changed
+134 -13

No files matched your search

+1
View File
@@ -0,0 +1 @@
{"abirkill": 1672471953.311189, "akkartik": 1672471953.3121076, "alexandria": 1672471953.312316, "algol": 1672471953.3124924, "altzig": 1672471953.3127468, "amr": 1672471953.3129718, "ascii": 1672471953.3142695, "atrahasis": 1672471953.3147311, "badgumby": 1672471953.3152437, "barlow": 1672471953.3153868, "bc": 1672471953.3155258, "bdeshi": 1672471953.3156114, "benharri": 1672471953.3158677, "betawaffle": 1672471953.3161225, "blackjack": 1672471953.3165338, "boiert": 1672471953.3167725, "bradley": 1672471953.317019, "cano": 1672471953.3177228, "cata": 1672471953.3179038, "cdavie": 1672471953.318028, "chars": 1672471953.3182979, "ciderbat": 1672471953.3186457, "comfydev": 1672471953.3191261, "cryptan": 1672471953.3196511, "deepend": 1672471554.7907066, "dgy": 1672471953.3211079, "docgreen": 1672471953.3216166, "ebsd": 1672471953.3223782, "egj": 1672471953.3225367, "embryo": 1672471953.3228326, "emol": 1672471953.3229547, "entoreor": 1672471953.3231385, "etalon": 1672471953.3234398, "exxxxkc": 1672471953.3236587, "ferikkusu": 1672471953.3240497, "fieryaleeco": 1672471953.324112, "filip": 1672471953.3241258, "fnordperfect": 1672471953.3244631, "fourhoarder": 1672471953.3245869, "frank": 1672471953.3246646, "freya": 1672471953.3247943, "gbmor": 1672471953.3252633, "gerwitz": 1672471953.325438, "gigog27": 1672471953.3255272, "gikiski": 1672471953.3255403, "gnuhacker": 1672471953.3257766, "gringogar": 1672471953.3262088, "gritty": 1672471953.3262365, "guest": 1672471953.3263652, "gzj": 1672471953.326516, "hedy": 1672471953.3270879, "hokies9402": 1672471953.3275263, "indoneziva": 1672471953.3283372, "iolfree": 1672471953.3284774, "isaac": 1672471953.3285518, "jan": 1672471953.328946, "jaredhal": 1672471953.328995, "jdr": 1672471953.3293738, "jeauxlb": 1672471953.3293993, "jgart": 1672471953.3296468, "jjs": 1672471953.3297842, "jkachel": 1672471953.329797, "jmjl": 1672471953.3298826, "johngodlee": 1672471953.3300412, "jta": 1672471953.3304853, "jusdepatate": 1672471953.3305895, "kayw": 1672471953.331246, "kdx": 1672471953.3313098, "keithmillar": 1672471953.3313825, "kite": 1672471953.331712, "kiwi": 1672471953.3317263, "kqldm": 1672471953.332115, "lab6": 1672471953.3324509, "leha2": 1672471953.3327816, "lel": 1672471953.3328192, "liebach": 1672471953.3329887, "lime360": 1672471953.3330178, "localghost": 1672471953.3331275, "lp0": 1672471953.333335, "luana": 1672471953.3333757, "lucss21a": 1672471953.3334472, "lukewarmcat": 1672471953.3335376, "lurker": 1672471953.3336072, "lyiriyah": 1672471953.3336594, "masacaai": 1672471953.334343, "mathguy": 1672471953.3344223, "melyanna": 1672471953.3350608, "meskin": 1672471953.3351176, "mhd": 1672471953.3352332, "michaelcoyote": 1672471953.335283, "mnw": 1672471953.3358111, "mot": 1672471953.3361487, "mpnordland": 1672471953.3362021, "ms": 1672471953.3362942, "mz721": 1672471953.3365898, "nan0id": 1672471953.3367572, "nebb": 1672471953.3369436, "neildaemond": 1672471953.3369849, "nepose": 1672471953.3371208, "notsure": 1672471953.3378599, "novaburst": 1672471953.337887, "odintsoff": 1672471953.3383458, "oink": 1672471953.3384151, "oreamnos": 1672471953.3385887, "performa": 1672471953.339265, "peron": 1672471953.3392894, "petitpoil": 1672471953.3393824, "pizza": 1672471953.3397906, "pkepley": 1672471953.3398192, "proub": 1672471953.3402932, "pulset": 1672471953.3403819, "randomnoun": 1672471953.537768, "randymon": 1672471953.5379276, "rebello": 1672471953.538871, "redsun": 1672471953.5392008, "renehsz": 1672471953.5396626, "rfnash": 1672471953.5401828, "rgu": 1672471953.5403461, "rmgr": 1672471953.5414875, "royce": 1672471953.5431669, "ryu": 1672471953.5444317, "schroeder": 1672471953.5463367, "simplicialcomplex": 1672471953.5472374, "smit2300": 1672471953.547797, "steph": 1672471953.5485642, "stern": 1672471953.548617, "sulaco": 1672471953.548953, "t0rba": 1672471953.97683, "t3mp0r4ry": 1672471953.9768798, "thecomputerguy": 1672471953.9775925, "thekorhi": 1672471953.9776983, "therainingmonkey": 1672471953.9778004, "tiwesdaeg": 1672471953.978198, "tomasino": 1672471953.9783902, "travelpi": 1672471953.9786105, "tubbo": 1672471953.9789686, "ty3r0x": 1672471953.97919, "ultranight": 1672471953.9793472, "underwood": 1672471953.979389, "usless": 1672471953.9795325, "vim": 1672471953.9800313, "vincent": 1672471953.980047, "vulpecula": 1672471953.9803052, "walden": 1672471953.9804468, "watermelonfaces": 1672471953.9805148, "whodini": 1672471953.98081, "wilsonnb": 1672471953.9811342, "wintermute": 1672471953.9811907, "xnoe": 1672471953.9816458, "xwindows": 1672471953.981735, "xyz": 1672471953.9817648, "zaphod42": 1672471953.9822001, "zerodni": 1672471953.9823458, "zoot": 1672471953.98251, "4mvrs": 1672475663.217685, "_": 1672475663.217761, "_nathan": 1672475663.217778, "aakash": 1672475663.2179317, "aalaap": 1672475663.2179458, "aanand": 1672475663.2179585, "abrons": 1672475663.2181263, "abutler": 1672475663.2181566, "activitystory": 1672475663.2183397, "admoman": 1672475663.2184787, Line truncated
+55
View File
@@ -0,0 +1,55 @@
#!/usr/bin/env python
import hashlib
import json
import os
LINK = "1~{0} /~{0} tilde.club 70"
def compare_gophermaps(user, cache):
user_path = f"/home/{user}/public_gopher/gophermap"
if not os.path.exists(user_path):
# Ignore user if public_gopher folder is not found
return
if user in cache:
print(LINK.format(user))
return
skel_path = "/etc/skel/public_gopher/gophermap"
skel_hash = hashlib.sha256()
with open(skel_path, "rb") as f:
skel_hash.update(f.read())
try:
user_hash = hashlib.sha256()
with open(user_path, "rb") as f:
user_hash.update(f.read())
if user_hash.hexdigest() != skel_hash.hexdigest():
cache[user]=True
print(LINK.format(user))
except PermissionError:
# Ignore PermissionError exceptions and treat the gophermap file as one to not list
pass
def main():
cache_path = "cache.json"
# Load the cache from disk if it exists, otherwise create a new cache
if os.path.exists(cache_path):
with open(cache_path, "r") as f:
cache = json.load(f)
else:
cache = {}
for user in sorted(os.listdir("/home"), key=lambda x: x.lower()):
compare_gophermaps(user, cache)
# Save the cache to disk
with open(cache_path, "w") as f:
json.dump(cache, f)
if __name__ == "__main__":
main()
+77 -13
View File
@@ -1,19 +1,83 @@
#!/usr/bin/env python
import filecmp
import os
def users():
return sorted(os.listdir("/home"), key=lambda x: x.lower())
import hashlib
import json
import os
import time
LINK = "1~{0} /~{0} tilde.club 70"
for user in users():
if os.path.exists(f"/home/{user}/public_gopher/gophermap"):
try:
if not filecmp.cmp(
"/etc/skel/public_gopher/gophermap",
f"/home/{user}/public_gopher/gophermap", shallow=False):
print(LINK.format(user))
except IOError:
pass
# This function returns boolean on whether `cache` was modified
def compare_gophermaps(user, cache):
user_path = f"/home/{user}/public_gopher/gophermap"
current_time = time.time()
time_threshold = 259200
if user in cache and current_time-cache[user] < time_threshold:
print(LINK.format(user))
return False
if not os.path.exists(user_path):
# Ignore user if public_gopher folder is not found
if user in cache:
del cache[user]
return True
else:
return False
skel_path = "/etc/skel/public_gopher/gophermap"
skel_hash = hashlib.sha256()
with open(skel_path, "rb") as f:
skel_hash.update(f.read())
try:
user_hash = hashlib.sha256()
with open(user_path, "rb") as f:
user_hash.update(f.read())
if user_hash.hexdigest() != skel_hash.hexdigest():
cache[user]=current_time
print(LINK.format(user))
return True
else:
if user in cache:
del cache[user]
return True
else:
return False
except FileNotFoundError:
# Accessible gopher directory without gophermap is a non-stock gopher directory
cache[user]=current_time
print(LINK.format(user))
return True
except:
# PermissionError and the rest, treat the gophermap file as one to not list
if user in cache:
del cache[user]
return True
else:
return False
def main():
cache_path = "cache.json"
modified = False
# Load the cache from disk if it exists, otherwise create a new cache
if os.path.exists(cache_path):
with open(cache_path, "r") as f:
cache = json.load(f)
else:
cache = {}
modified = True
for user in sorted(os.listdir("/home"), key=lambda x: x.lower()):
if compare_gophermaps(user, cache):
modified = True
# Save the cache to disk, if modified
if modified:
with open(cache_path, "w") as f:
json.dump(cache, f)
if __name__ == "__main__":
main()
Symlink
+1
View File
@@ -0,0 +1 @@
/home/benharri/workspace/ttbp/README.md