passwords = pandas.read_csv(config["dataFolder"] + os.sep + "DefaultPupilPasswords" + os.sep + "defaultPasswords.csv", header=0) for pupilIndex, pupil in pupils.iterrows(): pupilPassword = "" for passwordIndex, passwordEntry in passwords.iterrows(): if pupil["ID"] == passwordEntry["ID"]: pupilPassword = passwordEntry["DefaultPassword"] outputString = outputString + "P" + padString( str(pupil["ID"]) ) + "," + pupil["GivenName"] + " " + pupil["FamilyName"] + "," + pupil[ "OldUsername"] + "@knightsbridgeschool.com," + pupil[ "Form"] + ",," + pupilPassword + "," + pupil["OldUsername"] + "\n" installLib.writeFile( config["dataFolder"] + os.sep + "Twig" + os.sep + "pupils.csv", outputString) # Staff, input: GUID,UserCode,Title,GivenName,FamilyName,DateOfBirth,Username,Identifier,Form,JobTitle # Staff, output: Unique ID (optional),Teacher Name (required),Email (required),Class (optional),Student Group (optional),Password (required),Username (optional) outputString = "Unique ID,Teacher Name,Email,Class,Student Group,Password,Username\n" staff = pandas.read_csv(config["dataFolder"] + os.sep + "staff.csv", header=0) for staffIndex, staff in staff.iterrows(): outputString = outputString + "S" + padString( str(staff["ID"]) ) + "," + staff["GivenName"] + " " + staff["FamilyName"] + "," + staff[ "Username"] + "@knightsbridgeschool.com,,,,\n" installLib.writeFile( config["dataFolder"] + os.sep + "Twig" + os.sep + "staff.csv", outputString)
# Load the configuration file. config = json.loads(installLib.readFile("config/config.json")) for requiredConfigParameter in requiredConfigParameters: if not requiredConfigParameter in config.keys(): print("Error - required value " + requiredConfigParameter + " not set in config.json.") sys.exit(1) # Make sure the output folder exists. os.makedirs(config["dataFolder"] + os.sep + "Bebras", exist_ok=True) # Pupils, input: GUID,UserCode,GivenName,FamilyName,DateOfBirth,Gender,Username,YearGroup,Form,House,Tutor # Pupils, output: Full name, date of birth, Year group, Form group, House, gender, emergency contact outputString = "Name,DateOfBirth,Yeargroup,Form,House,Gender\n" pupils = pandas.read_csv(config["dataFolder"] + os.sep + "pupils.csv", header=0) for pupilIndex, pupil in pupils.iterrows(): for validYeargroup in validYeargroups: if validYeargroup in pupil["Form"]: house = str(pupil["House"]) if house == "nan": house = "" outputString = outputString + pupil["GivenName"] + " " + pupil[ "FamilyName"] + "," + pupil[ "DateOfBirth"] + "," + validYeargroup[1] + "," + pupil[ "Form"] + "," + house + "," + pupil["Gender"] + "\n" installLib.writeFile( config["dataFolder"] + os.sep + "SquadInTouch" + os.sep + "squadInTouch.csv", outputString)
staff["DateOfBirth"].append( getValue(currentStaffMember, "DOB").split("T")[0]) staff["Username"].append(username) staff["Identifier"].append(getValue(currentStaffMember, "Username")) staff["Form"].append("") roleName = "" roles = currentStaffMember.find("Roles") if not roles == None: for role in roles: roleName = role.find("Name").text.strip() if "-" in roleName: roleName = roleName.split("-")[1].strip() staff["Role"].append(roleName) staff["JobTitle"].append("") staff["TelephoneNumber"].append("") installLib.writeFile(config["dataFolder"] + os.sep + "staff.csv", pandas.DataFrame(staff).to_csv(index=False)) print("Generating the base pupils.csv file...") forms = {} houses = {} pupils = { "GUID": [], "ID": [], "UserCode": [], "GivenName": [], "FamilyName": [], "DateOfBirth": [], "Gender": [], "Username": [], "OldUsername": [], "YearGroup": [],
for sigLine in installLib.runCommand("gam user " + staffMember["Username"] + " show signature"): matchResult = re.match(".*bold..(.*)..span. \| (.*)..div..*", sigLine.strip()) if not matchResult == None: staffName = matchResult[1].strip() staffJobTitle = matchResult[2].strip().replace("&", "&") matchResult = re.match(".*blank..(.*)@knightsbridgeschool.com./a..*", sigLine.strip()) if not matchResult == None: staffUsername = matchResult[1] matchResult = re.match("([ \d]*)</div>$", sigLine.strip()) if not matchResult == None: if not matchResult[1] == "": staffTelephone = matchResult[1] if staffUsername == "": staffUsername = staffMember["Username"] if staffTelephone == "": staffTelephone = "020 7590 9000" if staffJobTitle == "": staffJobTitle = staffMember["Role"] if not staffMember["Username"] == staffUsername: print("Username mismatch: " + staffMember["Username"] + " not equal to " + staffUsername) else: staff.at[staffIndex, "JobTitle"] = staffJobTitle staff.at[staffIndex, "TelephoneNumber"] = staffTelephone installLib.writeFile(config["dataFolder"] + os.sep + "staff.csv", staff.to_csv(index=False))
header=0) for groupIndex, group in groups.iterrows(): groupEmails.append(groups.at[groupIndex, "email"]) os.makedirs(config["dataFolder"] + os.sep + "Parents" + os.sep + "ByClassOrYearGroup", exist_ok=True) for classGroup in classGroups: groupMembers = [] for pupilIndex, pupil in pupils.iterrows(): if classGroup in pupil["Form"]: if not str(pupil["Contacts"]) == "nan": for contact in str(pupil["Contacts"]).split(): groupMembers.append(contact) installLib.writeFile( config["dataFolder"] + os.sep + "Parents" + os.sep + "ByClassOrYearGroup" + os.sep + classGroup + ".csv", groupMembers) groupEmail = classGroup.lower() + "*****@*****.**" if not groupEmail in groupEmails: os.system("gam create group " + groupEmail + " name \"" + classGroup + " Parents\" description \"Parents of " + classGroup + "\" 2>&1") os.system("gam update group " + groupEmail + " sync member file \"" + config["dataFolder"] + os.sep + "Parents" + os.sep + "ByClassOrYearGroup" + os.sep + classGroup + ".csv\" 2>&1") os.makedirs(config["dataFolder"] + os.sep + "Parents" + os.sep + "Guardians", exist_ok=True) for classGroup in classGroups: CSVString = "ID,Name,Username,OldUsername,Guardian\n" for pupilIndex, pupil in pupils.iterrows():
len(adjectives) - 1)] + nouns[random.randint( 0, len(nouns) - 1)] + str(random.randint(10, 99)) # Read the contens of a file. def readFile(theFilename): inHandle = open(theFilename) inData = inHandle.read() inHandle.close() return inData installLib.writeFile( "fullEmailTemplate.html", readFile("config" + os.sep + "passwordReset" + os.sep + "emailTemplate.html") + "<br/>\n--<br/>\n<br/>\n" + readFile("config" + os.sep + "emailSignature" + os.sep + "emailSignature.html")) # Read the existing basic pupils data. pupils = pandas.read_csv(config["dataFolder"] + os.sep + "pupils.csv", header=0) def setPassword(theUser, thePassword): for pupilIndex, pupilEntry in pupils.iterrows(): if pupilEntry["Username"] == theUser: # os.system("gam update user " + theUser + "@knightsbridgeschool.com password " + thePassword) print("Setting password for user " + theUser + "...") os.system("net user " + theUser + " " + thePassword + " /domain") for emailAddress in str(pupilEntry["Contacts"]).split(" "):
result = theString for pl in range(0, 8 - len(theString)): result = "0" + result return result # Load the configuration file. config = json.loads(installLib.readFile("config/config.json")) for requiredConfigParameter in requiredConfigParameters: if not requiredConfigParameter in config.keys(): print("Error - required value " + requiredConfigParameter + " not set in config.json.") sys.exit(1) # Input data headings: # Pupils: GUID,UserCode,GivenName,FamilyName,DateOfBirth,Gender,Username,YearGroup,Form,Tutor # Staff: GUID,UserCode,Title,GivenName,FamilyName,DateOfBirth,Username,Identifier,Form,JobTitle # 2020-01-27,,a.astudent16,AaSal,astudent,AaSal,aStudent,kfkbhrg!,S4L,4,16/03/2011 # Example output: # Pupils: P1949,ksbsmith15,Student,Library,OPAC Only,Pupils,Bob,Smith,S5C,xx/yy/zzzz # Staff: S145,b.smith,Staff,Library,Staff,Staff,Bob,Smith,,xx/yy/zzzz outputString = "" pupils = pandas.read_csv(config["dataFolder"] + os.sep + "pupils.csv", header=0) for pupilIndex, pupil in pupils.iterrows(): outputString = outputString + "P" + padString(str(pupil["ID"])) + "," + pupil["Username"] + ",Student,Library,OPAC Only,Pupils," + pupil["GivenName"] + "," + pupil["FamilyName"]+ "," + pupil["Form"]+ "," + str(pupil["DateOfBirth"]) + "\n" staff = pandas.read_csv(config["dataFolder"] + os.sep + "staff.csv", header=0) for staffIndex, staff in staff.iterrows(): outputString = outputString + "S" + padString(str(staff["ID"])) + "," + str(staff["Username"]) + ",Staff,Library,Staff,Staff," + str(staff["GivenName"]) + "," + str(staff["FamilyName"]) + ",," + str(staff["DateOfBirth"]) + "\n" installLib.writeFile(config["dataFolder"] + os.sep + "Oliver" + os.sep + "allUsersForBorrowerImport.csv", outputString)
print("Error - required value " + requiredConfigParameter + " not set in config.json.") sys.exit(1) # Make sure the output folder exists. os.makedirs(config["dataFolder"] + os.sep + "Bebras", exist_ok=True) # Pupils, input: GUID,UserCode,GivenName,FamilyName,DateOfBirth,Gender,Username,YearGroup,Form,Tutor # Pupils, output: Class, Grade (English), Firstname, Lastname, Password, Gender outputString = "Class,Grade (English),Firstname,Lastname,Password,Gender\n" pupils = pandas.read_csv(config["dataFolder"] + os.sep + "pupils.csv", header=0) passwords = pandas.read_csv(config["dataFolder"] + os.sep + "DefaultPupilPasswords" + os.sep + "defaultPasswords.csv", header=0) for pupilIndex, pupil in pupils.iterrows(): pupilPassword = "" for passwordIndex, passwordEntry in passwords.iterrows(): if pupil["ID"] == passwordEntry["ID"]: pupilPassword = passwordEntry["DefaultPassword"] for validYeargroup in validYeargroups: if validYeargroup in pupil["Form"]: outputString = outputString + pupil["Form"] + "," + pupil["Form"][ 1] + "," + pupil["GivenName"] + "," + pupil[ "FamilyName"] + "," + pupilPassword + "," + pupil[ "Gender"] + "\n" installLib.writeFile( config["dataFolder"] + os.sep + "Bebras" + os.sep + "bebras.csv", outputString)
import sys import csv import json import pandas import installLib requiredConfigParameters = ["dataFolder"] # Load the configuration file. config = json.loads(installLib.readFile("config/config.json")) for requiredConfigParameter in requiredConfigParameters: if not requiredConfigParameter in config.keys(): print("Error - required value " + requiredConfigParameter + " not set in config.json.") sys.exit(1) # Read the existing basic groups data. groups = pandas.read_csv(config["dataFolder"] + os.sep + "groups.csv", header=0) # Create a CSV file for each GSuite group. os.makedirs(config["dataFolder"] + os.sep + "Groups", exist_ok=True) print("erase " + config["dataFolder"] + os.sep + "Groups" + os.sep + "*.*") for groupIndex, group in groups.iterrows(): outputString = "" for member in str(group["Members"]).split(): outputString = outputString + member + ",\n" installLib.writeFile( config["dataFolder"] + os.sep + "Groups" + os.sep + group["name"] + ".csv", outputString)