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

« back to all changes in this revision

Viewing changes to bin/ivle-addexercise

  • Committer: William Grant
  • Date: 2009-03-17 07:16:03 UTC
  • Revision ID: grantw@unimelb.edu.au-20090317071603-ux5qxbjkpdarvig3
Tags: 0.1.9.10
ivle.interpret.execute_raw() no longer breaks with lots of data.

Previously we uses subprocess' wait(), which doesn't empty the stdout
pipe. It filled up, causing the child to block. We now use communicate()
instead, which select()s and reads the pipes to unblock things.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import os, sys, traceback
24
24
import xml.dom.minidom as minidom
25
25
 
26
 
from ivle.config import Config
27
26
from ivle.database import Exercise, TestSuite, TestCase, TestSuiteVar, TestCasePart, get_store
28
27
 
29
28
class XMLMalformedError(Exception):
176
175
xmlfile = sys.argv[1]
177
176
 
178
177
def add_exercise(xmlfile):
 
178
    store = get_store()
 
179
 
179
180
    # Skip existing ones.
180
181
    if store.find(Exercise, id=unicode(xmlfile)).count():
181
182
        return
238
239
 
239
240
    store.add(new_exercise)
240
241
    store.commit()
241
 
 
242
 
store = get_store(Config())
243
 
 
 
242
    
244
243
xmlfiles = sys.argv[1:]
245
244
for xmlfile in xmlfiles:
246
245
    try: