X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-images.git/blobdiff_plain/dae40f489ab05411376b3013ec3c5f840d24b570..8220866fdbb2360716e1635dfc1bf9cc721c78f1:/invirt-images diff --git a/invirt-images b/invirt-images index 9d3c695..ea208a5 100755 --- a/invirt-images +++ b/invirt-images @@ -142,7 +142,12 @@ def load_image(cdrom): """ if cdrom.mirror_id is None: return - temp_file = fetch_image(cdrom) + try: + temp_file = fetch_image(cdrom) + except InvirtImageException, e: + print >>sys.stderr, 'ERROR: %s. Skipping.' % e + return + try: st_size = os.stat(temp_file).st_size if not st_size: @@ -186,7 +191,8 @@ def main(): global verbosity database.connect() - + database.session.begin() + usage = """%prog [options] --add [--cdrom] cdrom_id description mirror_id uri_suffix %prog [options] --add --mirror mirror_id uri_prefix @@ -238,8 +244,8 @@ def main(): attrs = dict(zip(('cdrom_id', 'description', 'mirror_id', 'uri_suffix'), args)) cdrom = database.CDROM(**attrs) - database.session.save(cdrom) - database.session.flush() + database.session.add(cdrom) + database.session.commit() load_image(cdrom) @@ -247,8 +253,8 @@ def main(): attrs = dict(zip(('mirror_id', 'uri_prefix'), args)) mirror = database.Mirror(**attrs) - database.session.save(mirror) - database.session.flush() + database.session.add(mirror) + database.session.commit() elif options.action == 'update': if len(args) > 0: images = [database.CDROM.query().get(arg) for arg in args]