VirtualBox

Changeset 28637 in vbox


Ignore:
Timestamp:
Apr 23, 2010 12:14:02 PM (15 years ago)
Author:
vboxsync
Message:

python shell: better progress handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxShell/vboxshell.py

    r28631 r28637  
    225225            p.waitForCompletion(wait)
    226226            ctx['global'].waitForEvents(0)
    227         return 0
     227        return 1
    228228    except KeyboardInterrupt:
    229229        print "Interrupted."
     
    231231            print "Canceling task..."
    232232            p.cancel()
    233         return 1
    234        
    235 
    236 
    237 def reportError(ctx,session,rc):
    238     if not ctx['remote']:
    239             print session.QueryErrorObject(rc)
    240 
     233        return 0
     234
     235def reportError(ctx,progress):
     236    print progress.errorInfo
    241237
    242238def createVm(ctx,name,kind,base):
     
    269265    uuid = mach.id
    270266    progress = vb.openRemoteSession(session, uuid, type, "")
    271     progressBar(ctx, progress, 100)
    272     completed = progress.completed
    273     rc = int(progress.resultCode)
    274     print "Completed:", completed, "rc:",hex(rc&0xffffffff)
    275     if rc == 0:
     267    if progressBar(ctx, progress, 100) and int(progress.resultCode) == 0:
    276268        # we ignore exceptions to allow starting VM even if
    277269        # perf collector cannot be started
     
    286278        session.close()
    287279    else:
    288        reportError(ctx,session,rc)
     280       reportError(ctx,progress)
    289281
    290282def getMachines(ctx, invalidate = False):
     
    398390    print "Teleporting to %s:%d..." %(host,port)
    399391    progress = console.teleport(host, port, passwd, maxDowntime)
    400     progressBar(ctx, progress, 100)
    401     completed = progress.completed
    402     rc = int(progress.resultCode)
    403     if rc == 0:
     392    if progressBar(ctx, progress, 100) and int(progress.resultCode) == 0:
    404393        print "Success!"
    405394    else:
    406         reportError(ctx,session,rc)
     395        reportError(ctx,progress)
    407396
    408397
     
    758747    print "executing %s with %s" %(args[0], args[1:])
    759748    (progress, pid) = console.guest.executeProcess(args[0], 0, args[1:], [], "", "", "", user, passwd, tmo)
    760     print "executed with pid %d" %(pid)
     749    if progressBar(ctx,progress, 10):
     750        print "executed with pid %d" %(pid)
     751    else:
     752        reportError(ctx, progress)
    761753
    762754def gexecCmd(ctx,args):
     
    13011293    desc.addDescription(ctx['global'].constants.VirtualSystemDescriptionType_License, license, "")
    13021294    p = app.write(format, path)
    1303     progressBar(ctx, p)
    1304     if (p.completed and int(p.resultCode) == 0):
     1295    if (progressBar(ctx, p) and int(p.resultCode) == 0):
    13051296        print "Exported to %s in format %s" %(path, format)
     1297    else:
     1298        reportError(ctx,p)
    13061299    return 0
    13071300
     
    15621555   hdd = ctx['vb'].createHardDisk(format, loc)
    15631556   progress = hdd.createBaseStorage(size, ctx['global'].constants.MediumVariant_Standard)
    1564    ctx['progressBar'](progress)
    1565 
    1566    if not hdd.id:
     1557   if progressBar(ctx,progress) and hdd.id:
     1558       print "created HDD at %s as %s" %(hdd.location, hdd.id)
     1559   else:
    15671560      print "cannot create disk (file %s exist?)" %(loc)
    1568       return 0
    1569 
    1570    print "created HDD at %s as %s" %(hdd.location, hdd.id)
     1561      reportError(ctx,progress)
     1562      return 0
    15711563
    15721564   return 0
     
    16841676
    16851677   progress = hdd.deleteStorage()
    1686    ctx['progressBar'](progress)
     1678   progressBar(ctx,progress)
    16871679
    16881680   return 0
     
    17311723
    17321724   progress = dvd.deleteStorage()
    1733    ctx['progressBar'](progress)
    1734    print "Removed ISO at %s" %(dvd.location)
    1735 
     1725   if progressBar(ctx,progress):
     1726       print "Removed ISO at %s" %(dvd.location)
     1727   else:
     1728       reportError(ctx,progress)
    17361729   return 0
    17371730
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette