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

« back to all changes in this revision

Viewing changes to bin/ivle-addexercise

Update some docs, and remove other obsolete ones.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
"""Script to upload an exercise file into the database"""
22
22
 
23
 
import os, sys, traceback
 
23
import os, sys
24
24
import xml.dom.minidom as minidom
25
25
 
26
26
from ivle.database import Exercise, TestSuite, TestCase, TestSuiteVar, TestCasePart, get_store
152
152
            filename = child_node.getAttribute('name')
153
153
            if filename == "":
154
154
                raise XMLMalformedException('file tag must have names')
155
 
            parts.append(add_part(store, part_type, test_type, data,
 
155
            parts.append(add_part(store, element_type, test_type, data,
156
156
                                        filename))
157
157
            
158
158
        elif child_node.tagName in allowed_parts:
175
175
xmlfile = sys.argv[1]
176
176
 
177
177
def add_exercise(xmlfile):
178
 
    store = get_store()
179
 
 
180
 
    # Skip existing ones.
181
 
    if store.find(Exercise, id=unicode(xmlfile)).count():
182
 
        return
183
 
 
184
 
    print "Adding exercise", xmlfile
185
178
    try:
186
179
        filedom = minidom.parse(xmlfile)
187
180
    except IOError, e:
222
215
        elif child.tagName == 'desc':
223
216
            description = getTextData(child)
224
217
 
 
218
    if solution is None:
 
219
        raise XMLMalformedError("ivle-addexercise: error parsing XML: No solution given")
 
220
    if len(test_suite_nodes) == 0:
 
221
        raise XMLMalformedError("ivle-addexercise: error parsing XML: No Tests Given!")
 
222
 
 
223
    store = get_store()
225
224
    new_exercise = Exercise()
226
225
    new_exercise.id = unicode(xmlfile)
227
226
    new_exercise.name = exercisename
242
241
    
243
242
xmlfiles = sys.argv[1:]
244
243
for xmlfile in xmlfiles:
245
 
    try:
246
 
        add_exercise(xmlfile)
247
 
    except Exception, e:
248
 
        print "ERROR: Could not add file", xmlfile
 
244
    print "Adding exercise", xmlfile
 
245
    #try:
 
246
    add_exercise(xmlfile)
 
247
    #except Exception, e:
 
248
    #    print "ERROR: Could not add file", xmlfile
 
249
    #    print e.stacktrace()