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

« back to all changes in this revision

Viewing changes to setup.py

Added module ivle.config, which takes care of some work interfacing with
    configobj, including searching for the file and opening the object.
ivle.conf.conf now uses this instead of having its own search.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# IVLE - Informatics Virtual Learning Environment
 
3
# Copyright (C) 2007-2008 The University of Melbourne
 
4
#
 
5
# This program is free software; you can redistribute it and/or modify
 
6
# it under the terms of the GNU General Public License as published by
 
7
# the Free Software Foundation; either version 2 of the License, or
 
8
# (at your option) any later version.
 
9
#
 
10
# This program is distributed in the hope that it will be useful,
 
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
# GNU General Public License for more details.
 
14
#
 
15
# You should have received a copy of the GNU General Public License
 
16
# along with this program; if not, write to the Free Software
 
17
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 
 
19
# Module: setup
 
20
# Author: Matt Giuca
 
21
# Date:   12/12/2007
 
22
 
 
23
# This is a command-line application, for use by the administrator.
 
24
# This program is a frontend for the modules in the setup packages that 
 
25
# configure, build and install IVLE in three separate steps.
 
26
# It is called with at least one argument, which specifies which operation to
 
27
# take.
 
28
 
 
29
import sys
 
30
import setup.configure
 
31
import setup.build
 
32
import setup.install
 
33
 
 
34
def main(argv=None):
 
35
    if argv is None:
 
36
        argv = sys.argv
 
37
 
 
38
    # Print the opening spiel including the GPL notice
 
39
 
 
40
    print """IVLE - Informatics Virtual Learning Environment Setup
 
41
Copyright (C) 2007-2009 The University of Melbourne
 
42
IVLE comes with ABSOLUTELY NO WARRANTY.
 
43
This is free software, and you are welcome to redistribute it
 
44
under certain conditions. See LICENSE.txt for details.
 
45
 
 
46
IVLE Setup
 
47
"""
 
48
 
 
49
    # First argument is the name of the setup operation
 
50
    try:
 
51
        operation = argv[1]
 
52
    except IndexError:
 
53
        # Print usage message and exit
 
54
        help([])
 
55
        return 1
 
56
 
 
57
    oper_func = call_operator(operation)
 
58
    return oper_func(argv[2:])
 
59
 
 
60
def help(args):
 
61
    if len(args)!=1:
 
62
        print """Usage: python setup.py operation [options]
 
63
Operation can be:
 
64
    help [operation]
 
65
    config
 
66
    build
 
67
    install
 
68
 
 
69
    For help and options for a specific operation use 'help [operation]'."""
 
70
    else:
 
71
        operator = args[0]
 
72
        oper_func = call_operator(operator)
 
73
        oper_func(['operator','--help'])
 
74
 
 
75
def call_operator(operation):
 
76
    # Call the requested operation's function
 
77
    try:
 
78
        oper_func = {
 
79
            'help' : help,
 
80
            'config' : setup.configure.configure,
 
81
            'build' : setup.build.build,
 
82
            'install' : setup.install.install,
 
83
        }[operation]
 
84
    except KeyError:
 
85
        print >>sys.stderr, (
 
86
            """Invalid operation '%s'. Try python setup.py help."""
 
87
            % operation)
 
88
        sys.exit(1)
 
89
    return oper_func
 
90
 
 
91
if __name__ == "__main__":
 
92
    sys.exit(main())
 
93