Skip to content

Commit 3bbc7f9

Browse files
committed
working on scripts for setting up class
1 parent d0ef570 commit 3bbc7f9

8 files changed

+202
-269
lines changed

materials/1_core.ipynb

+89-263
Large diffs are not rendered by default.

scripts/README.txt

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Set up for class
2+
3+
## Set up student accounts
4+
5+
1. Download class rosters for all sections into csv files that are put into this directory.
6+
1. Generate an undergrad and grad student username listing using `parse_username.py`.
7+
1. Generate an analogous set of files of passwords using `make_passwd.py`.
8+
1. Make the user accounts with `make_user_account.sh`.
9+
1. Email students their username and password with `email_passwords.py`.
10+
11+
12+
## Set up nbgrader_config.py
13+
14+
1. Generate student entries for the file with `make_student_dict_entries.py`.
15+
16+
17+
## Disperse materials to students
18+
19+
1. Initially: use `disperse_python4geosciences_materials.sh` to copy in the python4geosciences directory.
20+
1. Later when updating a file: `disperse_python4geosciences_file.sh`.
+5-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#!/bin/bash
2+
# how to run:
3+
# disperse_python4geosciences_file.sh [filename]
24

35
file=$1
46
echo copyng $file
57

6-
for id in `cat /root/pgs2017_g /root/pgs2017_ug` ; do
7-
cp -rf $file /d2/home/$id/notebooks/python4geosciences/materials ;
8-
chown $id:pythonspring2017 /d2/home/$id/notebooks/python4geosciences/materials/${file##*/} ;
8+
for id in `cat /root/pgs2017_g /root/pgs2017_ug` ; do
9+
cp -rf $file /d2/home/$id/notebooks/python4geosciences/materials ;
10+
chown $id:pythonspring2017 /d2/home/$id/notebooks/python4geosciences/materials/${file##*/} ;
911
echo copied $file for $id
1012
done
11-
12-
13-

scripts/email_passwords.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
f = open('passwords')
2+
3+
text = '''
4+
Python for Geosciences
5+
6+
You will need a username and password to log into the computer where we will view the class materials and work on the homework assignments. The jupyter server is:
7+
8+
http://redfish.tamu.edu:8000
9+
10+
Your username (same as TAMU NetID) and password are:
11+
12+
username: {username}
13+
password: {password}
14+
15+
See you in class,
16+
17+
Rob
18+
'''
19+
20+
for line in f.readlines():
21+
username, password = line.split()
22+
print('{username}@email.tamu.edu'.format(username=username))
23+
print(text.format(username=username, password=password))

scripts/make_passwd.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from random import shuffle
2+
import argparse
3+
4+
parser = argparse.ArgumentParser(description='Generate random passwords based on english words.')
5+
parser.add_argument('--passwords', type=int, default=1,
6+
help='Number of passwords to return')
7+
parser.add_argument('--length', default=3,
8+
help='Number of words in each password')
9+
10+
args = parser.parse_args()
11+
12+
# load in list of words
13+
f = open('../words.txt')
14+
words = f.readlines()
15+
f.close()
16+
17+
for n in range(args.passwords):
18+
# shuffle words
19+
shuffle(words)
20+
21+
# select and print 3 random words
22+
print('{}-{}-{}'.format(*[w.strip() for w in words[:args.length]]))

scripts/make_student_dict_entries.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import pandas as pd
2+
import argparse
3+
4+
parser = argparse.ArgumentParser(description='Generate random passwords based on english words.')
5+
parser.add_argument('filename',
6+
help='Name of student csv file to parse')
7+
args = parser.parse_args()
8+
9+
ds = pd.read_csv(args.filename)
10+
11+
last_name = ds['LAST NAME']
12+
first_name = ds['FIRST NAME']
13+
id = [email.split('@')[0] for email in ds['EMAIL']]
14+
15+
for info in zip(id, first_name, last_name):
16+
print(' dict(id="{}", first_name="{}", last_name="{}"),'.format(*info))

scripts/make_user_account.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
4+
for id in `cat /root/pgs2017_g /root/pgs2017_ug` ; do
5+
adduser $id -p $password;
6+
done

scripts/parse_username.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'''
2+
Example usage:
3+
python parse_username.py undergrads.csv
4+
'''
5+
6+
import pandas as pd
7+
import argparse
8+
9+
parser = argparse.ArgumentParser(description='Generate random passwords based on english words.')
10+
parser.add_argument('filename',
11+
help='Name of student csv file to parse')
12+
args = parser.parse_args()
13+
14+
ds = pd.read_csv(args.filename)
15+
16+
for email in ds['EMAIL']:
17+
username, domain = email.split('@')
18+
assert domain=='email.tamu.edu', 'email needs to be TAMU netID'
19+
print(username)
20+
21+
# copy and paste into a file by undergrad vs. grad to be used in disperse_...

0 commit comments

Comments
 (0)