~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: dcoles
  • Date: 2008-03-10 06:11:51 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:682
Natural Language Tool Kit (nltk) for student code

setup.py: copy '/usr/share/nltk' into jail
d/s/install_proc.txt: How to download and install NLTK
d/dependencies.txt: Added NLTK as a student code dependancy

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
# Copy trampoline/trampoline to $target/bin.
56
56
# chown and chmod the installed trampoline.
57
57
# Copy www/ to $target.
58
 
# Copy jail/ to jails __staging__ directory (unless --nojail specified).
 
58
# Copy jail/ to jails template directory (unless --nojail specified).
59
59
 
60
60
import os
61
61
import stat
69
69
import getopt
70
70
import hashlib
71
71
import uuid
72
 
import pysvn
73
72
 
74
73
# Import modules from the website is tricky since they're in the www
75
74
# directory.
112
111
    '/lib/libuuid.so.1',
113
112
    '/usr/lib/libapr-1.so.0',
114
113
    '/usr/lib/libaprutil-1.so.0',
115
 
    '/usr/lib/libapt-pkg-libc6.6-6.so.4.5',
116
 
    '/usr/lib/libdb-4.6.so',
 
114
    '/usr/lib/libdb-4.4.so',
117
115
    '/usr/lib/libexpat.so.1',
118
116
    '/usr/lib/libgcrypt.so.11',
119
117
    '/usr/lib/libgnutls.so.13',
123
121
    '/usr/lib/libkrb5.so.3',
124
122
    '/usr/lib/libkrb5support.so.0',
125
123
    '/usr/lib/liblber.so.2',
126
 
    '/usr/lib/liblber-2.4.so.2',
127
124
    '/usr/lib/libldap_r.so.2',
128
 
    '/usr/lib/libldap_r-2.4.so.2',
129
 
    '/usr/lib/libneon.so.27',
 
125
    '/usr/lib/libneon.so.26',
130
126
    '/usr/lib/libpq.so.5',
131
127
    '/usr/lib/libsasl2.so.2',
132
128
    '/usr/lib/libsqlite3.so.0',
167
163
    '/etc/matplotlibrc',
168
164
    # Needed for resolv
169
165
    '/lib/libnss_dns.so.2',
170
 
    '/lib/libnss_mdns4_minimal.so.2',
 
166
    #'/lib/libnss_mdns4.so',
171
167
    '/etc/hosts',
172
168
    '/etc/resolv.conf',
173
169
    #'/etc/hosts.conf',
174
170
    #'/etc/hostname',
175
171
    '/etc/nsswitch.conf',
176
172
    '/lib/libnss_files.so.2',
177
 
    # Needed for PIL
178
 
    '/usr/lib/libjpeg.so.62',
179
 
    # Needed by lxml
180
 
    '/usr/lib/libxslt.so.1',
181
 
    '/usr/lib/libexslt.so.0',
182
 
    # Needed by elementtree
183
 
    '/usr/lib/libtidy-0.99.so.0',
184
173
]
185
174
# Symlinks to make within the jail. Src mapped to dst.
186
175
JAIL_LINKS = {
190
179
JAIL_COPYTREES = {
191
180
    '/usr/lib/python%s' % PYTHON_VERSION:
192
181
        'jail/usr/lib/python%s' % PYTHON_VERSION,
193
 
    '/var/lib/python-support/python%s' % PYTHON_VERSION:
194
 
        'jail/var/lib/python-support/python%s' %PYTHON_VERSION,
195
182
    '/usr/share/matplotlib': 'jail/usr/share/matplotlib',
196
183
    '/etc/ld.so.conf.d': 'jail/etc/ld.so.conf.d',
197
 
    '/usr/share/pycentral': 'jail/usr/share/pycentral',
198
 
    '/usr/share/pycentral-data': 'jail/usr/share/pycentral-data',
199
184
    '/usr/share/nltk': 'jail/usr/share/nltk',
200
185
}
201
186
 
261
246
    file system):""",
262
247
    """
263
248
# In the local file system, where is the Terms of Service document located."""))
264
 
config_options.append(ConfigOption("motd_path",
265
 
    "/home/informatics/motd.html",
266
 
    """Location where the Message of the Day document is stored (on the local
267
 
    file system):""",
268
 
    """
269
 
# In the local file system, where is the Message of the Day document
270
 
# located. This is an HTML file (just the body fragment), which will
271
 
# be displayed on the login page. It is optional."""))
272
249
config_options.append(ConfigOption("public_host", "public.localhost",
273
250
    """Hostname which will cause the server to go into "public mode",
274
251
providing login-free access to student's published work:""",
533
510
Copy trampoline/trampoline to $target/bin.
534
511
chown and chmod the installed trampoline.
535
512
Copy www/ to $target.
536
 
Copy jail/ to jails __staging__ directory (unless --nojail specified).
 
513
Copy jail/ to jails template directory (unless --nojail specified).
537
514
Copy subjects/ to subjects directory (unless --nosubjects specified).
538
515
 
539
516
--nojail        Do not copy the jail.
658
635
    jailconffile = os.path.join(cwd, "lib/conf/jailconf.py")
659
636
    conf_hfile = os.path.join(cwd, "trampoline/conf.h")
660
637
    phpBBconffile = os.path.join(cwd, "www/php/phpBB3/config.php")
661
 
    usrmgtserver_initdfile = os.path.join(cwd, "doc/setup/usrmgt-server.init")
662
638
 
663
639
    # Get command-line arguments to avoid asking questions.
664
640
 
679
655
    %s
680
656
    %s
681
657
    %s
682
 
    %s
683
658
prompting you for details about your configuration. The file will be
684
659
overwritten if it already exists. It will *not* install or deploy IVLE.
685
660
 
686
661
Please hit Ctrl+C now if you do not wish to do this.
687
 
""" % (conffile, jailconffile, conf_hfile, phpBBconffile, usrmgtserver_initdfile)
 
662
""" % (conffile, jailconffile, conf_hfile, phpBBconffile)
688
663
 
689
664
        # Get information from the administrator
690
665
        # If EOF is encountered at any time during the questioning, just exit
862
837
 
863
838
    print "Successfully wrote www/php/phpBB3/config.php"
864
839
 
865
 
    # Write lib/conf/usrmgt-server.init
866
 
 
867
 
    try:
868
 
        conf = open(usrmgtserver_initdfile, "w")
869
 
 
870
 
        conf.write( '''#! /bin/sh
871
 
 
872
 
# Works for Ubuntu. Check before using on other distributions
873
 
 
874
 
### BEGIN INIT INFO
875
 
# Provides:          usrmgt-server
876
 
# Required-Start:    $syslog $networking $urandom
877
 
# Required-Stop:     $syslog
878
 
# Default-Start:     2 3 4 5
879
 
# Default-Stop:      1
880
 
# Short-Description: IVLE user management server
881
 
# Description:       Daemon connecting to the IVLE user management database.
882
 
### END INIT INFO
883
 
 
884
 
PATH=/sbin:/bin:/usr/sbin:/usr/bin
885
 
DESC="IVLE user management server"
886
 
NAME=usrmgt-server
887
 
DAEMON=/opt/ivle/scripts/$NAME
888
 
DAEMON_ARGS="''' + str(usrmgt_port) + ''' ''' + usrmgt_magic + '''"
889
 
PIDFILE=/var/run/$NAME.pid
890
 
SCRIPTNAME=/etc/init.d/usrmgt-server
891
 
 
892
 
# Exit if the daemon does not exist 
893
 
test -f $DAEMON || exit 0
894
 
 
895
 
# Load the VERBOSE setting and other rcS variables
896
 
[ -f /etc/default/rcS ] && . /etc/default/rcS
897
 
 
898
 
# Define LSB log_* functions.
899
 
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
900
 
. /lib/lsb/init-functions
901
 
 
902
 
#
903
 
# Function that starts the daemon/service
904
 
#
905
 
do_start()
906
 
{
907
 
        # Return
908
 
        #   0 if daemon has been started
909
 
        #   1 if daemon was already running
910
 
        #   2 if daemon could not be started
911
 
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
912
 
                || return 1
913
 
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
914
 
                $DAEMON_ARGS \
915
 
                || return 2
916
 
        # Add code here, if necessary, that waits for the process to be ready
917
 
        # to handle requests from services started subsequently which depend
918
 
        # on this one.  As a last resort, sleep for some time.
919
 
}
920
 
 
921
 
#
922
 
# Function that stops the daemon/service
923
 
#
924
 
do_stop()
925
 
{
926
 
        # Return
927
 
        #   0 if daemon has been stopped
928
 
        #   1 if daemon was already stopped
929
 
        #   2 if daemon could not be stopped
930
 
        #   other if a failure occurred
931
 
        start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
932
 
        RETVAL="$?"
933
 
        [ "$RETVAL" = 2 ] && return 2
934
 
        # Wait for children to finish too if this is a daemon that forks
935
 
        # and if the daemon is only ever run from this initscript.
936
 
        # If the above conditions are not satisfied then add some other code
937
 
        # that waits for the process to drop all resources that could be
938
 
        # needed by services started subsequently.  A last resort is to
939
 
        # sleep for some time.
940
 
        start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
941
 
        [ "$?" = 2 ] && return 2
942
 
        # Many daemons don't delete their pidfiles when they exit.
943
 
        rm -f $PIDFILE
944
 
        return "$RETVAL"
945
 
}
946
 
 
947
 
#
948
 
# Function that sends a SIGHUP to the daemon/service
949
 
#
950
 
do_reload() {
951
 
        #
952
 
        # If the daemon can reload its configuration without
953
 
        # restarting (for example, when it is sent a SIGHUP),
954
 
        # then implement that here.
955
 
        #
956
 
        start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
957
 
        return 0
958
 
}
959
 
 
960
 
case "$1" in
961
 
  start)
962
 
    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
963
 
        do_start
964
 
        case "$?" in
965
 
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
966
 
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
967
 
        esac
968
 
        ;;
969
 
  stop)
970
 
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
971
 
        do_stop
972
 
        case "$?" in
973
 
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
974
 
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
975
 
        esac
976
 
        ;;
977
 
  #reload|force-reload)
978
 
        #
979
 
        # If do_reload() is not implemented then leave this commented out
980
 
        # and leave 'force-reload' as an alias for 'restart'.
981
 
        #
982
 
        #log_daemon_msg "Reloading $DESC" "$NAME"
983
 
        #do_reload
984
 
        #log_end_msg $?
985
 
        #;;
986
 
  restart|force-reload)
987
 
        #
988
 
        # If the "reload" option is implemented then remove the
989
 
        # 'force-reload' alias
990
 
        #
991
 
        log_daemon_msg "Restarting $DESC" "$NAME"
992
 
        do_stop
993
 
        case "$?" in
994
 
          0|1)
995
 
                do_start
996
 
                case "$?" in
997
 
                        0) log_end_msg 0 ;;
998
 
                        1) log_end_msg 1 ;; # Old process is still running
999
 
                        *) log_end_msg 1 ;; # Failed to start
1000
 
                esac
1001
 
                ;;
1002
 
          *)
1003
 
                # Failed to stop
1004
 
                log_end_msg 1
1005
 
                ;;
1006
 
        esac
1007
 
        ;;
1008
 
  *)
1009
 
        #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
1010
 
        echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
1011
 
        exit 3
1012
 
        ;;
1013
 
esac
1014
 
 
1015
 
:
1016
 
''')
1017
 
        
1018
 
        conf.close()
1019
 
    except IOError, (errno, strerror):
1020
 
        print "IO error(%s): %s" % (errno, strerror)
1021
 
        sys.exit(1)
1022
 
 
1023
 
    # fix permissions as the file contains the database password
1024
 
    try:
1025
 
        os.chmod('doc/setup/usrmgt-server.init', 0600)
1026
 
    except OSError, (errno, strerror):
1027
 
        print "WARNING: Couldn't chmod doc/setup/usrmgt-server.init:"
1028
 
        print "OS error(%s): %s" % (errno, strerror)
1029
 
 
1030
 
    print "Successfully wrote lib/conf/usrmgt-server.init"
1031
 
 
1032
840
    print
1033
841
    print "You may modify the configuration at any time by editing"
1034
842
    print conffile
1035
843
    print jailconffile
1036
844
    print conf_hfile
1037
845
    print phpBBconffile
1038
 
    print usrmgtserver_initdfile
1039
846
    print
1040
847
    return 0
1041
848
 
1047
854
 
1048
855
    if dry:
1049
856
        print "Dry run (no actions will be executed\n"
1050
 
    
1051
 
    # Find out the revison number
1052
 
    revnum = get_svn_revision()
1053
 
    print "Building Revision %s"%str(revnum)
1054
 
    if not dry:
1055
 
        vfile = open('BUILD-VERSION','w')
1056
 
        vfile.write(str(revnum) + '\n')
1057
 
        vfile.close()
1058
857
 
1059
858
    # Compile the trampoline
1060
859
    curdir = os.getcwd()
1170
969
 
1171
970
    if not nojail:
1172
971
        # Copy the local jail directory built by the build action
1173
 
        # to the jails __staging__ directory (it will be used to help build
1174
 
        # all the students' jails).
1175
 
        action_copytree('jail', os.path.join(jail_base, '__staging__'), dry)
 
972
        # to the jails template directory (it will be used as a template
 
973
        # for all the students' jails).
 
974
        action_copytree('jail', os.path.join(jail_base, 'template'), dry)
1176
975
    if not nosubjects:
1177
976
        # Copy the subjects and exercises directories across
1178
977
        action_copylist(install_list.list_subjects, subjects_base, dry,
1219
1018
        print >>sys.stderr, "(I need to chown some files)."
1220
1019
        return 1
1221
1020
 
1222
 
    # Update the staging jail directory in case it hasn't been installed
 
1021
    # Update the template jail directory in case it hasn't been installed
1223
1022
    # recently.
1224
 
    action_copytree('jail', os.path.join(jail_base, '__staging__'), dry)
 
1023
    action_copytree('jail', os.path.join(jail_base, 'template'), dry)
1225
1024
 
1226
1025
    # Re-link all the files in all students jails.
1227
1026
    for dir in os.listdir(jail_base):
1228
 
        if dir == '__staging__': continue
 
1027
        if dir == 'template': continue
1229
1028
        # First back up the student's home directory
1230
1029
        temp_home = os.tmpnam()
1231
1030
        action_rename(os.path.join(jail_base, dir, 'home'), temp_home, dry)
1232
1031
        # Delete the student's jail and relink the jail files
1233
 
        action_linktree(os.path.join(jail_base, '__staging__'),
 
1032
        action_linktree(os.path.join(jail_base, 'template'),
1234
1033
            os.path.join(jail_base, dir), dry)
1235
1034
        # Restore the student's home directory
1236
1035
        action_rename(temp_home, os.path.join(jail_base, dir, 'home'), dry)
1443
1242
            del list[i]
1444
1243
        i -= 1
1445
1244
 
1446
 
def get_svn_revision():
1447
 
    """Returns either the current SVN revision of this build, or None"""
1448
 
    try:
1449
 
        svn = pysvn.Client()
1450
 
        entry = svn.info('.')
1451
 
        revnum = entry.revision.number
1452
 
    except pysvn.ClientError, e:
1453
 
        revnum = None
1454
 
    return revnum
1455
 
 
1456
1245
if __name__ == "__main__":
1457
1246
    sys.exit(main())
1458