Skip to content
Snippets Groups Projects
Commit 28f2fbce authored by Hague Matthew UXAC009's avatar Hague Matthew UXAC009
Browse files

Revert "Make module-info give you the intersection of multiple args"

This reverts commit e9b37c00.
parent e9b37c00
Branches
No related tags found
No related merge requests found
......@@ -8,9 +8,8 @@ registrations.
* `rhul-student-info.py` -- get student module registrations, email, and
id number. E.g. `python rhul-student-info.py "Matthew" for all
Matthews.
* `rhul-module-info.py` -- get list of students on a module. E.g. `python
rhul-module-info.py CS1811`. Specifying multiple modules gets you the
intersection.
* `rhul-module-info.py` -- get list of students on a module. E.g.
`python rhul-module-info.py CS1811`.
* `rhul-programme-info.py` -- get list of students on a programme. E.g.
`python rhul-programme-info.py Software 2` for all 2nd year students
on a Software Engineering degree.
......
......@@ -14,7 +14,7 @@ LOGIN_RE = re.compile(".*([A-Z]{4}[0-9]{3}).*")
LOGIN_RE_GRP = 1
if len(sys.argv) < 2:
print('Please pass at least one module code.')
print('Please pass module code.')
exit(-1)
search_term = sys.argv[1]
......@@ -29,14 +29,12 @@ BASE='DC=cc,DC=rhul,DC=local'
USERNAME = 'matthew.hague@rhul.ac.uk'
PASS_CMD = [os.path.expanduser('~/.config/mutt/getpass.sh'), 'rhul']
filter = "(&"
for mod_code in sys.argv[1:]:
mod_filter = "(|" + \
"".join(f"{filter.format(mod_code=mod_code)}" for filter in MOD_FILTERS) + \
")"
filter += mod_filter
filter += ")"
if len(sys.argv) < 2:
print('Please pass a search term.')
exit(-1)
mod_code = sys.argv[1]
student_attrs = [
"displayName", "mail",
"extensionAttribute2", "extensionAttribute3", "description"
......@@ -55,15 +53,17 @@ with ldap3.Connection(URI,
authentication=ldap3.SIMPLE) as conn:
count = 0
writer.writerow(["count", "name", "id", "email", "login", "description"])
conn.search(BASE, filter, attributes=student_attrs)
for student in conn.entries:
count += 1
writer.writerow([
count,
student.displayName,
student.extensionAttribute3,
student.mail,
student.extensionAttribute2,
student.description
])
for filter_fmt in MOD_FILTERS:
mod_filter = filter_fmt.format(mod_code=mod_code)
conn.search(BASE, mod_filter, attributes=student_attrs)
for student in conn.entries:
count += 1
writer.writerow([
count,
student.displayName,
student.extensionAttribute3,
student.mail,
student.extensionAttribute2,
student.description
])
......@@ -21,7 +21,6 @@
import browser_cookie3
import csv
import getopt
import os
import re
import sys
......@@ -33,12 +32,6 @@ from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.firefox.options import Options
TMPDIR = "/tmp/firefox"
if not os.path.exists(TMPDIR):
os.mkdir(TMPDIR)
os.environ["TMPDIR"] = TMPDIR
MOODLE_URL = "https://moodle.royalholloway.ac.uk"
QUIZ_EDIT_URL \
......@@ -61,10 +54,7 @@ class Browser:
self.driver = None
def __enter__(self):
ffbinary = "/var/lib/flatpak/exports/bin/org.mozilla.firefox"
ops = Options()
ops.binary_location = ffbinary
self.driver = webdriver.Firefox(options=ops)
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(WAIT_TIMEOUT)
return self
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment