/usr/bin/turnin is in turnin-ng 1.3-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | #!/usr/bin/python
# Turnin-NG, an assignment submitter and manager. --- Turnin script
# Copyright (C) 2009-2010 Ryan Kavanagh <ryanakca@kubuntu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from optparse import OptionParser, OptionGroup
import os.path
import sys
import turninng
from turninng.configparser import TurninGlobal, TurninCourse, TurninProject
from turninng.submitter import submit_files, list_projects
if __name__ == '__main__':
usage = '%prog [options] [files]'
parser = OptionParser(version=turninng.__version__, usage=usage)
parser.add_option('-c', '--course', help='Set the course to submit the ' +
'assignment to.')
parser.add_option('-l', '--list', help='Lists projects for the course. ' +
'also displays whether or not the project is open.',
action='store_true')
parser.add_option('-p', '--project', help='Set the project to submit the '+
'assigmnent to.')
parser.add_option('-C', '--config', help='Set a custom configuration ' +
'file.')
parser.add_option('-k', '--keyid', help='Cryptographically sign this ' +
'assignment using this key.')
parser.add_option('-v', '--verbose', action='store_true', help='Print ' +
'a list of submitted files after submitting.')
parser.add_option('-w', '--legal', action='store_true',
help='Print warranty and license information.')
parser.set_defaults(config=os.path.join('/etc', 'turnin-ng.cf'))
(options, args) = parser.parse_args()
if options.legal:
sys.exit(turninng.__license__)
config = options.config
# If we're listing projects, it's obvious we won't be submitting to one.
if not options.list and not args:
print ValueError("Error, please submit at least one document.")
parser.print_help()
sys.exit(ValueError(''))
if not options.course:
sys.exit(ValueError("Error, please specify a course."))
try:
# We're listing the courses:
course = TurninCourse(TurninCourse(config,
options.course).course['projlist'], options.course)
if options.list:
projects = list_projects(course.config.filename, options.course)
for i in projects:
print i
sys.exit()
except ValueError, e:
sys.exit(e)
try:
# We're creating after having run list because if the user is asking for
# a list of projects, the user won't be passing a project.
if options.project:
project = TurninProject(course.config.filename, options.course, options.project)
else:
if course.course.has_key('default') and course.course['default']:
project = TurninProject(course.config.filename, options.course,
course.course['default'])
else:
raise ValueError("It appears that this course does not have a "+
"default project. You will have to specify one " +
"yourself using the '-p' or '--project' option.")
except ValueError, e:
sys.exit(e)
if not project.project['enabled']:
sys.exit(ValueError("Error, project %s is not enabled." % project.name))
# We have checked that the user has provided a course, a project and
# assignments. We can now proceed to submit them.
files = submit_files(project, args, gpg_key=options.keyid)
if options.verbose:
print "Submitted files:"
for file in files:
print file
sys.exit()
else:
sys.exit("Successfully submitted your assignment for grading.")
|