File tree 10 files changed +135
-27
lines changed
10 files changed +135
-27
lines changed Original file line number Diff line number Diff line change 1
1
# Set up for class
2
2
3
+ Many of these steps can be run together in run.sh.
4
+
3
5
## Set up student accounts
4
6
5
7
1. Download class rosters for all sections into csv files that are put into this directory.
11
13
12
14
## Set up nbgrader_config.py
13
15
14
- 1. Generate student entries for the file with `make_student_dict_entries.py`.
16
+ 1. Generate student entries for the file with `make_student_dict_entries.py` and put into config file .
15
17
16
18
17
19
## Disperse materials to students
Original file line number Diff line number Diff line change 2
2
# how to run:
3
3
# disperse_python4geosciences_file.sh [filename]
4
4
5
- file=$1
6
- echo copyng $file
5
+ users1=$1
6
+ users2=$2
7
+ file=$3
7
8
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##*/ } ;
9
+ for id in ` cat $users1 $users2 ` ; do
10
+ cp -rf $file /home/$id /python4geosciences/materials ;
11
+ # removes path up to the file itself
12
+ chown $id :$id /home/$id /python4geosciences/materials/${file##*/ } ;
11
13
echo copied $file for $id
12
14
done
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
3
- for id in ` cat /root/pgs2017_g /root/pgs2017_ug` ; do
4
- mkdir /d2/home/$id /notebooks ;
5
- cp -rf python4geosciences /d2/home/$id /notebooks ;
6
- rm -rf /d2/home/$id /notebooks/python4geosciences/.git
7
- chown -R $id :pythonspring2017 /d2/home/$id /notebooks ;
8
- done
9
-
10
-
3
+ users1=$1
4
+ users2=$2
11
5
6
+ for id in ` cat $users1 $users2 ` ; do
7
+ cp -rf ../../python4geosciences /home/$id ;
8
+ rm -rf /home/$id /python4geosciences/.git
9
+ chown -R $id :$id /home/$id ;
10
+ done
Original file line number Diff line number Diff line change 1
- f = open ('passwords' )
1
+ import os
2
+
3
+ fuug = open ('users_undergrads.txt' )
4
+ fug = open ('users_grads.txt' )
5
+ fpug = open ('passwds_undergrads.txt' )
6
+ fpg = open ('passwds_grads.txt' )
2
7
3
8
text = '''
4
9
Python for Geosciences
5
10
6
11
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
12
8
- http://redfish.tamu.edu:8000
13
+ http://redfish.geos. tamu.edu:8000
9
14
10
15
Your username (same as TAMU NetID) and password are:
11
16
14
19
15
20
See you in class,
16
21
17
- Rob
22
+ Dr. Thyng
18
23
'''
19
24
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 ))
25
+ subject = 'Python class username and password'
26
+
27
+ for user , passwd in zip (fuug .readlines (), fpug .readlines ()):
28
+
29
+ # remove new line at end
30
+ user = user .split ()[0 ]
31
+ passwd = passwd .split ()[0 ]
32
+ email = '{username}@email.tamu.edu' .format (username = user )
33
+ message = text .format (username = user , password = passwd )
34
+ # # -s is subject, email address is who to send to, after <<< is body of message
35
+ command = 'mail -s "' + subject + '" ' + email + ' <<< "' + message + '"'
36
+ os .system (command )
Original file line number Diff line number Diff line change
1
+ '''
2
+ Generate passwords
3
+
4
+ Example usage:
5
+ wc -l < users_undergrads.txt # count number of users
6
+ python3 make_passwd.py --passwords [number of users] > passwds_undergrads.txt
7
+ wc -l < users_grads.txt # count number of users
8
+ python3 make_passwd.py --passwords [number of users] > passwds_grads.txt
9
+ '''
10
+
1
11
from random import shuffle
2
12
import argparse
3
13
9
19
10
20
args = parser .parse_args ()
11
21
22
+
23
+
12
24
# load in list of words
13
- f = open ('../words .txt' )
25
+ f = open ('../../wordlist .txt' )
14
26
words = f .readlines ()
15
27
f .close ()
16
28
Original file line number Diff line number Diff line change
1
+ '''
2
+ Usage:
3
+ python3 make_student_dict_entries.py undergrads.csv
4
+ python3 make_student_dict_entries.py grads-600.csv
5
+ python3 make_student_dict_entries.py grads-650.csv
6
+ '''
7
+
8
+
1
9
import pandas as pd
2
10
import argparse
3
11
4
- parser = argparse .ArgumentParser (description = 'Generate random passwords based on english words .' )
12
+ parser = argparse .ArgumentParser (description = 'make student entries for nbgrader_config.py file .' )
5
13
parser .add_argument ('filename' ,
6
14
help = 'Name of student csv file to parse' )
7
15
args = parser .parse_args ()
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
3
+ users1=$1
4
+ users2=$2
5
+ pass1=$3
6
+ pass2=$4
3
7
4
- for id in ` cat /root/pgs2017_g /root/pgs2017_ug` ; do
5
- adduser $id -p $password ;
8
+ # put users into an array
9
+ users=()
10
+ for id in ` cat $users1 $users2 ` ; do
11
+ users+=(" $id " )
12
+ done
13
+ # echo "${users[@]}"
14
+
15
+ # put passwords into an array
16
+ for pass in ` cat $pass1 $pass2 ` ; do
17
+ pass+=(" $pass " )
18
+ done
19
+
20
+ for (( i= 0 ;i< ${# users[@]} ;i++ )) ; do
21
+ # echo $i
22
+ # echo ${users[$i]}
23
+ # echo ${pass[$i]}
24
+ sudo adduser ${users[i]} -p ${pass[i]} ;
6
25
done
Original file line number Diff line number Diff line change 1
1
'''
2
+ Make user names
3
+
2
4
Example usage:
3
- python parse_username.py undergrads.csv
5
+ python3 parse_username.py undergrads.csv > users_undergrads.txt
6
+ python3 parse_username.py grads-600.csv > users_grads.txt
7
+ python3 parse_username.py grads-650.csv >> users_grads.txt
4
8
'''
5
9
6
10
import pandas as pd
18
22
assert domain == 'email.tamu.edu' , 'email needs to be TAMU netID'
19
23
print (username )
20
24
21
- # copy and paste into a file by undergrad vs. grad to be used in disperse_...
25
+ # redirect into a file by undergrad vs. grad to be used in disperse_...
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # Oops, need to remove the user accounts I made
4
+ # usage: ./remove_users.sh users_undergrads.txt users_grads.txt
5
+ # also good for end of class
6
+
7
+ users1=$1
8
+ users2=$2
9
+
10
+ for id in ` cat $users1 $users2 ` ; do
11
+ sudo userdel -r $id
12
+ done
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # call your roster files undergrads.csv, grads-600.csv, and grads-650.csv.
4
+ ugroster=undergrads.csv
5
+ groster1=grads-600.csv
6
+ groster2=grads-650.csv
7
+
8
+ # Save usernames
9
+ python3 parse_username.py $ugroster > users_undergrads.txt
10
+ python3 parse_username.py $groster1 > users_grads.txt
11
+ python3 parse_username.py $groster2 >> users_grads.txt
12
+
13
+ # Save passwords
14
+ num=" $( wc -l < users_undergrads.txt) " # count number of users
15
+ python3 make_passwd.py --passwords $num > passwds_undergrads.txt
16
+ num=" $( wc -l < users_grads.txt) " # count number of users
17
+ python3 make_passwd.py --passwords $num > passwds_grads.txt
18
+
19
+ # Make user accounts
20
+ ./make_user_account.sh users_undergrads.txt users_grads.txt passwds_undergrads.txt passwds_grads.txt
21
+
22
+ # If you mess it up and have to start over, remove user accounts:
23
+ # ./remove_users.sh users_undergrads.txt users_grads.txt
24
+
25
+ # Email students their username and password with `email_passwords.py`.
26
+ python3 email_passwords.py
27
+
28
+ # Make student entries to put into nbgrader file
29
+ python3 make_student_dict_entries.py $ugroster
30
+ python3 make_student_dict_entries.py $groster1
31
+ python3 make_student_dict_entries.py $groster2
32
+
33
+ # disperse class materials to students
34
+ sudo ./disperse_python4geosciences_materials.sh users_undergrads.txt users_grads.txt
35
+
36
+ # Later, disperse another file
37
+ # sudo ./disperse_python4geosciences_file.sh users_undergrads.txt users_grads.txt [filename]
You can’t perform that action at this time.
0 commit comments