update to include "extgrps" folder in grp name search

This commit is contained in:
Skillet 2023-05-08 14:19:11 -04:00
parent c9c4aca402
commit 27359ff29f

View File

@ -1,4 +1,5 @@
import http.server
import os
import socketserver
from urllib.parse import urlparse
from urllib.parse import parse_qs
@ -15,13 +16,19 @@ class serveRA(http.server.SimpleHTTPRequestHandler):
query = parse_qs(urlparse(self.path).query)
if 'grpName' in query:
grpName = query['grpName'][0]
grpfile = "./"
if os.path.exists(f"./wlgrps/{grpName}.cfg"):
grpfile += f"wlgrps/{grpName}.cfg"
elif os.path.exists(f"./extgrps/{grpName}.cfg"):
grpfile += f"extgrps/{grpName}.cfg"
else:
print("could not find admins file!", file=stderr)
try:
file = open(f"./wlgrps/{grpName}.cfg", 'rb')
file = open(grpfile, 'rb')
self.copyfile(file, self.wfile)
file.close()
except:
print('failed to open file!', file=stderr)
return
self.copyfile(file, self.wfile)
file.close()
return