tidy up gen_tdp and fix user count
This commit is contained in:
parent
77bc495812
commit
7162d3b82f
33
gen_tdp
33
gen_tdp
|
@ -5,34 +5,33 @@ from bs4 import BeautifulSoup as bs
|
||||||
tdp = {}
|
tdp = {}
|
||||||
tdp["name"] = "tilde.team"
|
tdp["name"] = "tilde.team"
|
||||||
tdp["url"] = "https://tilde.team"
|
tdp["url"] = "https://tilde.team"
|
||||||
tdp["signup_url"] = tdp["url"]+"/signup"
|
tdp["signup_url"] = tdp["url"] + "/signup/"
|
||||||
users = subprocess.check_output(["/usr/bin/members","team"]).decode('ascii').split()
|
users = subprocess.check_output(["/usr/bin/members", "team"]).decode("ascii").split()
|
||||||
users.sort()
|
users.sort()
|
||||||
tdp["user_count"] = len(users)-1
|
tdp["user_count"] = len(users)
|
||||||
tdp["want_users"] = True
|
tdp["want_users"] = True
|
||||||
tdp["admin_email"] = "sudoers@tilde.team"
|
tdp["admin_email"] = "sudoers@tilde.team"
|
||||||
tdp["description"] = "a digital community for socializing, learning, and making cool stuff, tilde.team is a shared system that provides a radically inclusive, non-commercial space for teaching, learning, practicing and enjoying the social medium of unix."
|
tdp["description"] = "a digital community for socializing, learning, and making cool stuff, tilde.team is a shared system that provides a radically inclusive, non-commercial space for teaching, learning, practicing and enjoying the social medium of unix."
|
||||||
tdpusers = []
|
tdpusers = []
|
||||||
|
|
||||||
for user in users:
|
for user in users:
|
||||||
if user=="asm":
|
|
||||||
continue
|
|
||||||
tdpuser = dict(username=user)
|
tdpuser = dict(username=user)
|
||||||
try:
|
try:
|
||||||
title = bs(requests.get("https://tilde.team/~{}".format(user)).text,"lxml").title
|
title = bs(
|
||||||
|
requests.get(f"https://tilde.team/~{user}/", allow_redirects=False).text,
|
||||||
|
"lxml",
|
||||||
|
).title.text
|
||||||
except:
|
except:
|
||||||
if user=="ahriman": pass
|
|
||||||
else: raise
|
|
||||||
if title is None:
|
|
||||||
title = "No title"
|
title = "No title"
|
||||||
else:
|
|
||||||
title = title.text
|
|
||||||
tdpuser["title"] = title
|
tdpuser["title"] = title
|
||||||
if os.path.exists(os.path.expanduser("~{}/public_html/index.html".format(user))):
|
|
||||||
tdpuser["mtime"] = os.path.getmtime(os.path.expanduser("~{}/public_html/index.html".format(user)))
|
if os.path.exists(f"/home/{user}/public_html/index.html"):
|
||||||
elif os.path.exists(os.path.expanduser("~{}/public_html/index.htm".format(user))):
|
tdpuser["mtime"] = os.path.getmtime(f"/home/{user}/public_html/index.html")
|
||||||
tdpuser["mtime"] = os.path.getmtime(os.path.expanduser("~{}/public_html/index.htm".format(user)))
|
elif os.path.exists(f"/home/{user}/public_html/index.cgi"):
|
||||||
elif os.path.exists(os.path.expanduser("~{}/public_html/index.php".format(user))):
|
tdpuser["mtime"] = os.path.getmtime(f"/home/{user}/public_html/index.cgi")
|
||||||
tdpuser["mtime"] = os.path.getmtime(os.path.expanduser("~{}/public_html/index.php".format(user)))
|
elif os.path.exists(f"/home/{user}/public_html/index.php"):
|
||||||
|
tdpuser["mtime"] = os.path.getmtime(f"/home/{user}/public_html/index.php")
|
||||||
|
|
||||||
tdpusers.append(tdpuser)
|
tdpusers.append(tdpuser)
|
||||||
tdp["users"] = tdpusers
|
tdp["users"] = tdpusers
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue