Changeset 59798 in vbox
- Timestamp:
- Feb 24, 2016 2:35:47 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 22 edited
-
Config.kmk (modified) (1 diff)
-
doc/manual/en_US/SDKRef.xml (modified) (3 diffs)
-
src/VBox/Frontends/VBoxShell/vboxshell.py (modified) (186 diffs)
-
src/VBox/Installer/common/vboxapisetup.py (modified) (2 diffs)
-
src/VBox/Main/glue/vboxapi.py (modified) (3 diffs)
-
src/VBox/Main/webservice/websrv-python.xsl (modified) (17 diffs)
-
src/VBox/ValidationKit/testdriver/vbox.py (modified) (1 diff)
-
src/libs/xpcom18a4/python/Makefile.kmk (modified) (5 diffs)
-
src/libs/xpcom18a4/python/__init__.py (modified) (7 diffs)
-
src/libs/xpcom18a4/python/client/__init__.py (modified) (19 diffs)
-
src/libs/xpcom18a4/python/components.py (modified) (9 diffs)
-
src/libs/xpcom18a4/python/file.py (modified) (8 diffs)
-
src/libs/xpcom18a4/python/gen_python_deps.py (modified) (5 diffs)
-
src/libs/xpcom18a4/python/primitives.py (modified) (1 diff)
-
src/libs/xpcom18a4/python/server/__init__.py (modified) (2 diffs)
-
src/libs/xpcom18a4/python/server/loader.py (modified) (5 diffs)
-
src/libs/xpcom18a4/python/server/module.py (modified) (4 diffs)
-
src/libs/xpcom18a4/python/server/policy.py (modified) (6 diffs)
-
src/libs/xpcom18a4/python/src/PyXPCOM.h (modified) (3 diffs)
-
src/libs/xpcom18a4/python/test/test_test_component.py (modified) (1 diff)
-
src/libs/xpcom18a4/python/vboxxpcom.py (modified) (2 diffs)
-
src/libs/xpcom18a4/python/xpt.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Config.kmk
r59795 r59798 6474 6474 $(MAKE) VBOX_QUICK=1 6475 6475 6476 -
trunk/doc/manual/en_US/SDKRef.xml
r59795 r59798 781 781 <xref linkend="glue-python"/>.</para> 782 782 783 <para>The minimum supported Python version is 2.6.</para> 784 783 785 <para>As indicated in <xref linkend="webservice-or-com"/>, the 784 786 COM/XPCOM API gives better performance without the SOAP overhead, and … … 788 790 platform<footnote> 789 791 <para>On On Mac OS X only the Python versions bundled with the OS 790 are officially supported. This means Python 2.3 for 10.4, Python 791 2.5 for 10.5 and Python 2.5 and 2.6 for 10.6.</para> 792 are officially supported. This means 2.6 and 2.7 for 10.8 and later.</para> 792 793 </footnote>). On Windows, you can use the Main API from Python if the 793 794 Win32 extensions package for Python<footnote> 794 795 <para>See <ulink 795 796 url="http://sourceforge.net/project/showfiles.php?group_id=78018">http://sourceforge.net/project/showfiles.php?group_id=78018</ulink>.</para> 796 </footnote> is installed. Version of Python Win32 extensions earlier797 </footnote> is installed. Versions of Python Win32 extensions earlier 797 798 than 2.16 are known to have bugs, leading to issues with VirtualBox 798 Python bindings, and also some early builds of Python 2.5 for Windows 799 have issues with reporting platform name on some Windows versions, so 800 please make sure to use latest available Python and Win32 801 extensions.</para> 799 Python bindings, so please make sure to use latest available Python 800 and Win32 extensions.</para> 802 801 803 802 <para>The VirtualBox OOWS for Python relies on the Python ZSI SOAP … … 1497 1496 the glue layer if you want to use a different Python 1498 1497 installation.</para> 1498 1499 <para>The minimum supported Python version is 2.6.</para> 1499 1500 1500 1501 <para>In this layer, the class -
trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
r59795 r59798 2 2 # -*- coding: utf-8 -*- 3 3 # $Id$ 4 4 5 """ 5 6 VirtualBox Python Shell. … … 19 20 """ 20 21 22 from __future__ import print_function 23 21 24 __copyright__ = \ 22 25 """ 23 Copyright (C) 2009-201 5Oracle Corporation26 Copyright (C) 2009-2016 Oracle Corporation 24 27 25 28 This file is part of VirtualBox Open Source Edition (OSE), as … … 34 37 35 38 36 import os, sys 39 import os 40 import sys 37 41 import traceback 38 42 import shlex … … 42 46 from optparse import OptionParser 43 47 from pprint import pprint 44 45 48 46 49 … … 152 155 matches.append(word) 153 156 154 except Exception ,e:157 except Exception as e: 155 158 printErr(self.ctx, e) 156 159 if g_fVerbose: … … 164 167 165 168 comps = {} 166 for (key, _value) in cmds.items():169 for (key, _value) in list(cmds.items()): 167 170 comps[key] = None 168 171 completer = CompleterNG(comps, ctx) … … 189 192 try: 190 193 while not progress.completed: 191 print "%s %%\r" % (colored(str(progress.percent), 'red')),194 print("%s %%\r" % (colored(str(progress.percent), 'red')), end="") 192 195 sys.stdout.flush() 193 196 progress.waitForCompletion(wait) … … 197 200 return 1 198 201 except KeyboardInterrupt: 199 print "Interrupted."202 print("Interrupted.") 200 203 ctx['interrupt'] = True 201 204 if progress.cancelable: 202 print "Canceling task..."205 print("Canceling task...") 203 206 progress.cancel() 204 207 return 0 205 208 206 209 def printErr(_ctx, e): 207 oVBoxMgr = _ctx['global'] ;210 oVBoxMgr = _ctx['global'] 208 211 if oVBoxMgr.errIsOurXcptKind(e): 209 print colored('%s: %s' % (oVBoxMgr.xcptToString(e), oVBoxMgr.xcptGetMessage(e)), 'red');210 else: 211 print colored(str(e), 'red')212 print(colored('%s: %s' % (oVBoxMgr.xcptToString(e), oVBoxMgr.xcptGetMessage(e)), 'red')) 213 else: 214 print(colored(str(e), 'red')) 212 215 213 216 def reportError(_ctx, progress): 214 217 errorinfo = progress.errorInfo 215 218 if errorinfo: 216 print colored("Error in module '%s': %s" % (errorinfo.component, errorinfo.text), 'red')219 print(colored("Error in module '%s': %s" % (errorinfo.component, errorinfo.text), 'red')) 217 220 218 221 def colCat(_ctx, strg): … … 241 244 mach = vbox.createMachine("", name, [], kind, "") 242 245 mach.saveSettings() 243 print "created machine with UUID", mach.id246 print("created machine with UUID", mach.id) 244 247 vbox.registerMachine(mach) 245 248 # update cache … … 248 251 def removeVm(ctx, mach): 249 252 uuid = mach.id 250 print "removing machine ", mach.name, "with UUID", uuid253 print("removing machine ", mach.name, "with UUID", uuid) 251 254 cmdClosedVm(ctx, mach, detachVmDevice, ["ALL"]) 252 255 disks = mach.unregister(ctx['global'].constants.CleanupMode_Full) … … 254 257 progress = mach.deleteConfig(disks) 255 258 if progressBar(ctx, progress, 100) and int(progress.resultCode) == 0: 256 print "Success!"259 print("Success!") 257 260 else: 258 261 reportError(ctx, progress) … … 271 274 try: 272 275 perf.setup(['*'], [mach], 10, 15) 273 except Exception ,e:276 except Exception as e: 274 277 printErr(ctx, e) 275 278 if g_fVerbose: … … 324 327 return 325 328 for metric in ctx['perf'].query(["*"], [mach]): 326 print metric['name'], metric['values_as_string']329 print(metric['name'], metric['values_as_string']) 327 330 328 331 def guestExec(ctx, machine, console, cmds): 329 exec cmds332 exec(cmds) 330 333 331 334 def printMouseEvent(_ctx, mev): 332 print "Mouse : mode=%d x=%d y=%d z=%d w=%d buttons=%x" % (mev.mode, mev.x, mev.y, mev.z, mev.w, mev.buttons)335 print("Mouse : mode=%d x=%d y=%d z=%d w=%d buttons=%x" % (mev.mode, mev.x, mev.y, mev.z, mev.w, mev.buttons)) 333 336 334 337 def printKbdEvent(ctx, kev): 335 print "Kbd: ", ctx['global'].getArray(kev, 'scancodes')338 print("Kbd: ", ctx['global'].getArray(kev, 'scancodes')) 336 339 337 340 def printMultiTouchEvent(ctx, mtev): 338 print "MultiTouch : contacts=%d time=%d" % (mtev.contactCount, mtev.scanTime)341 print("MultiTouch : contacts=%d time=%d" % (mtev.contactCount, mtev.scanTime)) 339 342 xPositions = ctx['global'].getArray(mtev, 'xPositions') 340 343 yPositions = ctx['global'].getArray(mtev, 'yPositions') … … 343 346 344 347 for i in range(0, mtev.contactCount): 345 print " [%d] %d,%d %d %d" % (i, xPositions[i], yPositions[i], contactIds[i], contactFlags[i])348 print(" [%d] %d,%d %d %d" % (i, xPositions[i], yPositions[i], contactIds[i], contactFlags[i])) 346 349 347 350 def monitorSource(ctx, eventSource, active, dur): 348 351 def handleEventImpl(event): 349 352 evtype = event.type 350 print "got event: %s %s" % (str(evtype), asEnumElem(ctx, 'VBoxEventType', evtype))353 print("got event: %s %s" % (str(evtype), asEnumElem(ctx, 'VBoxEventType', evtype))) 351 354 if evtype == ctx['global'].constants.VBoxEventType_OnMachineStateChanged: 352 355 scev = ctx['global'].queryInterface(event, 'IMachineStateChangedEvent') 353 356 if scev: 354 print "machine state event: mach=%s state=%s" % (scev.machineId, scev.state)357 print("machine state event: mach=%s state=%s" % (scev.machineId, scev.state)) 355 358 elif evtype == ctx['global'].constants.VBoxEventType_OnSnapshotTaken: 356 359 stev = ctx['global'].queryInterface(event, 'ISnapshotTakenEvent') 357 360 if stev: 358 print "snapshot taken event: mach=%s snap=%s" % (stev.machineId, stev.snapshotId)361 print("snapshot taken event: mach=%s snap=%s" % (stev.machineId, stev.snapshotId)) 359 362 elif evtype == ctx['global'].constants.VBoxEventType_OnGuestPropertyChanged: 360 363 gpcev = ctx['global'].queryInterface(event, 'IGuestPropertyChangedEvent') 361 364 if gpcev: 362 print "guest property change: name=%s value=%s" % (gpcev.name, gpcev.value)365 print("guest property change: name=%s value=%s" % (gpcev.name, gpcev.value)) 363 366 elif evtype == ctx['global'].constants.VBoxEventType_OnMousePointerShapeChanged: 364 367 psev = ctx['global'].queryInterface(event, 'IMousePointerShapeChangedEvent') … … 366 369 shape = ctx['global'].getArray(psev, 'shape') 367 370 if shape is None: 368 print "pointer shape event - empty shape"371 print("pointer shape event - empty shape") 369 372 else: 370 print "pointer shape event: w=%d h=%d shape len=%d" % (psev.width, psev.height, len(shape))373 print("pointer shape event: w=%d h=%d shape len=%d" % (psev.width, psev.height, len(shape))) 371 374 elif evtype == ctx['global'].constants.VBoxEventType_OnGuestMouse: 372 375 mev = ctx['global'].queryInterface(event, 'IGuestMouseEvent') … … 441 444 def handleEventImpl(event): 442 445 evtype = event.type 443 #print "got event: %s %s" % (str(evtype), asEnumElem(ctx, 'VBoxEventType', evtype))446 #print("got event: %s %s" % (str(evtype), asEnumElem(ctx, 'VBoxEventType', evtype))) 444 447 if evtype == ctx['global'].constants.VBoxEventType_OnGuestMouse: 445 448 mev = ctx['global'].queryInterface(event, 'IGuestMouseEvent') … … 489 492 490 493 header = demo.readline() 491 print "Header is", header494 print("Header is", header) 492 495 basere = re.compile(r'(?P<s>\d+): (?P<t>[km]) (?P<p>.*)') 493 496 mre = re.compile(r'(?P<a>\d+) (?P<x>-*\d+) (?P<y>-*\d+) (?P<z>-*\d+) (?P<w>-*\d+) (?P<b>-*\d+)') … … 515 518 if rtype == 'k': 516 519 codes = kre.findall(params) 517 #print "KBD:", codes520 #print("KBD:", codes) 518 521 kbd.putScancodes(codes) 519 522 elif rtype == 'm': … … 523 526 if mdict['a'] == '1': 524 527 # absolute 525 #print "MA: ", mdict['x'], mdict['y'], mdict['z'], mdict['b']528 #print("MA: ", mdict['x'], mdict['y'], mdict['z'], mdict['b']) 526 529 mouse.putMouseEventAbsolute(int(mdict['x']), int(mdict['y']), int(mdict['z']), int(mdict['w']), int(mdict['b'])) 527 530 else: 528 #print "MR: ", mdict['x'], mdict['y'], mdict['b']531 #print("MR: ", mdict['x'], mdict['y'], mdict['b']) 529 532 mouse.putMouseEvent(int(mdict['x']), int(mdict['y']), int(mdict['z']), int(mdict['w']), int(mdict['b'])) 530 533 … … 559 562 h = fbh 560 563 561 print "Saving screenshot (%d x %d) screen %d in %s..." % (w, h, screen, f)564 print("Saving screenshot (%d x %d) screen %d in %s..." % (w, h, screen, f)) 562 565 data = display.takeScreenShotToArray(screen, w, h, ctx['const'].BitmapFormat_RGBA) 563 566 size = (w, h) … … 586 589 h = fbh 587 590 588 print "Saving screenshot (%d x %d) screen %d in %s..." % (w, h, screen, f)591 print("Saving screenshot (%d x %d) screen %d in %s..." % (w, h, screen, f)) 589 592 data = display.takeScreenShotToArray(screen, w, h, ctx['const'].BitmapFormat_PNG) 590 593 pngfile = open(f, 'wb') … … 594 597 def teleport(ctx, _session, console, args): 595 598 if args[0].find(":") == -1: 596 print "Use host:port format for teleport target"599 print("Use host:port format for teleport target") 597 600 return 598 601 (host, port) = args[0].split(":") … … 608 611 609 612 port = int(port) 610 print "Teleporting to %s:%d..." % (host, port)613 print("Teleporting to %s:%d..." % (host, port)) 611 614 progress = console.teleport(host, port, passwd, maxDowntime) 612 615 if progressBar(ctx, progress, 100) and int(progress.resultCode) == 0: 613 print "Success!"616 print("Success!") 614 617 else: 615 618 reportError(ctx, progress) … … 632 635 all_stats = ctx['const'].all_values('GuestStatisticType') 633 636 cpu = 0 634 for s in all_stats.keys():637 for s in list(all_stats.keys()): 635 638 try: 636 639 val = guest.getStatistic( cpu, all_stats[s]) 637 print "%s: %d" % (s, val)640 print("%s: %d" % (s, val)) 638 641 except: 639 642 # likely not implemented … … 642 645 def plugCpu(_ctx, machine, _session, args): 643 646 cpu = int(args[0]) 644 print "Adding CPU %d..." % (cpu)647 print("Adding CPU %d..." % (cpu)) 645 648 machine.hotPlugCPU(cpu) 646 649 647 650 def unplugCpu(_ctx, machine, _session, args): 648 651 cpu = int(args[0]) 649 print "Removing CPU %d..." % (cpu)652 print("Removing CPU %d..." % (cpu)) 650 653 machine.hotUnplugCPU(cpu) 651 654 … … 661 664 662 665 def printHostUsbDev(ctx, ud): 663 print " %s: %s (vendorId=%d productId=%d serial=%s) %s" % (ud.id, colored(ud.product, 'blue'), ud.vendorId, ud.productId, ud.serialNumber, asEnumElem(ctx, 'USBDeviceState', ud.state))666 print(" %s: %s (vendorId=%d productId=%d serial=%s) %s" % (ud.id, colored(ud.product, 'blue'), ud.vendorId, ud.productId, ud.serialNumber, asEnumElem(ctx, 'USBDeviceState', ud.state))) 664 667 665 668 def printUsbDev(_ctx, ud): 666 print " %s: %s (vendorId=%d productId=%d serial=%s)" % (ud.id, colored(ud.product, 'blue'), ud.vendorId, ud.productId, ud.serialNumber)669 print(" %s: %s (vendorId=%d productId=%d serial=%s)" % (ud.id, colored(ud.product, 'blue'), ud.vendorId, ud.productId, ud.serialNumber)) 667 670 668 671 def printSf(ctx, sf): 669 print " name=%s host=%s %s %s" % (sf.name, colPath(ctx, sf.hostPath), cond(sf.accessible, "accessible", "not accessible"), cond(sf.writable, "writable", "read-only"))672 print(" name=%s host=%s %s %s" % (sf.name, colPath(ctx, sf.hostPath), cond(sf.accessible, "accessible", "not accessible"), cond(sf.writable, "writable", "read-only"))) 670 673 671 674 def ginfo(ctx, console, _args): 672 675 guest = console.guest 673 676 if guest.additionsRunLevel != ctx['const'].AdditionsRunLevelType_None: 674 print "Additions active, version %s" % (guest.additionsVersion)675 print "Support seamless: %s" % (getFacilityStatus(ctx, guest, ctx['const'].AdditionsFacilityType_Seamless))676 print "Support graphics: %s" % (getFacilityStatus(ctx, guest, ctx['const'].AdditionsFacilityType_Graphics))677 print "Balloon size: %d" % (guest.memoryBalloonSize)678 print "Statistic update interval: %d" % (guest.statisticsUpdateInterval)679 else: 680 print "No additions"677 print("Additions active, version %s" % (guest.additionsVersion)) 678 print("Support seamless: %s" % (getFacilityStatus(ctx, guest, ctx['const'].AdditionsFacilityType_Seamless))) 679 print("Support graphics: %s" % (getFacilityStatus(ctx, guest, ctx['const'].AdditionsFacilityType_Graphics))) 680 print("Balloon size: %d" % (guest.memoryBalloonSize)) 681 print("Statistic update interval: %d" % (guest.statisticsUpdateInterval)) 682 else: 683 print("No additions") 681 684 usbs = ctx['global'].getArray(console, 'USBDevices') 682 print "Attached USB:"685 print("Attached USB:") 683 686 for ud in usbs: 684 687 printUsbDev(ctx, ud) 685 688 rusbs = ctx['global'].getArray(console, 'remoteUSBDevices') 686 print "Remote USB:"689 print("Remote USB:") 687 690 for ud in rusbs: 688 691 printHostUsbDev(ctx, ud) 689 print "Transient shared folders:"692 print("Transient shared folders:") 690 693 sfs = rusbs = ctx['global'].getArray(console, 'sharedFolders') 691 694 for sf in sfs: … … 698 701 session = ctx['global'].getSessionObject(vbox) 699 702 mach.lockMachine(session, ctx['global'].constants.LockType_Shared) 700 except Exception ,e:703 except Exception as e: 701 704 printErr(ctx, "Session to '%s' not open: %s" % (mach.name, str(e))) 702 705 if g_fVerbose: … … 704 707 return 705 708 if session.state != ctx['const'].SessionState_Locked: 706 print "Session to '%s' in wrong state: %s" % (mach.name, session.state)709 print("Session to '%s' in wrong state: %s" % (mach.name, session.state)) 707 710 session.unlockMachine() 708 711 return … … 710 713 # in Webservices) functionality 711 714 if ctx['remote'] and cmd == 'some_local_only_command': 712 print 'Trying to use local only functionality, ignored'715 print('Trying to use local only functionality, ignored') 713 716 session.unlockMachine() 714 717 return … … 734 737 except KeyboardInterrupt: 735 738 ctx['interrupt'] = True 736 except Exception ,e:739 except Exception as e: 737 740 printErr(ctx, e) 738 741 if g_fVerbose: … … 747 750 try: 748 751 cmd(ctx, mach, args) 749 except Exception ,e:752 except Exception as e: 750 753 save = False 751 754 printErr(ctx, e) … … 755 758 try: 756 759 mach.saveSettings() 757 except Exception ,e:760 except Exception as e: 758 761 printErr(ctx, e) 759 762 if g_fVerbose: … … 767 770 try: 768 771 cmd(ctx, mach, session.console, args) 769 except Exception ,e:772 except Exception as e: 770 773 save = False 771 774 printErr(ctx, e) … … 777 780 778 781 def machById(ctx, uuid): 779 try: 780 mach = ctx['vb'].getMachine(uuid) 781 except: 782 mach = ctx['vb'].findMachine(uuid) 782 mach = ctx['vb'].findMachine(uuid) 783 783 return mach 784 784 … … 899 899 def argsToMach(ctx, args): 900 900 if len(args) < 2: 901 print "usage: %s [vmname|uuid]" % (args[0])901 print("usage: %s [vmname|uuid]" % (args[0])) 902 902 return None 903 903 uuid = args[1] 904 904 mach = machById(ctx, uuid) 905 905 if mach == None: 906 print "Machine '%s' is unknown, use list command to find available machines" % (uuid)906 print("Machine '%s' is unknown, use list command to find available machines" % (uuid)) 907 907 return mach 908 908 … … 912 912 else: 913 913 spec = "" 914 print " %s: %s%s" % (colored(cmd, 'blue'), h, spec)914 print(" %s: %s%s" % (colored(cmd, 'blue'), h, spec)) 915 915 916 916 def helpCmd(_ctx, args): 917 917 if len(args) == 1: 918 print "Help page:"919 names = commands.keys()918 print("Help page:") 919 names = list(commands.keys()) 920 920 names.sort() 921 921 for i in names: … … 925 925 c = commands.get(cmd) 926 926 if c == None: 927 print "Command '%s' not known" % (cmd)927 print("Command '%s' not known" % (cmd)) 928 928 else: 929 929 helpSingleCmd(cmd, c[0], c[2]) … … 932 932 def asEnumElem(ctx, enum, elem): 933 933 enumVals = ctx['const'].all_values(enum) 934 for e in enumVals.keys():934 for e in list(enumVals.keys()): 935 935 if str(elem) == str(enumVals[e]): 936 936 return colored(e, 'green') … … 948 948 else: 949 949 tele = " " 950 print "%sMachine '%s' [%s], machineState=%s, sessionState=%s" % (tele, colVm(ctx, mach.name), mach.id, asEnumElem(ctx, "MachineState", mach.state), asEnumElem(ctx, "SessionState", mach.sessionState))951 except Exception ,e:950 print("%sMachine '%s' [%s], machineState=%s, sessionState=%s" % (tele, colVm(ctx, mach.name), mach.id, asEnumElem(ctx, "MachineState", mach.state), asEnumElem(ctx, "SessionState", mach.sessionState))) 951 except Exception as e: 952 952 printErr(ctx, e) 953 953 if g_fVerbose: … … 956 956 957 957 def infoCmd(ctx, args): 958 if (len(args) < 2):959 print "usage: info [vmname|uuid]"958 if len(args) < 2: 959 print("usage: info [vmname|uuid]") 960 960 return 0 961 961 mach = argsToMach(ctx, args) … … 963 963 return 0 964 964 vmos = ctx['vb'].getGuestOSType(mach.OSTypeId) 965 print " One can use setvar <mach> <var> <value> to change variable, using name in []."966 print " Name [name]: %s" % (colVm(ctx, mach.name))967 print " Description [description]: %s" % (mach.description)968 print " ID [n/a]: %s" % (mach.id)969 print " OS Type [via OSTypeId]: %s" % (vmos.description)970 print " Firmware [firmwareType]: %s (%s)" % (asEnumElem(ctx, "FirmwareType", mach.firmwareType), mach.firmwareType)971 print 972 print " CPUs [CPUCount]: %d" % (mach.CPUCount)973 print " RAM [memorySize]: %dM" % (mach.memorySize)974 print " VRAM [VRAMSize]: %dM" % (mach.VRAMSize)975 print " Monitors [monitorCount]: %d" % (mach.monitorCount)976 print " Chipset [chipsetType]: %s (%s)" % (asEnumElem(ctx, "ChipsetType", mach.chipsetType), mach.chipsetType)977 print 978 print " Clipboard mode [clipboardMode]: %s (%s)" % (asEnumElem(ctx, "ClipboardMode", mach.clipboardMode), mach.clipboardMode)979 print " Machine status [n/a]: %s (%s)" % (asEnumElem(ctx, "SessionState", mach.sessionState), mach.sessionState)980 print 965 print(" One can use setvar <mach> <var> <value> to change variable, using name in [].") 966 print(" Name [name]: %s" % (colVm(ctx, mach.name))) 967 print(" Description [description]: %s" % (mach.description)) 968 print(" ID [n/a]: %s" % (mach.id)) 969 print(" OS Type [via OSTypeId]: %s" % (vmos.description)) 970 print(" Firmware [firmwareType]: %s (%s)" % (asEnumElem(ctx, "FirmwareType", mach.firmwareType), mach.firmwareType)) 971 print() 972 print(" CPUs [CPUCount]: %d" % (mach.CPUCount)) 973 print(" RAM [memorySize]: %dM" % (mach.memorySize)) 974 print(" VRAM [VRAMSize]: %dM" % (mach.VRAMSize)) 975 print(" Monitors [monitorCount]: %d" % (mach.monitorCount)) 976 print(" Chipset [chipsetType]: %s (%s)" % (asEnumElem(ctx, "ChipsetType", mach.chipsetType), mach.chipsetType)) 977 print() 978 print(" Clipboard mode [clipboardMode]: %s (%s)" % (asEnumElem(ctx, "ClipboardMode", mach.clipboardMode), mach.clipboardMode)) 979 print(" Machine status [n/a]: %s (%s)" % (asEnumElem(ctx, "SessionState", mach.sessionState), mach.sessionState)) 980 print() 981 981 if mach.teleporterEnabled: 982 print " Teleport target on port %d (%s)" % (mach.teleporterPort, mach.teleporterPassword)983 print 982 print(" Teleport target on port %d (%s)" % (mach.teleporterPort, mach.teleporterPassword)) 983 print() 984 984 bios = mach.BIOSSettings 985 print " ACPI [BIOSSettings.ACPIEnabled]: %s" % (asState(bios.ACPIEnabled))986 print " APIC [BIOSSettings.IOAPICEnabled]: %s" % (asState(bios.IOAPICEnabled))985 print(" ACPI [BIOSSettings.ACPIEnabled]: %s" % (asState(bios.ACPIEnabled))) 986 print(" APIC [BIOSSettings.IOAPICEnabled]: %s" % (asState(bios.IOAPICEnabled))) 987 987 hwVirtEnabled = mach.getHWVirtExProperty(ctx['global'].constants.HWVirtExPropertyType_Enabled) 988 print " Hardware virtualization [guest win machine.setHWVirtExProperty(ctx[\\'const\\'].HWVirtExPropertyType_Enabled, value)]: " + asState(hwVirtEnabled)988 print(" Hardware virtualization [guest win machine.setHWVirtExProperty(ctx[\\'const\\'].HWVirtExPropertyType_Enabled, value)]: " + asState(hwVirtEnabled)) 989 989 hwVirtVPID = mach.getHWVirtExProperty(ctx['const'].HWVirtExPropertyType_VPID) 990 print " VPID support [guest win machine.setHWVirtExProperty(ctx[\\'const\\'].HWVirtExPropertyType_VPID, value)]: " + asState(hwVirtVPID)990 print(" VPID support [guest win machine.setHWVirtExProperty(ctx[\\'const\\'].HWVirtExPropertyType_VPID, value)]: " + asState(hwVirtVPID)) 991 991 hwVirtNestedPaging = mach.getHWVirtExProperty(ctx['const'].HWVirtExPropertyType_NestedPaging) 992 print " Nested paging [guest win machine.setHWVirtExProperty(ctx[\\'const\\'].HWVirtExPropertyType_NestedPaging, value)]: " + asState(hwVirtNestedPaging)993 994 print " Hardware 3d acceleration [accelerate3DEnabled]: " + asState(mach.accelerate3DEnabled)995 print " Hardware 2d video acceleration [accelerate2DVideoEnabled]: " + asState(mach.accelerate2DVideoEnabled)996 997 print " Use universal time [RTCUseUTC]: %s" % (asState(mach.RTCUseUTC))998 print " HPET [HPETEnabled]: %s" % (asState(mach.HPETEnabled))992 print(" Nested paging [guest win machine.setHWVirtExProperty(ctx[\\'const\\'].HWVirtExPropertyType_NestedPaging, value)]: " + asState(hwVirtNestedPaging)) 993 994 print(" Hardware 3d acceleration [accelerate3DEnabled]: " + asState(mach.accelerate3DEnabled)) 995 print(" Hardware 2d video acceleration [accelerate2DVideoEnabled]: " + asState(mach.accelerate2DVideoEnabled)) 996 997 print(" Use universal time [RTCUseUTC]: %s" % (asState(mach.RTCUseUTC))) 998 print(" HPET [HPETEnabled]: %s" % (asState(mach.HPETEnabled))) 999 999 if mach.audioAdapter.enabled: 1000 print " Audio [via audioAdapter]: chip %s; host driver %s" % (asEnumElem(ctx, "AudioControllerType", mach.audioAdapter.audioController), asEnumElem(ctx, "AudioDriverType", mach.audioAdapter.audioDriver))1001 print " CPU hotplugging [CPUHotPlugEnabled]: %s" % (asState(mach.CPUHotPlugEnabled))1002 1003 print " Keyboard [keyboardHIDType]: %s (%s)" % (asEnumElem(ctx, "KeyboardHIDType", mach.keyboardHIDType), mach.keyboardHIDType)1004 print " Pointing device [pointingHIDType]: %s (%s)" % (asEnumElem(ctx, "PointingHIDType", mach.pointingHIDType), mach.pointingHIDType)1005 print " Last changed [n/a]: " + time.asctime(time.localtime(long(mach.lastStateChange)/1000))1000 print(" Audio [via audioAdapter]: chip %s; host driver %s" % (asEnumElem(ctx, "AudioControllerType", mach.audioAdapter.audioController), asEnumElem(ctx, "AudioDriverType", mach.audioAdapter.audioDriver))) 1001 print(" CPU hotplugging [CPUHotPlugEnabled]: %s" % (asState(mach.CPUHotPlugEnabled))) 1002 1003 print(" Keyboard [keyboardHIDType]: %s (%s)" % (asEnumElem(ctx, "KeyboardHIDType", mach.keyboardHIDType), mach.keyboardHIDType)) 1004 print(" Pointing device [pointingHIDType]: %s (%s)" % (asEnumElem(ctx, "PointingHIDType", mach.pointingHIDType), mach.pointingHIDType)) 1005 print(" Last changed [n/a]: " + time.asctime(time.localtime(mach.lastStateChange/1000))) 1006 1006 # OSE has no VRDE 1007 1007 try: 1008 print " VRDE server [VRDEServer.enabled]: %s" % (asState(mach.VRDEServer.enabled))1008 print(" VRDE server [VRDEServer.enabled]: %s" % (asState(mach.VRDEServer.enabled))) 1009 1009 except: 1010 1010 pass 1011 1011 1012 print 1013 print colCat(ctx, " USB Controllers:")1012 print() 1013 print(colCat(ctx, " USB Controllers:")) 1014 1014 for oUsbCtrl in ctx['global'].getArray(mach, 'USBControllers'): 1015 print " '%s': type %s standard: %#x" \1016 % (oUsbCtrl.name, asEnumElem(ctx, "USBControllerType", oUsbCtrl.type), oUsbCtrl.USBStandard) ;1017 1018 print 1019 print colCat(ctx, " I/O subsystem info:")1020 print " Cache enabled [IOCacheEnabled]: %s" % (asState(mach.IOCacheEnabled))1021 print " Cache size [IOCacheSize]: %dM" % (mach.IOCacheSize)1015 print(" '%s': type %s standard: %#x" \ 1016 % (oUsbCtrl.name, asEnumElem(ctx, "USBControllerType", oUsbCtrl.type), oUsbCtrl.USBStandard)) 1017 1018 print() 1019 print(colCat(ctx, " I/O subsystem info:")) 1020 print(" Cache enabled [IOCacheEnabled]: %s" % (asState(mach.IOCacheEnabled))) 1021 print(" Cache size [IOCacheSize]: %dM" % (mach.IOCacheSize)) 1022 1022 1023 1023 controllers = ctx['global'].getArray(mach, 'storageControllers') 1024 1024 if controllers: 1025 print 1026 print colCat(ctx, " Storage Controllers:")1025 print() 1026 print(colCat(ctx, " Storage Controllers:")) 1027 1027 for controller in controllers: 1028 print " '%s': bus %s type %s" % (controller.name, asEnumElem(ctx, "StorageBus", controller.bus), asEnumElem(ctx, "StorageControllerType", controller.controllerType))1028 print(" '%s': bus %s type %s" % (controller.name, asEnumElem(ctx, "StorageBus", controller.bus), asEnumElem(ctx, "StorageControllerType", controller.controllerType))) 1029 1029 1030 1030 attaches = ctx['global'].getArray(mach, 'mediumAttachments') 1031 1031 if attaches: 1032 print 1033 print colCat(ctx, " Media:")1032 print() 1033 print(colCat(ctx, " Media:")) 1034 1034 for a in attaches: 1035 print " Controller: '%s' port/device: %d:%d type: %s (%s):" % (a.controller, a.port, a.device, asEnumElem(ctx, "DeviceType", a.type), a.type)1035 print(" Controller: '%s' port/device: %d:%d type: %s (%s):" % (a.controller, a.port, a.device, asEnumElem(ctx, "DeviceType", a.type), a.type)) 1036 1036 medium = a.medium 1037 1037 if a.type == ctx['global'].constants.DeviceType_HardDisk: 1038 print " HDD:"1039 print " Id: %s" % (medium.id)1040 print " Location: %s" % (colPath(ctx, medium.location))1041 print " Name: %s" % (medium.name)1042 print " Format: %s" % (medium.format)1038 print(" HDD:") 1039 print(" Id: %s" % (medium.id)) 1040 print(" Location: %s" % (colPath(ctx, medium.location))) 1041 print(" Name: %s" % (medium.name)) 1042 print(" Format: %s" % (medium.format)) 1043 1043 1044 1044 if a.type == ctx['global'].constants.DeviceType_DVD: 1045 print " DVD:"1045 print(" DVD:") 1046 1046 if medium: 1047 print " Id: %s" % (medium.id)1048 print " Name: %s" % (medium.name)1047 print(" Id: %s" % (medium.id)) 1048 print(" Name: %s" % (medium.name)) 1049 1049 if medium.hostDrive: 1050 print " Host DVD %s" % (colPath(ctx, medium.location))1050 print(" Host DVD %s" % (colPath(ctx, medium.location))) 1051 1051 if a.passthrough: 1052 print " [passthrough mode]"1052 print(" [passthrough mode]") 1053 1053 else: 1054 print " Virtual image at %s" % (colPath(ctx, medium.location))1055 print " Size: %s" % (medium.size)1054 print(" Virtual image at %s" % (colPath(ctx, medium.location))) 1055 print(" Size: %s" % (medium.size)) 1056 1056 1057 1057 if a.type == ctx['global'].constants.DeviceType_Floppy: 1058 print " Floppy:"1058 print(" Floppy:") 1059 1059 if medium: 1060 print " Id: %s" % (medium.id)1061 print " Name: %s" % (medium.name)1060 print(" Id: %s" % (medium.id)) 1061 print(" Name: %s" % (medium.name)) 1062 1062 if medium.hostDrive: 1063 print " Host floppy %s" % (colPath(ctx, medium.location))1063 print(" Host floppy %s" % (colPath(ctx, medium.location))) 1064 1064 else: 1065 print " Virtual image at %s" % (colPath(ctx, medium.location))1066 print " Size: %s" % (medium.size)1067 1068 print 1069 print colCat(ctx, " Shared folders:")1065 print(" Virtual image at %s" % (colPath(ctx, medium.location))) 1066 print(" Size: %s" % (medium.size)) 1067 1068 print() 1069 print(colCat(ctx, " Shared folders:")) 1070 1070 for sf in ctx['global'].getArray(mach, 'sharedFolders'): 1071 1071 printSf(ctx, sf) … … 1075 1075 def startCmd(ctx, args): 1076 1076 if len(args) < 2: 1077 print "usage: start name <frontend>"1077 print("usage: start name <frontend>") 1078 1078 return 0 1079 1079 mach = argsToMach(ctx, args) … … 1088 1088 1089 1089 def createVmCmd(ctx, args): 1090 if (len(args) != 3):1091 print "usage: createvm name ostype"1090 if len(args) != 3: 1091 print("usage: createvm name ostype") 1092 1092 return 0 1093 1093 name = args[1] … … 1096 1096 ctx['vb'].getGuestOSType(oskind) 1097 1097 except Exception: 1098 print 'Unknown OS type:', oskind1098 print('Unknown OS type:', oskind) 1099 1099 return 0 1100 1100 createVm(ctx, name, oskind) … … 1102 1102 1103 1103 def ginfoCmd(ctx, args): 1104 if (len(args) < 2):1105 print "usage: ginfo [vmname|uuid]"1104 if len(args) < 2: 1105 print("usage: ginfo [vmname|uuid]") 1106 1106 return 0 1107 1107 mach = argsToMach(ctx, args) … … 1113 1113 def execInGuest(ctx, console, args, env, user, passwd, tmo, inputPipe=None, outputPipe=None): 1114 1114 if len(args) < 1: 1115 print "exec in guest needs at least program name"1115 print("exec in guest needs at least program name") 1116 1116 return 1117 1117 guest = console.guest … … 1119 1119 # shall contain program name as argv[0] 1120 1120 gargs = args 1121 print "executing %s with args %s as %s" % (args[0], gargs, user)1121 print("executing %s with args %s as %s" % (args[0], gargs, user)) 1122 1122 flags = 0 1123 1123 if inputPipe is not None: 1124 1124 flags = 1 # set WaitForProcessStartOnly 1125 print args[0]1125 print(args[0]) 1126 1126 process = guestSession.processCreate(args[0], gargs, env, [], tmo) 1127 print "executed with pid %d" % (process.PID)1127 print("executed with pid %d" % (process.PID)) 1128 1128 if pid != 0: 1129 1129 try: … … 1161 1161 1162 1162 except KeyboardInterrupt: 1163 print "Interrupted."1163 print("Interrupted.") 1164 1164 ctx['interrupt'] = True 1165 1165 if progress.cancelable: 1166 1166 progress.cancel() 1167 1167 (_reason, code, _flags) = guest.getProcessStatus(pid) 1168 print "Exit code: %d" % (code)1168 print("Exit code: %d" % (code)) 1169 1169 return 0 1170 1170 else: … … 1175 1175 dst = args[1] 1176 1176 flags = 0 1177 print "Copying host %s to guest %s" % (src, dst)1177 print("Copying host %s to guest %s" % (src, dst)) 1178 1178 progress = console.guest.copyToGuest(src, dst, user, passwd, flags) 1179 1179 progressBar(ctx, progress) … … 1196 1196 user = getpass.getuser() 1197 1197 user_inp = nh_raw_input("User (%s): " % (user)) 1198 if len (user_inp) > 0:1198 if len(user_inp) > 0: 1199 1199 user = user_inp 1200 1200 passwd = getpass.getpass() … … 1203 1203 1204 1204 def gexecCmd(ctx, args): 1205 if (len(args) < 2):1206 print "usage: gexec [vmname|uuid] command args"1205 if len(args) < 2: 1206 print("usage: gexec [vmname|uuid] command args") 1207 1207 return 0 1208 1208 mach = argsToMach(ctx, args) … … 1217 1217 1218 1218 def gcopyCmd(ctx, args): 1219 if (len(args) < 2):1220 print "usage: gcopy [vmname|uuid] host_path guest_path"1219 if len(args) < 2: 1220 print("usage: gcopy [vmname|uuid] host_path guest_path") 1221 1221 return 0 1222 1222 mach = argsToMach(ctx, args) … … 1236 1236 1237 1237 def gpipeCmd(ctx, args): 1238 if (len(args) < 4):1239 print "usage: gpipe [vmname|uuid] hostProgram guestProgram, such as gpipe linux '/bin/uname -a' '/bin/sh -c \"/usr/bin/tee; /bin/uname -a\"'"1238 if len(args) < 4: 1239 print("usage: gpipe [vmname|uuid] hostProgram guestProgram, such as gpipe linux '/bin/uname -a' '/bin/sh -c \"/usr/bin/tee; /bin/uname -a\"'") 1240 1240 return 0 1241 1241 mach = argsToMach(ctx, args) … … 1309 1309 1310 1310 def guestCmd(ctx, args): 1311 if (len(args) < 3):1312 print "usage: guest name commands"1311 if len(args) < 3: 1312 print("usage: guest name commands") 1313 1313 return 0 1314 1314 mach = argsToMach(ctx, args) … … 1322 1322 1323 1323 def screenshotCmd(ctx, args): 1324 if (len(args) < 2):1325 print "usage: screenshot vm <file> <width> <height> <monitor>"1324 if len(args) < 2: 1325 print("usage: screenshot vm <file> <width> <height> <monitor>") 1326 1326 return 0 1327 1327 mach = argsToMach(ctx, args) … … 1332 1332 1333 1333 def teleportCmd(ctx, args): 1334 if (len(args) < 3):1335 print "usage: teleport name host:port <password>"1334 if len(args) < 3: 1335 print("usage: teleport name host:port <password>") 1336 1336 return 0 1337 1337 mach = argsToMach(ctx, args) … … 1351 1351 1352 1352 def openportalCmd(ctx, args): 1353 if (len(args) < 3):1354 print "usage: openportal name port <password>"1353 if len(args) < 3: 1354 print("usage: openportal name port <password>") 1355 1355 return 0 1356 1356 mach = argsToMach(ctx, args) … … 1358 1358 return 0 1359 1359 port = int(args[2]) 1360 if (len(args) > 3):1360 if len(args) > 3: 1361 1361 passwd = args[3] 1362 1362 else: … … 1368 1368 1369 1369 def closeportalCmd(ctx, args): 1370 if (len(args) < 2):1371 print "usage: closeportal name"1370 if len(args) < 2: 1371 print("usage: closeportal name") 1372 1372 return 0 1373 1373 mach = argsToMach(ctx, args) … … 1379 1379 1380 1380 def gueststatsCmd(ctx, args): 1381 if (len(args) < 2):1382 print "usage: gueststats name <check interval>"1381 if len(args) < 2: 1382 print("usage: gueststats name <check interval>") 1383 1383 return 0 1384 1384 mach = argsToMach(ctx, args) … … 1392 1392 cpu = args[1] 1393 1393 if plug: 1394 print "Adding CPU %d..." % (cpu)1394 print("Adding CPU %d..." % (cpu)) 1395 1395 mach.hotPlugCPU(cpu) 1396 1396 else: 1397 print "Removing CPU %d..." % (cpu)1397 print("Removing CPU %d..." % (cpu)) 1398 1398 mach.hotUnplugCPU(cpu) 1399 1399 1400 1400 def plugcpuCmd(ctx, args): 1401 if (len(args) < 2):1402 print "usage: plugcpu name cpuid"1401 if len(args) < 2: 1402 print("usage: plugcpu name cpuid") 1403 1403 return 0 1404 1404 mach = argsToMach(ctx, args) … … 1413 1413 1414 1414 def unplugcpuCmd(ctx, args): 1415 if (len(args) < 2):1416 print "usage: unplugcpu name cpuid"1415 if len(args) < 2: 1416 print("usage: unplugcpu name cpuid") 1417 1417 return 0 1418 1418 mach = argsToMach(ctx, args) … … 1428 1428 def setvar(_ctx, _mach, args): 1429 1429 expr = 'mach.'+args[0]+' = '+args[1] 1430 print "Executing", expr1431 exec expr1430 print("Executing", expr) 1431 exec(expr) 1432 1432 1433 1433 def setvarCmd(ctx, args): 1434 if (len(args) < 4):1435 print "usage: setvar [vmname|uuid] expr value"1434 if len(args) < 4: 1435 print("usage: setvar [vmname|uuid] expr value") 1436 1436 return 0 1437 1437 mach = argsToMach(ctx, args) … … 1444 1444 key = args[0] 1445 1445 value = args[1] 1446 print "%s: setting %s to %s" % (mach.name, key, value if value else None)1446 print("%s: setting %s to %s" % (mach.name, key, value if value else None)) 1447 1447 mach.setExtraData(key, value) 1448 1448 1449 1449 def setExtraDataCmd(ctx, args): 1450 if (len(args) < 3):1451 print "usage: setextra [vmname|uuid|global] key <value>"1450 if len(args) < 3: 1451 print("usage: setextra [vmname|uuid|global] key <value>") 1452 1452 return 0 1453 1453 key = args[2] … … 1467 1467 1468 1468 def printExtraKey(obj, key, value): 1469 print "%s: '%s' = '%s'" % (obj, key, value)1469 print("%s: '%s' = '%s'" % (obj, key, value)) 1470 1470 1471 1471 def getExtraDataCmd(ctx, args): 1472 if (len(args) < 2):1473 print "usage: getextra [vmname|uuid|global] <key>"1472 if len(args) < 2: 1473 print("usage: getextra [vmname|uuid|global] <key>") 1474 1474 return 0 1475 1475 if len(args) == 3: … … 1498 1498 1499 1499 def aliasCmd(ctx, args): 1500 if (len(args) == 3):1500 if len(args) == 3: 1501 1501 aliases[args[1]] = args[2] 1502 1502 return 0 1503 1503 1504 for (key, value) in aliases.items():1505 print "'%s' is an alias for '%s'" % (key, value)1504 for (key, value) in list(aliases.items()): 1505 print("'%s' is an alias for '%s'" % (key, value)) 1506 1506 return 0 1507 1507 1508 1508 def verboseCmd(ctx, args): 1509 1509 global g_fVerbose 1510 if (len(args) > 1):1510 if len(args) > 1: 1511 1511 g_fVerbose = (args[1]=='on') 1512 1512 else: … … 1516 1516 def colorsCmd(ctx, args): 1517 1517 global g_fHasColors 1518 if (len(args) > 1):1518 if len(args) > 1: 1519 1519 g_fHasColors = (args[1] == 'on') 1520 1520 else: … … 1525 1525 vbox = ctx['vb'] 1526 1526 try: 1527 print "VirtualBox version %s" % (colored(vbox.version, 'blue'))1528 except Exception ,e:1527 print("VirtualBox version %s" % (colored(vbox.version, 'blue'))) 1528 except Exception as e: 1529 1529 printErr(ctx, e) 1530 1530 if g_fVerbose: 1531 1531 traceback.print_exc() 1532 1532 props = vbox.systemProperties 1533 print "Machines: %s" % (colPath(ctx, props.defaultMachineFolder))1534 1535 #print "Global shared folders:"1533 print("Machines: %s" % (colPath(ctx, props.defaultMachineFolder))) 1534 1535 #print("Global shared folders:") 1536 1536 #for ud in ctx['global'].getArray(vbox, 'sharedFolders'): 1537 1537 # printSf(ctx, sf) 1538 1538 host = vbox.host 1539 1539 cnt = host.processorCount 1540 print colCat(ctx, "Processors:")1541 print " available/online: %d/%d " % (cnt, host.processorOnlineCount)1540 print(colCat(ctx, "Processors:")) 1541 print(" available/online: %d/%d " % (cnt, host.processorOnlineCount)) 1542 1542 for i in range(0, cnt): 1543 print " processor #%d speed: %dMHz %s" % (i, host.getProcessorSpeed(i), host.getProcessorDescription(i))1544 1545 print colCat(ctx, "RAM:")1546 print " %dM (free %dM)" % (host.memorySize, host.memoryAvailable)1547 print colCat(ctx, "OS:")1548 print " %s (%s)" % (host.operatingSystem, host.OSVersion)1543 print(" processor #%d speed: %dMHz %s" % (i, host.getProcessorSpeed(i), host.getProcessorDescription(i))) 1544 1545 print(colCat(ctx, "RAM:")) 1546 print(" %dM (free %dM)" % (host.memorySize, host.memoryAvailable)) 1547 print(colCat(ctx, "OS:")) 1548 print(" %s (%s)" % (host.operatingSystem, host.OSVersion)) 1549 1549 if host.acceleration3DAvailable: 1550 print colCat(ctx, "3D acceleration available")1551 else: 1552 print colCat(ctx, "3D acceleration NOT available")1553 1554 print colCat(ctx, "Network interfaces:")1550 print(colCat(ctx, "3D acceleration available")) 1551 else: 1552 print(colCat(ctx, "3D acceleration NOT available")) 1553 1554 print(colCat(ctx, "Network interfaces:")) 1555 1555 for ni in ctx['global'].getArray(host, 'networkInterfaces'): 1556 print " %s (%s)" % (ni.name, ni.IPAddress)1557 1558 print colCat(ctx, "DVD drives:")1556 print(" %s (%s)" % (ni.name, ni.IPAddress)) 1557 1558 print(colCat(ctx, "DVD drives:")) 1559 1559 for dd in ctx['global'].getArray(host, 'DVDDrives'): 1560 print " %s - %s" % (dd.name, dd.description)1561 1562 print colCat(ctx, "Floppy drives:")1560 print(" %s - %s" % (dd.name, dd.description)) 1561 1562 print(colCat(ctx, "Floppy drives:")) 1563 1563 for dd in ctx['global'].getArray(host, 'floppyDrives'): 1564 print " %s - %s" % (dd.name, dd.description)1565 1566 print colCat(ctx, "USB devices:")1564 print(" %s - %s" % (dd.name, dd.description)) 1565 1566 print(colCat(ctx, "USB devices:")) 1567 1567 for ud in ctx['global'].getArray(host, 'USBDevices'): 1568 1568 printHostUsbDev(ctx, ud) … … 1570 1570 if ctx['perf']: 1571 1571 for metric in ctx['perf'].query(["*"], [host]): 1572 print metric['name'], metric['values_as_string']1572 print(metric['name'], metric['values_as_string']) 1573 1573 1574 1574 return 0 1575 1575 1576 1576 def monitorGuestCmd(ctx, args): 1577 if (len(args) < 2):1578 print "usage: monitorGuest name (duration)"1577 if len(args) < 2: 1578 print("usage: monitorGuest name (duration)") 1579 1579 return 0 1580 1580 mach = argsToMach(ctx, args) … … 1589 1589 1590 1590 def monitorGuestKbdCmd(ctx, args): 1591 if (len(args) < 2):1592 print "usage: monitorGuestKbd name (duration)"1591 if len(args) < 2: 1592 print("usage: monitorGuestKbd name (duration)") 1593 1593 return 0 1594 1594 mach = argsToMach(ctx, args) … … 1603 1603 1604 1604 def monitorGuestMouseCmd(ctx, args): 1605 if (len(args) < 2):1606 print "usage: monitorGuestMouse name (duration)"1605 if len(args) < 2: 1606 print("usage: monitorGuestMouse name (duration)") 1607 1607 return 0 1608 1608 mach = argsToMach(ctx, args) … … 1617 1617 1618 1618 def monitorGuestMultiTouchCmd(ctx, args): 1619 if (len(args) < 2):1620 print "usage: monitorGuestMultiTouch name (duration)"1619 if len(args) < 2: 1620 print("usage: monitorGuestMultiTouch name (duration)") 1621 1621 return 0 1622 1622 mach = argsToMach(ctx, args) … … 1631 1631 1632 1632 def monitorVBoxCmd(ctx, args): 1633 if (len(args) > 2):1634 print "usage: monitorVBox (duration)"1633 if len(args) > 2: 1634 print("usage: monitorVBox (duration)") 1635 1635 return 0 1636 1636 dur = 5 … … 1659 1659 1660 1660 def portForwardCmd(ctx, args): 1661 if (len(args) != 5):1662 print "usage: portForward <vm> <adapter> <hostPort> <guestPort>"1661 if len(args) != 5: 1662 print("usage: portForward <vm> <adapter> <hostPort> <guestPort>") 1663 1663 return 0 1664 1664 mach = argsToMach(ctx, args) … … 1690 1690 1691 1691 def showLogCmd(ctx, args): 1692 if (len(args) < 2):1693 print "usage: showLog vm <num>"1692 if len(args) < 2: 1693 print("usage: showLog vm <num>") 1694 1694 return 0 1695 1695 mach = argsToMach(ctx, args) … … 1698 1698 1699 1699 log = 0 1700 if (len(args) > 2):1700 if len(args) > 2: 1701 1701 log = args[2] 1702 1702 … … 1704 1704 while True: 1705 1705 data = mach.readLog(log, uOffset, 4096) 1706 if (len(data) == 0):1706 if len(data) == 0: 1707 1707 break 1708 1708 # print adds either NL or space to chunks not ending with a NL … … 1713 1713 1714 1714 def findLogCmd(ctx, args): 1715 if (len(args) < 3):1716 print "usage: findLog vm pattern <num>"1715 if len(args) < 3: 1716 print("usage: findLog vm pattern <num>") 1717 1717 return 0 1718 1718 mach = argsToMach(ctx, args) … … 1721 1721 1722 1722 log = 0 1723 if (len(args) > 3):1723 if len(args) > 3: 1724 1724 log = args[3] 1725 1725 … … 1729 1729 # to reduce line splits on buffer boundary 1730 1730 data = mach.readLog(log, uOffset, 512*1024) 1731 if (len(data) == 0):1731 if len(data) == 0: 1732 1732 break 1733 1733 d = str(data).split("\n") … … 1737 1737 for mt in match: 1738 1738 s = s.replace(mt, colored(mt, 'red')) 1739 print s1739 print(s) 1740 1740 uOffset += len(data) 1741 1741 … … 1744 1744 1745 1745 def findAssertCmd(ctx, args): 1746 if (len(args) < 2):1747 print "usage: findAssert vm <num>"1746 if len(args) < 2: 1747 print("usage: findAssert vm <num>") 1748 1748 return 0 1749 1749 mach = argsToMach(ctx, args) … … 1752 1752 1753 1753 log = 0 1754 if (len(args) > 2):1754 if len(args) > 2: 1755 1755 log = args[2] 1756 1756 … … 1762 1762 # to reduce line splits on buffer boundary 1763 1763 data = mach.readLog(log, uOffset, 512*1024) 1764 if (len(data) == 0):1764 if len(data) == 0: 1765 1765 break 1766 1766 d = str(data).split("\n") 1767 1767 for s in d: 1768 1768 if active: 1769 print s1769 print(s) 1770 1770 if context == 0: 1771 1771 active = False … … 1777 1777 active = True 1778 1778 context = 50 1779 print s1779 print(s) 1780 1780 uOffset += len(data) 1781 1781 … … 1785 1785 expr = ' '.join(args[1:]) 1786 1786 try: 1787 exec expr1788 except Exception ,e:1787 exec(expr) 1788 except Exception as e: 1789 1789 printErr(ctx, e) 1790 1790 if g_fVerbose: … … 1799 1799 1800 1800 def runScriptCmd(ctx, args): 1801 if (len(args) != 2):1802 print "usage: runScript <script>"1801 if len(args) != 2: 1802 print("usage: runScript <script>") 1803 1803 return 0 1804 1804 try: 1805 1805 lf = open(args[1], 'r') 1806 except IOError ,e:1807 print "cannot open:", args[1], ":", e1806 except IOError as e: 1807 print("cannot open:", args[1], ":", e) 1808 1808 return 0 1809 1809 … … 1819 1819 break 1820 1820 1821 except Exception ,e:1821 except Exception as e: 1822 1822 printErr(ctx, e) 1823 1823 if g_fVerbose: … … 1827 1827 1828 1828 def sleepCmd(ctx, args): 1829 if (len(args) != 2):1830 print "usage: sleep <secs>"1829 if len(args) != 2: 1830 print("usage: sleep <secs>") 1831 1831 return 0 1832 1832 … … 1840 1840 1841 1841 def shellCmd(ctx, args): 1842 if (len(args) < 2):1843 print "usage: shell <commands>"1842 if len(args) < 2: 1843 print("usage: shell <commands>") 1844 1844 return 0 1845 1845 cmd = ' '.join(args[1:]) … … 1854 1854 1855 1855 def connectCmd(ctx, args): 1856 if (len(args) > 4):1857 print "usage: connect url <username> <passwd>"1856 if len(args) > 4: 1857 print("usage: connect url <username> <passwd>") 1858 1858 return 0 1859 1859 1860 1860 if ctx['vb'] is not None: 1861 print "Already connected, disconnect first..."1862 return 0 1863 1864 if (len(args) > 1):1861 print("Already connected, disconnect first...") 1862 return 0 1863 1864 if len(args) > 1: 1865 1865 url = args[1] 1866 1866 else: 1867 1867 url = None 1868 1868 1869 if (len(args) > 2):1869 if len(args) > 2: 1870 1870 user = args[2] 1871 1871 else: 1872 1872 user = "" 1873 1873 1874 if (len(args) > 3):1874 if len(args) > 3: 1875 1875 passwd = args[3] 1876 1876 else: … … 1881 1881 ctx['vb'] = vbox 1882 1882 try: 1883 print "Running VirtualBox version %s" % (vbox.version)1884 except Exception ,e:1883 print("Running VirtualBox version %s" % (vbox.version)) 1884 except Exception as e: 1885 1885 printErr(ctx, e) 1886 1886 if g_fVerbose: … … 1890 1890 1891 1891 def disconnectCmd(ctx, args): 1892 if (len(args) != 1):1893 print "usage: disconnect"1892 if len(args) != 1: 1893 print("usage: disconnect") 1894 1894 return 0 1895 1895 1896 1896 if ctx['vb'] is None: 1897 print "Not connected yet."1897 print("Not connected yet.") 1898 1898 return 0 1899 1899 … … 1909 1909 def reconnectCmd(ctx, args): 1910 1910 if ctx['wsinfo'] is None: 1911 print "Never connected..."1911 print("Never connected...") 1912 1912 return 0 1913 1913 … … 1920 1920 ctx['vb'] = ctx['global'].platform.connect(url, user, passwd) 1921 1921 try: 1922 print "Running VirtualBox version %s" % (ctx['vb'].version)1923 except Exception ,e:1922 print("Running VirtualBox version %s" % (ctx['vb'].version)) 1923 except Exception as e: 1924 1924 printErr(ctx, e) 1925 1925 if g_fVerbose: … … 1929 1929 def exportVMCmd(ctx, args): 1930 1930 if len(args) < 3: 1931 print "usage: exportVm <machine> <path> <format> <license>"1931 print("usage: exportVm <machine> <path> <format> <license>") 1932 1932 return 0 1933 1933 mach = argsToMach(ctx, args) … … 1935 1935 return 0 1936 1936 path = args[2] 1937 if (len(args) > 3):1937 if len(args) > 3: 1938 1938 fmt = args[3] 1939 1939 else: 1940 1940 fmt = "ovf-1.0" 1941 if (len(args) > 4):1941 if len(args) > 4: 1942 1942 lic = args[4] 1943 1943 else: … … 1949 1949 progress = app.write(fmt, path) 1950 1950 if (progressBar(ctx, progress) and int(progress.resultCode) == 0): 1951 print "Exported to %s in format %s" % (path, fmt)1951 print("Exported to %s in format %s" % (path, fmt)) 1952 1952 else: 1953 1953 reportError(ctx, progress) … … 2053 2053 extCode = extScancodes.get(ch, []) 2054 2054 if len(extCode) == 0: 2055 print "bad ext", ch2055 print("bad ext", ch) 2056 2056 return extCode 2057 2057 … … 2125 2125 def typeGuestCmd(ctx, args): 2126 2126 if len(args) < 3: 2127 print "usage: typeGuest <machine> <text> <charDelay>"2127 print("usage: typeGuest <machine> <text> <charDelay>") 2128 2128 return 0 2129 2129 mach = argsToMach(ctx, args) … … 2161 2161 verbose = False 2162 2162 hdds = ctx['global'].getArray(ctx['vb'], 'hardDisks') 2163 print colCat(ctx, "Hard disks:")2163 print(colCat(ctx, "Hard disks:")) 2164 2164 for hdd in hdds: 2165 2165 if hdd.state != ctx['global'].constants.MediumState_Created: 2166 2166 hdd.refreshState() 2167 print " %s (%s)%s %s [logical %s]" % (colPath(ctx, hdd.location), hdd.format, optId(verbose, hdd.id), colSizeM(ctx, asSize(hdd.size, True)), colSizeM(ctx, asSize(hdd.logicalSize, True)))2167 print(" %s (%s)%s %s [logical %s]" % (colPath(ctx, hdd.location), hdd.format, optId(verbose, hdd.id), colSizeM(ctx, asSize(hdd.size, True)), colSizeM(ctx, asSize(hdd.logicalSize, True)))) 2168 2168 2169 2169 dvds = ctx['global'].getArray(ctx['vb'], 'DVDImages') 2170 print colCat(ctx, "CD/DVD disks:")2170 print(colCat(ctx, "CD/DVD disks:")) 2171 2171 for dvd in dvds: 2172 2172 if dvd.state != ctx['global'].constants.MediumState_Created: 2173 2173 dvd.refreshState() 2174 print " %s (%s)%s %s" % (colPath(ctx, dvd.location), dvd.format, optId(verbose, dvd.id), colSizeM(ctx, asSize(dvd.size, True)))2174 print(" %s (%s)%s %s" % (colPath(ctx, dvd.location), dvd.format, optId(verbose, dvd.id), colSizeM(ctx, asSize(dvd.size, True)))) 2175 2175 2176 2176 floppys = ctx['global'].getArray(ctx['vb'], 'floppyImages') 2177 print colCat(ctx, "Floppy disks:")2177 print(colCat(ctx, "Floppy disks:")) 2178 2178 for floppy in floppys: 2179 2179 if floppy.state != ctx['global'].constants.MediumState_Created: 2180 2180 floppy.refreshState() 2181 print " %s (%s)%s %s" % (colPath(ctx, floppy.location), floppy.format, optId(verbose, floppy.id), colSizeM(ctx, asSize(floppy.size, True)))2181 print(" %s (%s)%s %s" % (colPath(ctx, floppy.location), floppy.format, optId(verbose, floppy.id), colSizeM(ctx, asSize(floppy.size, True)))) 2182 2182 2183 2183 return 0 2184 2184 2185 2185 def listUsbCmd(ctx, args): 2186 if (len(args) > 1):2187 print "usage: listUsb"2186 if len(args) > 1: 2187 print("usage: listUsb") 2188 2188 return 0 2189 2189 … … 2202 2202 2203 2203 def createHddCmd(ctx, args): 2204 if (len(args) < 3):2205 print "usage: createHdd sizeM location type"2204 if len(args) < 3: 2205 print("usage: createHdd sizeM location type") 2206 2206 return 0 2207 2207 … … 2216 2216 progress = hdd.createBaseStorage(size, (ctx['global'].constants.MediumVariant_Standard, )) 2217 2217 if progressBar(ctx,progress) and hdd.id: 2218 print "created HDD at %s as %s" % (colPath(ctx,hdd.location), hdd.id)2219 else: 2220 print "cannot create disk (file %s exist?)" % (loc)2218 print("created HDD at %s as %s" % (colPath(ctx,hdd.location), hdd.id)) 2219 else: 2220 print("cannot create disk (file %s exist?)" % (loc)) 2221 2221 reportError(ctx,progress) 2222 2222 return 0 … … 2225 2225 2226 2226 def registerHddCmd(ctx, args): 2227 if (len(args) < 2):2228 print "usage: registerHdd location"2227 if len(args) < 2: 2228 print("usage: registerHdd location") 2229 2229 return 0 2230 2230 … … 2236 2236 parentId = "" 2237 2237 hdd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_HardDisk, ctx['global'].constants.AccessMode_ReadWrite, False) 2238 print "registered HDD as %s" % (hdd.id)2238 print("registered HDD as %s" % (hdd.id)) 2239 2239 return 0 2240 2240 … … 2244 2244 2245 2245 def attachHddCmd(ctx, args): 2246 if (len(args) < 3):2247 print "usage: attachHdd vm hdd controller port:slot"2246 if len(args) < 3: 2247 print("usage: attachHdd vm hdd controller port:slot") 2248 2248 return 0 2249 2249 … … 2256 2256 hdd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_HardDisk, ctx['global'].constants.AccessMode_ReadWrite, False) 2257 2257 except: 2258 print "no HDD with path %s registered" % (loc)2258 print("no HDD with path %s registered" % (loc)) 2259 2259 return 0 2260 2260 if len(args) > 3: … … 2279 2279 2280 2280 def detachHddCmd(ctx, args): 2281 if (len(args) < 3):2282 print "usage: detachHdd vm hdd"2281 if len(args) < 3: 2282 print("usage: detachHdd vm hdd") 2283 2283 return 0 2284 2284 … … 2291 2291 hdd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_HardDisk, ctx['global'].constants.AccessMode_ReadWrite, False) 2292 2292 except: 2293 print "no HDD with path %s registered" % (loc)2293 print("no HDD with path %s registered" % (loc)) 2294 2294 return 0 2295 2295 … … 2298 2298 2299 2299 def unregisterHddCmd(ctx, args): 2300 if (len(args) < 2):2301 print "usage: unregisterHdd path <vmunreg>"2300 if len(args) < 2: 2301 print("usage: unregisterHdd path <vmunreg>") 2302 2302 return 0 2303 2303 2304 2304 vbox = ctx['vb'] 2305 2305 loc = args[1] 2306 if (len(args) > 2):2306 if len(args) > 2: 2307 2307 vmunreg = int(args[2]) 2308 2308 else: … … 2311 2311 hdd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_HardDisk, ctx['global'].constants.AccessMode_ReadWrite, False) 2312 2312 except: 2313 print "no HDD with path %s registered" % (loc)2313 print("no HDD with path %s registered" % (loc)) 2314 2314 return 0 2315 2315 … … 2318 2318 try: 2319 2319 for mach in machs: 2320 print "Trying to detach from %s" % (mach)2320 print("Trying to detach from %s" % (mach)) 2321 2321 detachMedium(ctx, mach, hdd) 2322 except Exception ,e:2323 print 'failed: ', e2322 except Exception as e: 2323 print('failed: ', e) 2324 2324 return 0 2325 2325 hdd.close() … … 2327 2327 2328 2328 def removeHddCmd(ctx, args): 2329 if (len(args) != 2):2330 print "usage: removeHdd path"2329 if len(args) != 2: 2330 print("usage: removeHdd path") 2331 2331 return 0 2332 2332 … … 2336 2336 hdd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_HardDisk, ctx['global'].constants.AccessMode_ReadWrite, False) 2337 2337 except: 2338 print "no HDD with path %s registered" % (loc)2338 print("no HDD with path %s registered" % (loc)) 2339 2339 return 0 2340 2340 … … 2345 2345 2346 2346 def registerIsoCmd(ctx, args): 2347 if (len(args) < 2):2348 print "usage: registerIso location"2347 if len(args) < 2: 2348 print("usage: registerIso location") 2349 2349 return 0 2350 2350 … … 2352 2352 loc = args[1] 2353 2353 iso = vbox.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, False) 2354 print "registered ISO as %s" % (iso.id)2354 print("registered ISO as %s" % (iso.id)) 2355 2355 return 0 2356 2356 2357 2357 def unregisterIsoCmd(ctx, args): 2358 if (len(args) != 2):2359 print "usage: unregisterIso path"2358 if len(args) != 2: 2359 print("usage: unregisterIso path") 2360 2360 return 0 2361 2361 … … 2365 2365 dvd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, False) 2366 2366 except: 2367 print "no DVD with path %s registered" % (loc)2367 print("no DVD with path %s registered" % (loc)) 2368 2368 return 0 2369 2369 2370 2370 progress = dvd.close() 2371 print "Unregistered ISO at %s" % (colPath(ctx, loc))2371 print("Unregistered ISO at %s" % (colPath(ctx, loc))) 2372 2372 2373 2373 return 0 2374 2374 2375 2375 def removeIsoCmd(ctx, args): 2376 if (len(args) != 2):2377 print "usage: removeIso path"2376 if len(args) != 2: 2377 print("usage: removeIso path") 2378 2378 return 0 2379 2379 … … 2383 2383 dvd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, False) 2384 2384 except: 2385 print "no DVD with path %s registered" % (loc)2385 print("no DVD with path %s registered" % (loc)) 2386 2386 return 0 2387 2387 2388 2388 progress = dvd.deleteStorage() 2389 2389 if progressBar(ctx, progress): 2390 print "Removed ISO at %s" % (colPath(ctx, dvd.location))2390 print("Removed ISO at %s" % (colPath(ctx, dvd.location))) 2391 2391 else: 2392 2392 reportError(ctx, progress) … … 2394 2394 2395 2395 def attachIsoCmd(ctx, args): 2396 if (len(args) < 3):2397 print "usage: attachIso vm iso controller port:slot"2396 if len(args) < 3: 2397 print("usage: attachIso vm iso controller port:slot") 2398 2398 return 0 2399 2399 … … 2406 2406 dvd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, False) 2407 2407 except: 2408 print "no DVD with path %s registered" % (loc)2408 print("no DVD with path %s registered" % (loc)) 2409 2409 return 0 2410 2410 if len(args) > 3: … … 2417 2417 2418 2418 def detachIsoCmd(ctx, args): 2419 if (len(args) < 3):2420 print "usage: detachIso vm iso"2419 if len(args) < 3: 2420 print("usage: detachIso vm iso") 2421 2421 return 0 2422 2422 … … 2429 2429 dvd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, False) 2430 2430 except: 2431 print "no DVD with path %s registered" % (loc)2431 print("no DVD with path %s registered" % (loc)) 2432 2432 return 0 2433 2433 … … 2436 2436 2437 2437 def mountIsoCmd(ctx, args): 2438 if (len(args) < 3):2439 print "usage: mountIso vm iso controller port:slot"2438 if len(args) < 3: 2439 print("usage: mountIso vm iso controller port:slot") 2440 2440 return 0 2441 2441 … … 2448 2448 dvd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, False) 2449 2449 except: 2450 print "no DVD with path %s registered" % (loc)2450 print("no DVD with path %s registered" % (loc)) 2451 2451 return 0 2452 2452 … … 2463 2463 2464 2464 def unmountIsoCmd(ctx, args): 2465 if (len(args) < 2):2466 print "usage: unmountIso vm controller port:slot"2465 if len(args) < 2: 2466 print("usage: unmountIso vm controller port:slot") 2467 2467 return 0 2468 2468 … … 2490 2490 2491 2491 def attachCtrCmd(ctx, args): 2492 if (len(args) < 4):2493 print "usage: attachCtr vm cname bus <type>"2492 if len(args) < 4: 2493 print("usage: attachCtr vm cname bus <type>") 2494 2494 return 0 2495 2495 … … 2497 2497 ctrltype = enumFromString(ctx, 'StorageControllerType', args[4]) 2498 2498 if ctrltype == None: 2499 print "Controller type %s unknown" % (args[4])2499 print("Controller type %s unknown" % (args[4])) 2500 2500 return 0 2501 2501 else: … … 2507 2507 bus = enumFromString(ctx, 'StorageBus', args[3]) 2508 2508 if bus is None: 2509 print "Bus type %s unknown" % (args[3])2509 print("Bus type %s unknown" % (args[3])) 2510 2510 return 0 2511 2511 name = args[2] … … 2514 2514 2515 2515 def detachCtrCmd(ctx, args): 2516 if (len(args) < 3):2517 print "usage: detachCtr vm name"2516 if len(args) < 3: 2517 print("usage: detachCtr vm name") 2518 2518 return 0 2519 2519 … … 2526 2526 2527 2527 def usbctr(ctx, mach, console, args): 2528 if (args[0]):2528 if args[0]: 2529 2529 console.attachUSBDevice(args[1], "") 2530 2530 else: … … 2532 2532 2533 2533 def attachUsbCmd(ctx, args): 2534 if (len(args) < 3):2535 print "usage: attachUsb vm deviceuid"2534 if len(args) < 3: 2535 print("usage: attachUsb vm deviceuid") 2536 2536 return 0 2537 2537 … … 2544 2544 2545 2545 def detachUsbCmd(ctx, args): 2546 if (len(args) < 3):2547 print "usage: detachUsb vm deviceuid"2546 if len(args) < 3: 2547 print("usage: detachUsb vm deviceuid") 2548 2548 return 0 2549 2549 … … 2557 2557 2558 2558 def guiCmd(ctx, args): 2559 if (len(args) > 1):2560 print "usage: gui"2559 if len(args) > 1: 2560 print("usage: gui") 2561 2561 return 0 2562 2562 … … 2572 2572 2573 2573 def shareFolderCmd(ctx, args): 2574 if (len(args) < 4):2575 print "usage: shareFolder vm path name <writable> <persistent>"2574 if len(args) < 4: 2575 print("usage: shareFolder vm path name <writable> <persistent>") 2576 2576 return 0 2577 2577 … … 2596 2596 2597 2597 def unshareFolderCmd(ctx, args): 2598 if (len(args) < 3):2599 print "usage: unshareFolder vm name"2598 if len(args) < 3: 2599 print("usage: unshareFolder vm name") 2600 2600 return 0 2601 2601 … … 2617 2617 def snapshotCmd(ctx, args): 2618 2618 if (len(args) < 2 or args[1] == 'help'): 2619 print "Take snapshot: snapshot vm take name <description>"2620 print "Restore snapshot: snapshot vm restore name"2621 print "Merge snapshot: snapshot vm merge name"2619 print("Take snapshot: snapshot vm take name <description>") 2620 print("Restore snapshot: snapshot vm restore name") 2621 print("Merge snapshot: snapshot vm merge name") 2622 2622 return 0 2623 2623 … … 2627 2627 cmd = args[2] 2628 2628 if cmd == 'take': 2629 if (len(args) < 4):2630 print "usage: snapshot vm take name <description>"2629 if len(args) < 4: 2630 print("usage: snapshot vm take name <description>") 2631 2631 return 0 2632 2632 name = args[3] 2633 if (len(args) > 4):2633 if len(args) > 4: 2634 2634 desc = args[4] 2635 2635 else: … … 2639 2639 2640 2640 if cmd == 'restore': 2641 if (len(args) < 4):2642 print "usage: snapshot vm restore name"2641 if len(args) < 4: 2642 print("usage: snapshot vm restore name") 2643 2643 return 0 2644 2644 name = args[3] … … 2648 2648 2649 2649 if cmd == 'restorecurrent': 2650 if (len(args) < 4):2651 print "usage: snapshot vm restorecurrent"2650 if len(args) < 4: 2651 print("usage: snapshot vm restorecurrent") 2652 2652 return 0 2653 2653 snap = mach.currentSnapshot() … … 2656 2656 2657 2657 if cmd == 'delete': 2658 if (len(args) < 4):2659 print "usage: snapshot vm delete name"2658 if len(args) < 4: 2659 print("usage: snapshot vm delete name") 2660 2660 return 0 2661 2661 name = args[3] … … 2664 2664 return 0 2665 2665 2666 print "Command '%s' is unknown" % (cmd)2666 print("Command '%s' is unknown" % (cmd)) 2667 2667 return 0 2668 2668 … … 2683 2683 first = 0 2684 2684 msg = '' 2685 for aliasmode, aliaskey in alias.iteritems():2685 for aliasmode, aliaskey in list(alias.items()): 2686 2686 if first == 0: 2687 2687 first = 1 … … 2689 2689 msg += ', ' 2690 2690 if int(nat.aliasMode) & aliaskey: 2691 msg += '% d: %s' % (aliasmode, 'on')2691 msg += '%s: %s' % (aliasmode, 'on') 2692 2692 else: 2693 msg += '%d: %s' % (aliasmode, 'off') 2694 msg += ')' 2693 msg += '%s: %s' % (aliasmode, 'off') 2695 2694 return (0, [msg]) 2696 2695 else: … … 2698 2697 if 'default' not in args: 2699 2698 for a in range(1, len(args)): 2700 if not alias.has_key(args[a]):2701 print 'Invalid alias mode: ' + args[a]2702 print natAlias.__doc__2699 if args[a] not in alias: 2700 print('Invalid alias mode: ' + args[a]) 2701 print(natAlias.__doc__) 2703 2702 return (1, None) 2704 2703 nat.aliasMode = int(nat.aliasMode) | alias[args[a]] … … 2723 2722 else: 2724 2723 if args[1] < 16000: 2725 print 'invalid mtu value (%s not in range [65 - 16000])' % (args[1])2724 print('invalid mtu value (%s not in range [65 - 16000])' % (args[1])) 2726 2725 return (1, None) 2727 2726 for i in range(2, len(args)): 2728 2727 if not args[i].isdigit() or int(args[i]) < 8 or int(args[i]) > 1024: 2729 print 'invalid %s parameter (%i not in range [8-1024])' % (i, args[i])2728 print('invalid %s parameter (%i not in range [8-1024])' % (i, args[i])) 2730 2729 return (1, None) 2731 2730 a = [args[1]] … … 2735 2734 else: 2736 2735 for i in range(2, len(args)): a.append(args[i]) 2737 #print a2736 #print(a) 2738 2737 nat.setNetworkSettings(int(a[0]), int(a[1]), int(a[2]), int(a[3]), int(a[4])) 2739 2738 return (0, None) … … 2786 2785 cmd = args[1] 2787 2786 if len(args) != 3: 2788 print 'invalid args:', args2789 print natTftp.__doc__2787 print('invalid args:', args) 2788 print(natTftp.__doc__) 2790 2789 return (1, None) 2791 2790 if cmd == 'prefix': nat.TFTPPrefix = args[2] … … 2793 2792 elif cmd == 'server': nat.TFTPNextServer = args[2] 2794 2793 else: 2795 print "invalid cmd:", cmd2794 print("invalid cmd:", cmd) 2796 2795 return (1, None) 2797 2796 return (0, None) … … 2818 2817 pfcmd = { 2819 2818 'simple': { 2820 'validate': lambda: args[1] in pfcmd.keys() and args[2] in proto.keys() and len(args) == 5,2819 'validate': lambda: args[1] in list(pfcmd.keys()) and args[2] in list(proto.keys()) and len(args) == 5, 2821 2820 'func':lambda: nat.addRedirect('', proto[args[2]], '', int(args[3]), '', int(args[4])) 2822 2821 }, 2823 2822 'no_name': { 2824 'validate': lambda: args[1] in pfcmd.keys() and args[2] in proto.keys() and len(args) == 7,2823 'validate': lambda: args[1] in list(pfcmd.keys()) and args[2] in list(proto.keys()) and len(args) == 7, 2825 2824 'func': lambda: nat.addRedirect('', proto[args[2]], args[3], int(args[4]), args[5], int(args[6])) 2826 2825 }, 2827 2826 'ex': { 2828 'validate': lambda: args[1] in pfcmd.keys() and args[2] in proto.keys() and len(args) == 8,2827 'validate': lambda: args[1] in list(pfcmd.keys()) and args[2] in list(proto.keys()) and len(args) == 8, 2829 2828 'func': lambda: nat.addRedirect(args[3], proto[args[2]], args[4], int(args[5]), args[6], int(args[7])) 2830 2829 }, … … 2836 2835 2837 2836 if not pfcmd[args[1]]['validate'](): 2838 print 'invalid port-forwarding or args of sub command ', args[1]2839 print natPortForwarding.__doc__2837 print('invalid port-forwarding or args of sub command ', args[1]) 2838 print(natPortForwarding.__doc__) 2840 2839 return (1, None) 2841 2840 … … 2856 2855 (addr, mask) = args[1].split('/') 2857 2856 if addr.count('.') > 3 or int(mask) < 0 or int(mask) > 32: 2858 print 'Invalid arguments'2857 print('Invalid arguments') 2859 2858 return (1, None) 2860 2859 nat.network = args[1] … … 2880 2879 if len(args) < 2 or args[1] == 'help': 2881 2880 if len(args) > 2: 2882 print natcommands[args[2]].__doc__2881 print(natcommands[args[2]].__doc__) 2883 2882 else: 2884 print natCmd.__doc__2883 print(natCmd.__doc__) 2885 2884 return 0 2886 2885 if len(args) == 1 or len(args) < 4 or args[3] not in natcommands: 2887 print natCmd.__doc__2886 print(natCmd.__doc__) 2888 2887 return 0 2889 2888 mach = ctx['argsToMach'](args) 2890 2889 if mach == None: 2891 print "please specify vm"2892 return 0 2893 if len(args) < 3 or not args[2].isdigit() or int(args[2]) not in range(0, ctx['vb'].systemProperties.getMaxNetworkAdapters(mach.chipsetType)):2894 print 'please specify adapter num %d isn\'t in range [0-%d]' % (args[2], ctx['vb'].systemProperties.getMaxNetworkAdapters(mach.chipsetType))2890 print("please specify vm") 2891 return 0 2892 if len(args) < 3 or not args[2].isdigit() or int(args[2]) not in list(range(0, ctx['vb'].systemProperties.getMaxNetworkAdapters(mach.chipsetType))): 2893 print('please specify adapter num %d isn\'t in range [0-%d]' % (args[2], ctx['vb'].systemProperties.getMaxNetworkAdapters(mach.chipsetType))) 2895 2894 return 0 2896 2895 nicnum = int(args[2]) … … 2919 2918 for r in report: 2920 2919 msg ='%s nic%d %s: %s' % (mach.name, nicnum, func, r) 2921 print msg2920 print(msg) 2922 2921 return 0 2923 2922 … … 2930 2929 yesno = {'off' : 0, 'on' : 1} 2931 2930 if args[1] not in yesno: 2932 print '%s isn\'t acceptable, please choose %s' % (args[1], yesno.keys())2931 print('%s isn\'t acceptable, please choose %s' % (args[1], list(yesno.keys()))) 2933 2932 return (1, None) 2934 2933 adapter.__setattr__(attr, yesno[args[1]]) … … 2953 2952 else: 2954 2953 if not args[1].isdigit(): 2955 print '%s isn\'t a number' % (args[1])2956 print(1, None)2954 print('%s isn\'t a number' % (args[1])) 2955 return (1, None) 2957 2956 adapter.lineSpeed = int(args[1]) 2958 2957 return (0, None) … … 2976 2975 if len(args) == 1: 2977 2976 nictypes = ctx['const'].all_values('NetworkAdapterType') 2978 for key in nictypes.keys():2977 for key in list(nictypes.keys()): 2979 2978 if str(adapter.adapterType) == str(nictypes[key]): 2980 2979 return (0, str(key)) … … 2982 2981 else: 2983 2982 nictypes = ctx['const'].all_values('NetworkAdapterType') 2984 if args[1] not in nictypes.keys():2985 print '%s not in acceptable values (%s)' % (args[1], nictypes.keys())2983 if args[1] not in list(nictypes.keys()): 2984 print('%s not in acceptable values (%s)' % (args[1], list(nictypes.keys()))) 2986 2985 return (1, None) 2987 2986 adapter.adapterType = nictypes[args[1]] … … 3002 3001 ctx['global'].constants.NetworkAttachmentType_Generic: ('Generic', ''), 3003 3002 } 3004 import types 3005 if type(adapter.attachmentType) != types.IntType: 3003 if type(adapter.attachmentType) != int: 3006 3004 t = str(adapter.attachmentType) 3007 3005 else: … … 3037 3035 'f': lambda: ctx['global'].constants.NetworkAttachmentType_Generic} 3038 3036 } 3039 if args[1] not in nicAttachmentType.keys():3040 print '%s not in acceptable values (%s)' % (args[1], nicAttachmentType.keys())3037 if args[1] not in list(nicAttachmentType.keys()): 3038 print('%s not in acceptable values (%s)' % (args[1], list(nicAttachmentType.keys()))) 3041 3039 return (1, None) 3042 3040 if not nicAttachmentType[args[1]]['v'](): 3043 print nicAttachmentType.__doc__3041 print(nicAttachmentType.__doc__) 3044 3042 return (1, None) 3045 3043 nicAttachmentType[args[1]]['p']() … … 3067 3065 if len(args) == 3 \ 3068 3066 and args[2] in niccomand: 3069 print niccomand[args[2]].__doc__3067 print(niccomand[args[2]].__doc__) 3070 3068 else: 3071 print nicCmd.__doc__3069 print(nicCmd.__doc__) 3072 3070 return 0 3073 3071 3074 3072 vm = ctx['argsToMach'](args) 3075 3073 if vm is None: 3076 print 'please specify vm'3074 print('please specify vm') 3077 3075 return 0 3078 3076 3079 3077 if len(args) < 3 \ 3080 or int(args[2]) not in range(0, ctx['vb'].systemProperties.getMaxNetworkAdapters(vm.chipsetType)):3081 print 'please specify adapter num %d isn\'t in range [0-%d]'% (args[2], ctx['vb'].systemProperties.getMaxNetworkAdapters(vm.chipsetType))3078 or int(args[2]) not in list(range(0, ctx['vb'].systemProperties.getMaxNetworkAdapters(vm.chipsetType))): 3079 print('please specify adapter num %d isn\'t in range [0-%d]'% (args[2], ctx['vb'].systemProperties.getMaxNetworkAdapters(vm.chipsetType))) 3082 3080 return 0 3083 3081 nicnum = int(args[2]) … … 3092 3090 vm.saveSettings() 3093 3091 if report is not None: 3094 print '%s nic %d %s: %s' % (vm.name, nicnum, args[3], report)3092 print('%s nic %d %s: %s' % (vm.name, nicnum, args[3], report)) 3095 3093 session.unlockMachine() 3096 3094 return 0 … … 3099 3097 def promptCmd(ctx, args): 3100 3098 if len(args) < 2: 3101 print "Current prompt: '%s'" % (ctx['prompt'])3099 print("Current prompt: '%s'" % (ctx['prompt'])) 3102 3100 return 0 3103 3101 … … 3107 3105 def foreachCmd(ctx, args): 3108 3106 if len(args) < 3: 3109 print "usage: foreach scope command, where scope is XPath-like expression //vms/vm[@CPUCount='2']"3107 print("usage: foreach scope command, where scope is XPath-like expression //vms/vm[@CPUCount='2']") 3110 3108 return 0 3111 3109 … … 3117 3115 e.apply(cmd) 3118 3116 except: 3119 print "Error executing"3117 print("Error executing") 3120 3118 traceback.print_exc() 3121 3119 return 0 … … 3123 3121 def foreachvmCmd(ctx, args): 3124 3122 if len(args) < 2: 3125 print "foreachvm command <args>"3123 print("foreachvm command <args>") 3126 3124 return 0 3127 3125 cmdargs = args[1:] … … 3133 3131 3134 3132 def recordDemoCmd(ctx, args): 3135 if (len(args) < 3):3136 print "usage: recordDemo vm filename (duration)"3133 if len(args) < 3: 3134 print("usage: recordDemo vm filename (duration)") 3137 3135 return 0 3138 3136 mach = argsToMach(ctx, args) … … 3147 3145 3148 3146 def playbackDemoCmd(ctx, args): 3149 if (len(args) < 3):3150 print "usage: playbackDemo vm filename (duration)"3147 if len(args) < 3: 3148 print("usage: playbackDemo vm filename (duration)") 3151 3149 return 0 3152 3150 mach = argsToMach(ctx, args) … … 3169 3167 for a in assigned: 3170 3168 if a.isPhysicalDevice: 3171 print "%s: assigned host device %s guest %s" % (colDev(ctx, a.name), pciAddr(ctx, a.hostAddress), pciAddr(ctx, a.guestAddress))3169 print("%s: assigned host device %s guest %s" % (colDev(ctx, a.name), pciAddr(ctx, a.hostAddress), pciAddr(ctx, a.guestAddress))) 3172 3170 3173 3171 atts = ctx['global'].getArray(console, 'attachedPCIDevices') 3174 3172 for a in atts: 3175 3173 if a.isPhysicalDevice: 3176 print "%s: physical, guest %s, host %s" % (colDev(ctx, a.name), pciAddr(ctx, a.guestAddress), pciAddr(ctx, a.hostAddress))3174 print("%s: physical, guest %s, host %s" % (colDev(ctx, a.name), pciAddr(ctx, a.guestAddress), pciAddr(ctx, a.hostAddress))) 3177 3175 else: 3178 print "%s: virtual, guest %s" % (colDev(ctx, a.name), pciAddr(ctx, a.guestAddress))3176 print("%s: virtual, guest %s" % (colDev(ctx, a.name), pciAddr(ctx, a.guestAddress))) 3179 3177 return 3180 3178 … … 3188 3186 3189 3187 def lspciCmd(ctx, args): 3190 if (len(args) < 2):3191 print "usage: lspci vm"3188 if len(args) < 2: 3189 print("usage: lspci vm") 3192 3190 return 0 3193 3191 mach = argsToMach(ctx, args) … … 3198 3196 3199 3197 def attachpciCmd(ctx, args): 3200 if (len(args) < 3):3201 print "usage: attachpci vm hostpci <guestpci>"3198 if len(args) < 3: 3199 print("usage: attachpci vm hostpci <guestpci>") 3202 3200 return 0 3203 3201 mach = argsToMach(ctx, args) … … 3206 3204 hostaddr = parsePci(args[2]) 3207 3205 if hostaddr == -1: 3208 print "invalid host PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" % (args[2])3209 return 0 3210 3211 if (len(args) > 3):3206 print("invalid host PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" % (args[2])) 3207 return 0 3208 3209 if len(args) > 3: 3212 3210 guestaddr = parsePci(args[3]) 3213 3211 if guestaddr == -1: 3214 print "invalid guest PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" % (args[3])3212 print("invalid guest PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" % (args[3])) 3215 3213 return 0 3216 3214 else: … … 3220 3218 3221 3219 def detachpciCmd(ctx, args): 3222 if (len(args) < 3):3223 print "usage: detachpci vm hostpci"3220 if len(args) < 3: 3221 print("usage: detachpci vm hostpci") 3224 3222 return 0 3225 3223 mach = argsToMach(ctx, args) … … 3228 3226 hostaddr = parsePci(args[2]) 3229 3227 if hostaddr == -1: 3230 print "invalid host PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" % (args[2])3228 print("invalid host PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" % (args[2])) 3231 3229 return 0 3232 3230 … … 3235 3233 3236 3234 def gotoCmd(ctx, args): 3237 if (len(args) < 2):3238 print "usage: goto line"3235 if len(args) < 2: 3236 print("usage: goto line") 3239 3237 return 0 3240 3238 … … 3273 3271 'verbose':['Toggle verbosity', verboseCmd, 0], 3274 3272 'setvar':['Set VMs variable: setvar Fedora BIOSSettings.ACPIEnabled True', setvarCmd, 0], 3275 'eval':['Evaluate arbitrary Python construction: eval \'for m in getMachines(ctx): print m.name, "has", m.memorySize, "M"\'', evalCmd, 0],3273 'eval':['Evaluate arbitrary Python construction: eval \'for m in getMachines(ctx): print(m.name, "has", m.memorySize, "M")\'', evalCmd, 0], 3276 3274 'quit':['Exits', quitCmd, 0], 3277 3275 'host':['Show host information', hostCmd, 0], … … 3329 3327 'prompt' : ['Control shell prompt', promptCmd, 0], 3330 3328 'foreachvm' : ['Perform command for each VM', foreachvmCmd, 0], 3331 'foreach' : ['Generic "for each" construction, using XPath-like notation: foreach //vms/vm[@OSTypeId=\'MacOS\'] "print obj.name"', foreachCmd, 0],3329 'foreach' : ['Generic "for each" construction, using XPath-like notation: foreach //vms/vm[@OSTypeId=\'MacOS\'] "print(obj.name)"', foreachCmd, 0], 3332 3330 'recordDemo':['Record demo: recordDemo Win32 file.dmo 10', recordDemoCmd, 0], 3333 3331 'playbackDemo':['Playback demo: playbackDemo Win32 file.dmo 10', playbackDemoCmd, 0], … … 3344 3342 ci = commands.get(c, None) 3345 3343 if ci == None: 3346 print "Unknown command: '%s', type 'help' for list of known commands" % (c)3344 print("Unknown command: '%s', type 'help' for list of known commands" % (c)) 3347 3345 return 0 3348 3346 if ctx['remote'] and ctx['vb'] is None: 3349 3347 if c not in ['connect', 'reconnect', 'help', 'quit']: 3350 print "First connect to remote server with %s command." % (colored('connect', 'blue'))3348 print("First connect to remote server with %s command." % (colored('connect', 'blue'))) 3351 3349 return 0 3352 3350 return ci[1](ctx, args) … … 3354 3352 3355 3353 def runCommand(ctx, cmd): 3356 if len(cmd) == 0: return 03354 if not cmd: return 0 3357 3355 args = split_no_quotes(cmd) 3358 3356 if len(args) == 0: return 0 … … 3364 3362 # 3365 3363 # def runTestCmd(ctx, args): 3366 # print "Testy test", ctx['vb']3364 # print("Testy test", ctx['vb']) 3367 3365 # return 0 3368 3366 # … … 3381 3379 d = {} 3382 3380 try: 3383 exec file(filename, d, d)3384 for (k, v) in d['commands'].items():3381 exec(compile(open(filename).read(), filename, 'exec'), d, d) 3382 for (k, v) in list(d['commands'].items()): 3385 3383 if g_fVerbose: 3386 print "customize: adding \"%s\" - %s" % (k, v[0])3384 print("customize: adding \"%s\" - %s" % (k, v[0])) 3387 3385 cmds[k] = [v[0], v[1], filename] 3388 3386 except: 3389 print "Error loading user extensions from %s" % (filename)3387 print("Error loading user extensions from %s" % (filename)) 3390 3388 traceback.print_exc() 3391 3389 … … 3423 3421 if vbox is not None: 3424 3422 try: 3425 print "Running VirtualBox version %s" % (vbox.version)3426 except Exception ,e:3423 print("Running VirtualBox version %s" % (vbox.version)) 3424 except Exception as e: 3427 3425 printErr(ctx, e) 3428 3426 if g_fVerbose: … … 3461 3459 cmd = 'runScript %s'% (g_sScriptFile) 3462 3460 elif g_sCmd is not None: 3463 cmd = it.next()3461 cmd = next(it) 3464 3462 else: 3465 cmd = raw_input(ctx['prompt']) 3463 if sys.version_info[0] <= 2: 3464 cmd = raw_input(ctx['prompt']) 3465 else: 3466 cmd = input(ctx['prompt']) 3466 3467 done = runCommand(ctx, cmd) 3467 3468 if done != 0: break … … 3469 3470 break 3470 3471 except KeyboardInterrupt: 3471 print '====== You can type quit or q to leave'3472 print('====== You can type quit or q to leave') 3472 3473 except StopIteration: 3473 3474 break 3474 3475 except EOFError: 3475 3476 break 3476 except Exception ,e:3477 except Exception as e: 3477 3478 printErr(ctx, e) 3478 3479 if g_fVerbose: … … 3536 3537 3537 3538 if options.autopath: 3538 asLocations = [ os.getcwd(), ] ;3539 try: sScriptDir = os.path.dirname(os.path.abspath(__file__)) ;3539 asLocations = [ os.getcwd(), ] 3540 try: sScriptDir = os.path.dirname(os.path.abspath(__file__)) 3540 3541 except: pass; # In case __file__ isn't there. 3541 3542 else: 3542 3543 if platform.system() in [ 'SunOS', ]: 3543 asLocations.append(os.path.join(sScriptDir, 'amd64')) ;3544 asLocations.append(sScriptDir) ;3544 asLocations.append(os.path.join(sScriptDir, 'amd64')) 3545 asLocations.append(sScriptDir) 3545 3546 3546 3547 … … 3550 3551 if os.path.isfile(os.path.join(sCurLoc, "VirtualBox")) \ 3551 3552 or os.path.isfile(os.path.join(sCurLoc, "VirtualBox.exe")): 3552 print "Autodetected VBOX_PROGRAM_PATH as", sCurLoc3553 print("Autodetected VBOX_PROGRAM_PATH as", sCurLoc) 3553 3554 os.environ["VBOX_PROGRAM_PATH"] = sCurLoc 3554 3555 sPath = sCurLoc 3555 break ;3556 break 3556 3557 if sPath: 3557 3558 sys.path.append(os.path.join(sPath, "sdk", "installer")) … … 3561 3562 for sCurLoc in asLocations: 3562 3563 if os.path.isfile(os.path.join(sCurLoc, "sdk", "bindings", "VirtualBox.xidl")): 3563 sCurLoc = os.path.join(sCurLoc, "sdk") ;3564 print "Autodetected VBOX_SDK_PATH as", sCurLoc3564 sCurLoc = os.path.join(sCurLoc, "sdk") 3565 print("Autodetected VBOX_SDK_PATH as", sCurLoc) 3565 3566 os.environ["VBOX_SDK_PATH"] = sCurLoc 3566 sPath = sCurLoc ;3567 break ;3567 sPath = sCurLoc 3568 break 3568 3569 if sPath: 3569 sTmp = os.path.join(sCurLoc, ' sdk', 'bindings', 'xpcom', 'python');3570 sTmp = os.path.join(sCurLoc, 'bindings', 'xpcom', 'python') 3570 3571 if os.path.isdir(sTmp): 3571 sys.path.append(sTmp) ;3572 del sTmp ;3573 del sPath, asLocations ;3572 sys.path.append(sTmp) 3573 del sTmp 3574 del sPath, asLocations 3574 3575 3575 3576 -
trunk/src/VBox/Installer/common/vboxapisetup.py
r59795 r59798 1 1 """ 2 Copyright (C) 2009-201 5Oracle Corporation2 Copyright (C) 2009-2016 Oracle Corporation 3 3 4 4 This file is part of VirtualBox Open Source Edition (OSE), as … … 19 19 comCache1 = os.path.join(get_python_lib(), 'win32com', 'gen_py') 20 20 comCache2 = os.path.join(os.environ.get("TEMP", "c:\\tmp"), 'gen_py') 21 print "Cleaning COM cache at",comCache1,"and",comCache221 print("Cleaning COM cache at",comCache1,"and",comCache2) 22 22 shutil.rmtree(comCache1, True) 23 23 shutil.rmtree(comCache2, True) -
trunk/src/VBox/Main/glue/vboxapi.py
r59795 r59798 7 7 __copyright__ = \ 8 8 """ 9 Copyright (C) 2009-201 5Oracle Corporation9 Copyright (C) 2009-2016 Oracle Corporation 10 10 11 11 This file is part of VirtualBox Open Source Edition (OSE), as … … 32 32 xrange = range 33 33 long = int 34 import builtins35 print_ = getattr(builtins, 'print', None)36 elif sys.version_info >= (2, 6):37 import __builtin__38 print_ = getattr(__builtin__, 'print', None)39 else:40 def print_(*args, **kwargs):41 """The new-style print function for Python 2.4 and 2.5."""42 fp = kwargs.pop("file", sys.stdout)43 if fp is None:44 return45 46 def write(data):47 if not isinstance(data, basestring):48 data = str(data)49 # If the file has an encoding, encode unicode with it.50 if isinstance(fp, file) and isinstance(data, unicode) and fp.encoding is not None:51 errors = getattr(fp, "errors", None)52 if errors is None:53 errors = "strict"54 data = data.encode(fp.encoding, errors)55 fp.write(data)56 57 want_unicode = False58 sep = kwargs.pop("sep", None)59 if sep is not None:60 if isinstance(sep, unicode):61 want_unicode = True62 elif not isinstance(sep, str):63 raise TypeError("sep must be None or a string")64 end = kwargs.pop("end", None)65 if end is not None:66 if isinstance(end, unicode):67 want_unicode = True68 elif not isinstance(end, str):69 raise TypeError("end must be None or a string")70 if kwargs:71 raise TypeError("invalid keyword arguments to print()")72 if not want_unicode:73 for arg in args:74 if isinstance(arg, unicode):75 want_unicode = True76 break77 if want_unicode:78 newline = unicode("\n")79 space = unicode(" ")80 else:81 newline = "\n"82 space = " "83 if sep is None:84 sep = space85 if end is None:86 end = newline87 for i, arg in enumerate(args):88 if i:89 write(sep)90 write(arg)91 write(end)92 34 93 35 # … … 225 167 # Try case-insensitivity workaround for class attributes (COM methods). 226 168 sAttrLower = sAttr.lower() 227 for k in self.__class__.__dict__.keys():169 for k in list(self.__class__.__dict__.keys()): 228 170 if k.lower() == sAttrLower: 229 171 setattr(self.__class__, sAttr, self.__class__.__dict__[k]) -
trunk/src/VBox/Main/webservice/websrv-python.xsl
r59795 r59798 193 193 if self.isarray: 194 194 return self.handle.__next() 195 raise TypeError , "iteration over non-sequence"195 raise TypeError("iteration over non-sequence") 196 196 197 197 def __size(self): 198 198 if self.isarray: 199 199 return self.handle.__size() 200 raise TypeError , "iteration over non-sequence"200 raise TypeError("iteration over non-sequence") 201 201 202 202 def __len__(self): 203 203 if self.isarray: 204 204 return self.handle.__len__() 205 raise TypeError , "iteration over non-sequence"205 raise TypeError("iteration over non-sequence") 206 206 207 207 def __getitem__(self, index): 208 208 if self.isarray: 209 209 return <xsl:value-of select="$ifname" />(self.mgr, self.handle[index]) 210 raise TypeError , "iteration over non-sequence"210 raise TypeError("iteration over non-sequence") 211 211 212 212 def __str__(self): … … 326 326 327 327 def <xsl:call-template name="makeSetterName"><xsl:with-param name="attrname" select="@name"/></xsl:call-template>(self): 328 raise Error , 'setters not supported'328 raise Error('setters not supported') 329 329 </xsl:for-each> 330 330 … … 332 332 if self.isarray: 333 333 return self.handle.__next() 334 raise TypeError , "iteration over non-sequence"334 raise TypeError("iteration over non-sequence") 335 335 336 336 def __size(self): 337 337 if self.isarray: 338 338 return self.handle.__size() 339 raise TypeError , "iteration over non-sequence"339 raise TypeError("iteration over non-sequence") 340 340 341 341 def __len__(self): 342 342 if self.isarray: 343 343 return self.handle.__len__() 344 raise TypeError , "iteration over non-sequence"344 raise TypeError("iteration over non-sequence") 345 345 346 346 def __getitem__(self, index): 347 347 if self.isarray: 348 348 return <xsl:value-of select="$ifname" />(self.mgr, self.handle[index]) 349 raise TypeError , "iteration over non-sequence"349 raise TypeError("iteration over non-sequence") 350 350 <xsl:call-template name="xsltprocNewlineOutputHack"/> 351 351 </xsl:template> … … 511 511 c = self.map.get(handle,-1) 512 512 if c == -1: 513 raise Error , 'wrong refcount'513 raise Error('wrong refcount') 514 514 c = c - 1 515 515 if c == 0: … … 533 533 if self.isarray: 534 534 return self.handle.__next() 535 raise TypeError , "iteration over non-sequence"535 raise TypeError("iteration over non-sequence") 536 536 537 537 def __size(self): 538 538 if self.isarray: 539 539 return self.handle.__size() 540 raise TypeError , "iteration over non-sequence"540 raise TypeError("iteration over non-sequence") 541 541 542 542 def __len__(self): 543 543 if self.isarray: 544 544 return self.handle.__len__() 545 raise TypeError , "iteration over non-sequence"545 raise TypeError("iteration over non-sequence") 546 546 547 547 def __getitem__(self, index): 548 548 if self.isarray: 549 549 return String(self.mgr, self.handle[index]) 550 raise TypeError , "iteration over non-sequence"550 raise TypeError("iteration over non-sequence") 551 551 552 552 def __str__(self): … … 624 624 if self.isarray: 625 625 return self.handle.__next() 626 raise TypeError , "iteration over non-sequence"626 raise TypeError("iteration over non-sequence") 627 627 628 628 def __size(self): 629 629 if self.isarray: 630 630 return self.handle.__size() 631 raise TypeError , "iteration over non-sequence"631 raise TypeError("iteration over non-sequence") 632 632 633 633 def __len__(self): 634 634 if self.isarray: 635 635 return self.handle.__len__() 636 raise TypeError , "iteration over non-sequence"636 raise TypeError("iteration over non-sequence") 637 637 638 638 def __getitem__(self, index): 639 639 if self.isarray: 640 640 return Boolean(self.mgr, self.handle[index]) 641 raise TypeError , "iteration over non-sequence"641 raise TypeError("iteration over non-sequence") 642 642 643 643 class Number: … … 650 650 if self.isarray: 651 651 return self.handle.__next() 652 raise TypeError , "iteration over non-sequence"652 raise TypeError("iteration over non-sequence") 653 653 654 654 def __size(self): 655 655 if self.isarray: 656 656 return self.handle.__size() 657 raise TypeError , "iteration over non-sequence"657 raise TypeError("iteration over non-sequence") 658 658 659 659 def __len__(self): 660 660 if self.isarray: 661 661 return self.handle.__len__() 662 raise TypeError , "iteration over non-sequence"662 raise TypeError("iteration over non-sequence") 663 663 664 664 def __str__(self): … … 711 711 self.handle = mgr.decodebase64(handle) 712 712 else: 713 raise TypeError , "only octet arrays"713 raise TypeError("only octet arrays") 714 714 715 715 def __getitem__(self, index): … … 731 731 if self.isarray: 732 732 return UnsignedInt(self.mgr, self.handle[index]) 733 raise TypeError , "iteration over non-sequence"733 raise TypeError("iteration over non-sequence") 734 734 735 735 … … 743 743 if self.isarray: 744 744 return Int(self.mgr, self.handle[index]) 745 raise TypeError , "iteration over non-sequence"745 raise TypeError("iteration over non-sequence") 746 746 747 747 class UnsignedShort(Number): … … 754 754 if self.isarray: 755 755 return UnsignedShort(self.mgr, self.handle[index]) 756 raise TypeError , "iteration over non-sequence"756 raise TypeError("iteration over non-sequence") 757 757 758 758 class Short(Number): … … 765 765 if self.isarray: 766 766 return Short(self.mgr, self.handle[index]) 767 raise TypeError , "iteration over non-sequence"767 raise TypeError("iteration over non-sequence") 768 768 769 769 class UnsignedLong(Number): … … 776 776 if self.isarray: 777 777 return UnsignedLong(self.mgr, self.handle[index]) 778 raise TypeError , "iteration over non-sequence"778 raise TypeError("iteration over non-sequence") 779 779 780 780 class Long(Number): … … 787 787 if self.isarray: 788 788 return Long(self.mgr, self.handle[index]) 789 raise TypeError , "iteration over non-sequence"789 raise TypeError("iteration over non-sequence") 790 790 791 791 class Double(Number): … … 798 798 if self.isarray: 799 799 return Double(self.mgr, self.handle[index]) 800 raise TypeError , "iteration over non-sequence"800 raise TypeError("iteration over non-sequence") 801 801 802 802 class Float(Number): … … 809 809 if self.isarray: 810 810 return Float(self.mgr, self.handle[index]) 811 raise TypeError , "iteration over non-sequence"811 raise TypeError("iteration over non-sequence") 812 812 813 813 class IUnknown: … … 826 826 if self.isarray: 827 827 return self.handle.__next() 828 raise TypeError , "iteration over non-sequence"828 raise TypeError("iteration over non-sequence") 829 829 830 830 def __size(self): 831 831 if self.isarray: 832 832 return self.handle.__size() 833 raise TypeError , "iteration over non-sequence"833 raise TypeError("iteration over non-sequence") 834 834 835 835 def __len__(self): 836 836 if self.isarray: 837 837 return self.handle.__len__() 838 raise TypeError , "iteration over non-sequence"838 raise TypeError("iteration over non-sequence") 839 839 840 840 def __getitem__(self, index): 841 841 if self.isarray: 842 842 return IUnknown(self.mgr, self.handle[index]) 843 raise TypeError , "iteration over non-sequence"843 raise TypeError("iteration over non-sequence") 844 844 845 845 def __str__(self): -
trunk/src/VBox/ValidationKit/testdriver/vbox.py
r59795 r59798 9 9 __copyright__ = \ 10 10 """ 11 Copyright (C) 2010-201 5Oracle Corporation11 Copyright (C) 2010-2016 Oracle Corporation 12 12 13 13 This file is part of VirtualBox Open Source Edition (OSE), as -
trunk/src/libs/xpcom18a4/python/Makefile.kmk
r59795 r59798 5 5 6 6 # 7 # Copyright (C) 2009-201 5Oracle Corporation7 # Copyright (C) 2009-2016 Oracle Corporation 8 8 # 9 9 # This file is part of VirtualBox Open Source Edition (OSE), as … … 27 27 # 28 28 # List of supported Python versions, defining a number of 29 # VBOX_PYTHON[25|26|27|DEF]_[INC|LIB] variables which get picked up below. 29 # VBOX_PYTHON[26|27|31|32|33|34|35|DEF]_[INC|LIB] variables 30 # which get picked up below. 30 31 # 31 32 ifeq ($(KBUILD_TARGET),darwin) # Relatively predictable, don't script. 32 ifeq ($(KBUILD_TARGET_ARCH),x86)33 VBOX_PYTHON25_INC = $(VBOX_PATH_MACOSX_SDK)/usr/include/python2.534 VBOX_PYTHON25_LIB = $(VBOX_PATH_MACOSX_SDK)/usr/lib/libpython2.5.dylib35 VBOX_PYTHON25_LIB_X86 = $(VBOX_PYTHON25_LIB)36 endif37 33 if !defined(VBOX_WITHOUT_VBOXPYTHON_FOR_OSX_10_6) \ 38 34 && ( !defined(VBOX_OSE) \ … … 49 45 VBOX_PYTHON27_LIB_X86 = $(VBOX_PYTHON27_LIB) 50 46 endif 47 # No Python 3.x yet as part of OSX versions including El Capitan, 10.11. 51 48 52 49 else … … 115 112 116 113 117 ifdef VBOX_PYTHON23_INC118 #119 # Python 2.3 version120 #121 DLLS += VBoxPython2_3122 VBoxPython2_3_EXTENDS = VBoxPythonBase123 VBoxPython2_3_EXTENDS_BY = appending124 VBoxPython2_3_TEMPLATE = XPCOM$(if-expr "$(KBUILD_TARGET)" == "darwin",OSX104,)125 VBoxPython2_3_INCS = $(VBOX_PYTHON23_INC)126 VBoxPython2_3_LIBS = $(VBOX_PYTHON23_LIB)127 128 ifdef VBOX_WITH_32_ON_64_MAIN_API129 DLLS += VBoxPython2_3_x86130 VBoxPython2_3_x86_EXTENDS = VBoxPythonBase_x86131 VBoxPython2_3_x86_EXTENDS_BY = appending132 VBoxPython2_3_x86_TEMPLATE = XPCOM$(if-expr "$(KBUILD_TARGET)" == "darwin",OSX104,-x86)133 VBoxPython2_3_x86_INCS = $(VBOX_PYTHON23_INC)134 VBoxPython2_3_x86_LIBS = $(VBOX_PYTHON23_LIB_X86)135 endif136 endif137 138 ifdef VBOX_PYTHON24_INC139 #140 # Python 2.4 version141 #142 DLLS += VBoxPython2_4143 VBoxPython2_4_EXTENDS = VBoxPythonBase144 VBoxPython2_4_EXTENDS_BY = appending145 VBoxPython2_4_INCS = $(VBOX_PYTHON24_INC)146 VBoxPython2_4_LIBS = $(VBOX_PYTHON24_LIB)147 148 ifdef VBOX_WITH_32_ON_64_MAIN_API149 DLLS += VBoxPython2_4_x86150 VBoxPython2_4_x86_EXTENDS = VBoxPythonBase_x86151 VBoxPython2_4_x86_EXTENDS_BY = appending152 VBoxPython2_4_x86_INCS = $(VBOX_PYTHON24_INC)153 VBoxPython2_4_x86_LIBS = $(VBOX_PYTHON24_LIB_X86)154 endif155 endif156 157 ifdef VBOX_PYTHON25_INC158 #159 # Python 2.5 version160 #161 DLLS += VBoxPython2_5162 VBoxPython2_5_EXTENDS = VBoxPythonBase163 VBoxPython2_5_EXTENDS_BY = appending164 VBoxPython2_5_INCS = $(VBOX_PYTHON25_INC)165 VBoxPython2_5_LIBS = $(VBOX_PYTHON25_LIB)166 167 ifdef VBOX_WITH_32_ON_64_MAIN_API168 DLLS += VBoxPython2_5_x86169 VBoxPython2_5_x86_EXTENDS = VBoxPythonBase_x86170 VBoxPython2_5_x86_EXTENDS_BY = appending171 VBoxPython2_5_x86_INCS = $(VBOX_PYTHON25_INC)172 VBoxPython2_5_x86_LIBS = $(VBOX_PYTHON25_LIB_X86)173 endif174 endif175 176 114 ifdef VBOX_PYTHON26_INC 177 115 # … … 213 151 VBoxPython2_7_x86_INCS = $(VBOX_PYTHON27_INC) 214 152 VBoxPython2_7_x86_LIBS = $(VBOX_PYTHON27_LIB_X86) 153 endif 154 endif 155 156 ifdef VBOX_PYTHON31_INC 157 # 158 # Python 3.1 version 159 # 160 DLLS += VBoxPython3_1 161 VBoxPython3_1_EXTENDS = VBoxPythonBase 162 VBoxPython3_1_EXTENDS_BY = appending 163 VBoxPython3_1_TEMPLATE = XPCOM 164 VBoxPython3_1_INCS = $(VBOX_PYTHON31_INC) 165 VBoxPython3_1_LIBS = $(VBOX_PYTHON31_LIB) 166 167 ifdef VBOX_WITH_32_ON_64_MAIN_API 168 DLLS += VBoxPython3_1_x86 169 VBoxPython3_1_x86_EXTENDS = VBoxPythonBase_x86 170 VBoxPython3_1_x86_EXTENDS_BY = appending 171 VBoxPython3_1_x86_TEMPLATE = XPCOM 172 VBoxPython3_1_x86_INCS = $(VBOX_PYTHON31_INC) 173 VBoxPython3_1_x86_LIBS = $(VBOX_PYTHON31_LIB_X86) 174 endif 175 endif 176 177 ifdef VBOX_PYTHON32_INC 178 # 179 # Python 3.2 version 180 # 181 DLLS += VBoxPython3_2 182 VBoxPython3_2_EXTENDS = VBoxPythonBase 183 VBoxPython3_2_EXTENDS_BY = appending 184 VBoxPython3_2_TEMPLATE = XPCOM 185 VBoxPython3_2_INCS = $(VBOX_PYTHON32_INC) 186 VBoxPython3_2_LIBS = $(VBOX_PYTHON32_LIB) 187 188 ifdef VBOX_WITH_32_ON_64_MAIN_API 189 DLLS += VBoxPython3_2_x86 190 VBoxPython3_2_x86_EXTENDS = VBoxPythonBase_x86 191 VBoxPython3_2_x86_EXTENDS_BY = appending 192 VBoxPython3_2_x86_TEMPLATE = XPCOM 193 VBoxPython3_2_x86_INCS = $(VBOX_PYTHON32_INC) 194 VBoxPython3_2_x86_LIBS = $(VBOX_PYTHON32_LIB_X86) 195 endif 196 endif 197 198 ifdef VBOX_PYTHON33_INC 199 # 200 # Python 3.3 version 201 # 202 DLLS += VBoxPython3_3 203 VBoxPython3_3_EXTENDS = VBoxPythonBase 204 VBoxPython3_3_EXTENDS_BY = appending 205 VBoxPython3_3_TEMPLATE = XPCOM 206 VBoxPython3_3_INCS = $(VBOX_PYTHON33_INC) 207 VBoxPython3_3_LIBS = $(VBOX_PYTHON33_LIB) 208 209 ifdef VBOX_WITH_32_ON_64_MAIN_API 210 DLLS += VBoxPython3_3_x86 211 VBoxPython3_3_x86_EXTENDS = VBoxPythonBase_x86 212 VBoxPython3_3_x86_EXTENDS_BY = appending 213 VBoxPython3_3_x86_TEMPLATE = XPCOM 214 VBoxPython3_3_x86_INCS = $(VBOX_PYTHON33_INC) 215 VBoxPython3_3_x86_LIBS = $(VBOX_PYTHON33_LIB_X86) 216 endif 217 endif 218 219 ifdef VBOX_PYTHON34_INC 220 # 221 # Python 3.4 version 222 # 223 DLLS += VBoxPython3_4 224 VBoxPython3_4_EXTENDS = VBoxPythonBase 225 VBoxPython3_4_EXTENDS_BY = appending 226 VBoxPython3_4_TEMPLATE = XPCOM 227 VBoxPython3_4_INCS = $(VBOX_PYTHON34_INC) 228 VBoxPython3_4_LIBS = $(VBOX_PYTHON34_LIB) 229 230 ifdef VBOX_WITH_32_ON_64_MAIN_API 231 DLLS += VBoxPython3_4_x86 232 VBoxPython3_4_x86_EXTENDS = VBoxPythonBase_x86 233 VBoxPython3_4_x86_EXTENDS_BY = appending 234 VBoxPython3_4_x86_TEMPLATE = XPCOM 235 VBoxPython3_4_x86_INCS = $(VBOX_PYTHON34_INC) 236 VBoxPython3_4_x86_LIBS = $(VBOX_PYTHON34_LIB_X86) 237 endif 238 endif 239 240 ifdef VBOX_PYTHON35_INC 241 # 242 # Python 3.5 version 243 # 244 DLLS += VBoxPython3_5 245 VBoxPython3_5_EXTENDS = VBoxPythonBase 246 VBoxPython3_5_EXTENDS_BY = appending 247 VBoxPython3_5_TEMPLATE = XPCOM 248 VBoxPython3_5_INCS = $(VBOX_PYTHON35_INC) 249 VBoxPython3_5_LIBS = $(VBOX_PYTHON35_LIB) 250 251 ifdef VBOX_WITH_32_ON_64_MAIN_API 252 DLLS += VBoxPython3_5_x86 253 VBoxPython3_5_x86_EXTENDS = VBoxPythonBase_x86 254 VBoxPython3_5_x86_EXTENDS_BY = appending 255 VBoxPython3_5_x86_TEMPLATE = XPCOM 256 VBoxPython3_5_x86_INCS = $(VBOX_PYTHON35_INC) 257 VBoxPython3_5_x86_LIBS = $(VBOX_PYTHON35_LIB_X86) 215 258 endif 216 259 endif -
trunk/src/libs/xpcom18a4/python/__init__.py
r59795 r59798 38 38 39 39 # The XPCOM (Cross Platform COM) package. 40 import exceptions 40 from __future__ import print_function 41 import sys 42 if sys.version_info[0] <= 2: 43 import exceptions 44 XPCOMBaseException = exceptions.Exception 45 else: 46 XPCOMBaseException = Exception 41 47 42 48 # A global "verbose" flag - currently used by the … … 48 54 # The standard XPCOM exception object. 49 55 # Instances of this class are raised by the XPCOM extension module. 50 class Exception( exceptions.Exception):56 class Exception(XPCOMBaseException): 51 57 def __init__(self, errno, message = None): 52 58 assert int(errno) == errno, "The errno param must be an integer" 53 59 self.errno = errno 54 60 self.msg = message 55 exceptions.Exception.__init__(self, errno)61 XPCOMBaseException.__init__(self, errno) 56 62 def __str__(self): 57 63 if not hr_map: 58 import nsError59 for name, val in nsError.__dict__.items():64 from . import nsError 65 for name, val in list(nsError.__dict__.items()): 60 66 if type(val)==type(0): 61 67 hr_map[val] = name … … 80 86 def __init__(self, errno=None, *args, **kw): 81 87 if errno is None: 82 import nsError88 from . import nsError 83 89 errno = nsError.NS_ERROR_FAILURE 84 90 Exception.__init__(self, errno, *args, **kw) … … 98 104 pass 99 105 def write(self, msg): 100 import _xpcom106 import xpcom._xpcom as _xpcom 101 107 _xpcom.LogConsoleMessage(msg) 102 108 def close(self): … … 104 110 105 111 def setupLogging(): 106 import sys, os, threading, thread 112 import os 113 if sys.version_info[0] <= 2: 114 import threading, thread 107 115 hdlr = logging.StreamHandler(ConsoleServiceStream()) 108 116 fmt = logging.Formatter(logging.BASIC_FORMAT) … … 113 121 # Later versions of logging use an RLock, so we detect an "old" style 114 122 # handler and update its lock 115 if type(hdlr.lock) == thread.LockType: 116 hdlr.lock = threading.RLock() 123 if sys.version_info[0] <= 2: 124 if type(hdlr.lock) == thread.LockType: 125 hdlr.lock = threading.RLock() 117 126 118 127 logger.addHandler(hdlr) … … 126 135 # open without buffering so never pending output 127 136 stream = open(filename, "wU", 0) 128 except IOError, why: 129 print >> sys.stderr, "pyxpcom failed to open log file '%s': %s" \ 130 % (filename, why) 137 except IOError as why: 138 print("pyxpcom failed to open log file '%s': %s" % (filename, why), file=sys.stderr) 131 139 # stream remains default 132 140 133 141 hdlr = logging.StreamHandler(stream) 134 142 # see above - fix a deadlock problem on this handler too. 135 if type(hdlr.lock) == thread.LockType: 136 hdlr.lock = threading.RLock() 143 if sys.version_info[0] <= 2: 144 if type(hdlr.lock) == thread.LockType: 145 hdlr.lock = threading.RLock() 137 146 138 147 fmt = logging.Formatter(logging.BASIC_FORMAT) -
trunk/src/libs/xpcom18a4/python/client/__init__.py
r59795 r59798 37 37 38 38 import os 39 import new 39 from types import MethodType 40 40 import logging 41 41 from xpcom import xpt, COMException, nsError, logger … … 126 126 # Exec the code object 127 127 tempNameSpace = {} 128 exec codeObject in globals(), tempNameSpace128 exec(codeObject, globals(), tempNameSpace) 129 129 ret = tempNameSpace[name] 130 if not interface_method_cache.has_key(iid):130 if iid not in interface_method_cache: 131 131 interface_method_cache[iid] = {} 132 132 interface_method_cache[iid][name] = ret … … 153 153 if flags & FLAGS_TO_IGNORE == 0: 154 154 if flags & XPT_MD_SETTER: 155 param_flags = map(lambda x: (x.param_flags,) + xpt.MakeReprForInvoke(x), m.params)155 param_flags = list([(x.param_flags,) + xpt.MakeReprForInvoke(x) for x in m.params]) 156 156 setters[m.name] = m.method_index, param_flags 157 157 elif flags & XPT_MD_GETTER: 158 param_flags = map(lambda x: (x.param_flags,) + xpt.MakeReprForInvoke(x), m.params)158 param_flags = list([(x.param_flags,) + xpt.MakeReprForInvoke(x) for x in m.params]) 159 159 getters[m.name] = m.method_index, param_flags 160 160 else: … … 220 220 except COMException: 221 221 pass 222 raise ValueError , "This object does not support automatic numeric conversion to this type"222 raise ValueError("This object does not support automatic numeric conversion to this type") 223 223 224 224 def __int__(self): … … 281 281 for nominated_iid in interface_infos: 282 282 # Interface may appear twice in the class info list, so check this here. 283 if no t self.__dict__['_interface_infos_'].has_key(nominated_iid):283 if nominated_iid not in self.__dict__['_interface_infos_']: 284 284 # Just invoke our QI on the object 285 285 self.queryInterface(nominated_iid) … … 290 290 contractid_info_cache[real_cid] = contractid_info 291 291 else: 292 for key, val in contractid_info.items():292 for key, val in list(contractid_info.items()): 293 293 self.__dict__[key].update(val) 294 294 … … 300 300 # rebuild the world for each new object. 301 301 iis = self.__dict__['_interface_infos_'] 302 assert not iis.has_key(iid), "Already remembered this interface!"302 assert iid not in iis, "Already remembered this interface!" 303 303 try: 304 304 method_infos, getters, setters, constants = BuildInterfaceInfo(iid) 305 except COMException ,why:305 except COMException as why: 306 306 # Failing to build an interface info generally isn't a real 307 307 # problem - its probably just that the interface is non-scriptable. … … 314 314 iis[iid] = method_infos, getters, setters, constants 315 315 names = self.__dict__['_name_to_interface_iid_'] 316 for name in method_infos.keys(): names[name] = iid317 for name in getters.keys(): names[name] = iid318 for name in setters.keys(): names[name] = iid319 for name in constants.keys(): names[name] = iid316 for name in list(method_infos.keys()): names[name] = iid 317 for name in list(getters.keys()): names[name] = iid 318 for name in list(setters.keys()): names[name] = iid 319 for name in list(constants.keys()): names[name] = iid 320 320 321 321 def QueryInterface(self, iid): 322 if self._interfaces_.has_key(iid):323 assert self._interface_names_.has_key(iid.name), "_interfaces_ has the key, but _interface_names_ does not!"322 if iid in self._interfaces_: 323 assert iid_name in self._interface_names_, "_interfaces_ has the key, but _interface_names_ does not!" 324 324 return self 325 325 # Haven't seen this before - do a real QI. 326 if not self._interface_infos_.has_key(iid):326 if iid not in self._interface_infos_: 327 327 self._remember_interface_info(iid) 328 328 iface_info = self._interface_infos_[iid] … … 350 350 def __getattr__(self, attr): 351 351 if attr in _special_getattr_names: 352 raise AttributeError , attr352 raise AttributeError(attr) 353 353 # First allow the interface name to return the "raw" interface 354 354 interface = self.__dict__['_interface_names_'].get(attr, None) … … 375 375 # Some interfaces may provide this name via "native" support. 376 376 # Loop over all interfaces, and if found, cache it for next time. 377 for interface in self.__dict__['_interfaces_'].values():377 for interface in list(self.__dict__['_interfaces_'].values()): 378 378 try: 379 379 ret = getattr(interface, attr) … … 382 382 except AttributeError: 383 383 pass 384 raise AttributeError , "XPCOM component '%s' has no attribute '%s'" % (self._object_name_, attr)384 raise AttributeError("XPCOM component '%s' has no attribute '%s'" % (self._object_name_, attr)) 385 385 386 386 def __setattr__(self, attr, val): … … 397 397 setattr(interface, attr, val) 398 398 return 399 raise AttributeError , "XPCOM component '%s' has no attribute '%s'" % (self._object_name_, attr)399 raise AttributeError("XPCOM component '%s' has no attribute '%s'" % (self._object_name_, attr)) 400 400 401 401 def _get_classinfo_repr_(self): … … 410 410 self.__dict__['_tried_classinfo_'] = 0 411 411 412 iface_names = self.__dict__['_interface_names_'].keys()412 iface_names = list(self.__dict__['_interface_names_'].keys()) 413 413 try: 414 414 iface_names.remove("nsISupports") … … 436 436 self.__dict__.update(constants) 437 437 # We remember the constant names to prevent the user trying to assign to them! 438 self.__dict__['_constant_names_'] = constants.keys()438 self.__dict__['_constant_names_'] = list(constants.keys()) 439 439 440 440 def __getattr__(self, attr): 441 441 # Allow the underlying interface to provide a better implementation if desired. 442 442 if attr in _special_getattr_names: 443 raise AttributeError , attr443 raise AttributeError(attr) 444 444 445 445 ret = getattr(self.__dict__['_comobj_'], attr, None) … … 449 449 unbound_method = self.__dict__['_methods_'].get(attr, None) 450 450 if unbound_method is not None: 451 return new.instancemethod(unbound_method, self, self.__class__)451 return MethodType(unbound_method, self) 452 452 453 453 getters = self.__dict__['_property_getters_'] … … 456 456 method_index, param_infos = info 457 457 if len(param_infos)!=1: # Only expecting a retval 458 raise RuntimeError , "Can't get properties with this many args!"458 raise RuntimeError("Can't get properties with this many args!") 459 459 args = ( param_infos, () ) 460 460 return XPTC_InvokeByIndex(self._comobj_, method_index, args) … … 467 467 # Cache it locally 468 468 self.__dict__['_methods_'][attr] = unbound_method 469 return new.instancemethod(unbound_method, self, self.__class__)470 471 raise AttributeError , "XPCOM component '%s' has no attribute '%s'" % (self._object_name_, attr)469 return MethodType(unbound_method, self) 470 471 raise AttributeError("XPCOM component '%s' has no attribute '%s'" % (self._object_name_, attr)) 472 472 473 473 def __setattr__(self, attr, val): 474 474 # If we already have a __dict__ item of that name, and its not one of 475 475 # our constants, we just directly set it, and leave. 476 if self.__dict__.has_key(attr)and attr not in self.__dict__['_constant_names_']:476 if attr in self.__dict__ and attr not in self.__dict__['_constant_names_']: 477 477 self.__dict__[attr] = val 478 478 return … … 481 481 info = setters.get(attr) 482 482 if info is None: 483 raise AttributeError , "XPCOM component '%s' can not set attribute '%s'" % (self._object_name_, attr)483 raise AttributeError("XPCOM component '%s' can not set attribute '%s'" % (self._object_name_, attr)) 484 484 method_index, param_infos = info 485 485 if len(param_infos)!=1: # Only expecting a single input val 486 raise RuntimeError , "Can't set properties with this many args!"486 raise RuntimeError("Can't set properties with this many args!") 487 487 real_param_infos = ( param_infos, (val,) ) 488 488 return XPTC_InvokeByIndex(self._comobj_, method_index, real_param_infos) … … 527 527 try: 528 528 return Component(self._comobj_.QueryReferent(iid)._comobj_, iid) 529 except COMException ,details:529 except COMException as details: 530 530 if details.errno != nsError.NS_ERROR_NULL_POINTER: 531 531 raise -
trunk/src/libs/xpcom18a4/python/components.py
r59795 r59798 37 37 38 38 # This module provides the JavaScript "components" interface 39 import xpt 40 import xpcom, _xpcom 39 from . import xpt 40 import xpcom 41 import xpcom._xpcom as _xpcom 41 42 import xpcom.client 42 43 import xpcom.server 43 import types 44 45 StringTypes = [types.StringType, types.UnicodeType] 44 45 StringTypes = [bytes, str] 46 46 47 47 def _get_good_iid(iid): … … 79 79 if self._dict_data is None: 80 80 self._dict_data = self._build_dict() 81 return self._dict_data.keys()81 return list(self._dict_data.keys()) 82 82 def items(self): 83 83 if self._dict_data is None: 84 84 self._dict_data = self._build_dict() 85 return self._dict_data.items()85 return list(self._dict_data.items()) 86 86 def values(self): 87 87 if self._dict_data is None: 88 88 self._dict_data = self._build_dict() 89 return self._dict_data.values()90 def has_key(self, key):91 if self._dict_data is None:92 self._dict_data = self._build_dict()93 return self._dict_data.has_key(key)89 return list(self._dict_data.values()) 90 # def has_key(self, key): 91 # if self._dict_data is None: 92 # self._dict_data = self._build_dict() 93 # return self._dict_data.has_key(key) 94 94 95 95 def __len__(self): … … 99 99 100 100 def __getattr__(self, attr): 101 if self._dict_data is not None and self._dict_data.has_key(attr):101 if self._dict_data is not None and attr in self._dict_data: 102 102 return self._dict_data[attr] 103 103 return self._get_one(attr) 104 104 def __getitem__(self, item): 105 if self._dict_data is not None and self._dict_data.has_key(item):105 if self._dict_data is not None and item in self._dict_data: 106 106 return self._dict_data[item] 107 107 return self._get_one(item) … … 120 120 other_iid = getattr(other, "_iidobj_", other) 121 121 return cmp(this_iid, other_iid) 122 def __eq__(self, other): 123 this_iid = self._iidobj_ 124 other_iid = getattr(other, "_iidobj_", other) 125 return this_iid == other_iid 122 126 def __hash__(self): 123 127 return hash(self._iidobj_) … … 125 129 return str(self._iidobj_) 126 130 def __getitem__(self, item): 127 raise TypeError , "components.interface objects are not subscriptable"131 raise TypeError("components.interface objects are not subscriptable") 128 132 def __setitem__(self, item, value): 129 raise TypeError , "components.interface objects are not subscriptable"133 raise TypeError("components.interface objects are not subscriptable") 130 134 def __setattr__(self, attr, value): 131 raise AttributeError , "Can not set attributes on components.Interface objects"135 raise AttributeError("Can not set attributes on components.Interface objects") 132 136 def __getattr__(self, attr): 133 137 # Support constants as attributes. … … 139 143 c[c_ob.name] = c_ob.value 140 144 _constants_by_iid_map[self._iidobj_] = c 141 if c.has_key(attr):145 if attr in c: 142 146 return c[attr] 143 raise AttributeError , "'%s' interfaces do not define a constant '%s'" % (self.name, attr)147 raise AttributeError("'%s' interfaces do not define a constant '%s'" % (self.name, attr)) 144 148 145 149 … … 148 152 try: 149 153 item = interfaceInfoManager.GetInfoForName(name) 150 except xpcom.COMException ,why:154 except xpcom.COMException as why: 151 155 # Present a better exception message, and give a more useful error code. 152 import nsError156 from . import nsError 153 157 raise xpcom.COMException(nsError.NS_ERROR_NO_INTERFACE, "The interface '%s' does not exist" % (name,)) 154 158 return _Interface(item.GetName(), item.GetIID()) … … 180 184 self.clsid = rc 181 185 return rc 182 raise AttributeError , "%s class has no attribute '%s'" % (self.contractid, attr)186 raise AttributeError("%s class has no attribute '%s'" % (self.contractid, attr)) 183 187 def createInstance(self, iid = None): 184 188 import xpcom.client 185 189 try: 186 190 return xpcom.client.Component(self.contractid, _get_good_iid(iid)) 187 except xpcom.COMException ,details:188 import nsError191 except xpcom.COMException as details: 192 from . import nsError 189 193 # Handle "no such component" in a cleaner way for the user. 190 194 if details.errno == nsError.NS_ERROR_FACTORY_NOT_REGISTERED: … … 219 223 220 224 # The ID function 221 ID = _xpcom.I ID225 ID = _xpcom.ID 222 226 223 227 # A helper to cleanup our namespace as xpcom shuts down. -
trunk/src/libs/xpcom18a4/python/file.py
r59795 r59798 156 156 self.close() 157 157 if mode != "r": 158 raise ValueError , "only 'r' mode supported'"158 raise ValueError("only 'r' mode supported") 159 159 io_service = components.classes["@mozilla.org/network/io-service;1"] \ 160 160 .getService(components.interfaces.nsIIOService) … … 165 165 # Mozilla asserts and starts saying "NULL POINTER" if this is wrong! 166 166 if not url_ob.scheme: 167 raise ValueError ,("The URI '%s' is invalid (no scheme)"167 raise ValueError("The URI '%s' is invalid (no scheme)" 168 168 % (url_ob.spec,)) 169 169 self.channel = io_service.newChannelFromURI(url_ob) … … 202 202 self.inputStream.init(self.fileIO) 203 203 else: 204 raise ValueError , "Unknown mode"204 raise ValueError("Unknown mode") 205 205 206 206 def close(self): … … 226 226 got = got + file.read() 227 227 if got != expected: 228 raise RuntimeError , "Reading '%s' failed - got %d bytes, but expected %d bytes" % (file, len(got), len(expected))228 raise RuntimeError("Reading '%s' failed - got %d bytes, but expected %d bytes" % (file, len(got), len(expected))) 229 229 230 230 def _DoTestBufferRead(file, expected): … … 240 240 got = got + str(buffer[:num]) 241 241 if got != expected: 242 raise RuntimeError , "Reading '%s' failed - got %d bytes, but expected %d bytes" % (file, len(got), len(expected))242 raise RuntimeError("Reading '%s' failed - got %d bytes, but expected %d bytes" % (file, len(got), len(expected))) 243 243 244 244 def _TestLocalFile(): … … 266 266 # Open the same file again for writing - this should delete the old one. 267 267 if not os.path.isfile(fname): 268 raise RuntimeError , "The file '%s' does not exist, but we are explicitly testing create semantics when it does" % (fname,)268 raise RuntimeError("The file '%s' does not exist, but we are explicitly testing create semantics when it does" % (fname,)) 269 269 test_file = LocalFile(fname, "w") 270 270 test_file.write(data) … … 305 305 def _TestURI(url): 306 306 test_file = URIFile(url) 307 print "Opened file is", test_file307 print("Opened file is", test_file) 308 308 got = test_file.read() 309 print "Read %d bytes of data from %r" % (len(got), url)309 print("Read %d bytes of data from %r" % (len(got), url)) 310 310 test_file.close() 311 311 … … 313 313 import sys 314 314 if len(sys.argv) < 2: 315 print "No URL specified on command line - performing self-test"315 print("No URL specified on command line - performing self-test") 316 316 _TestAll() 317 317 else: -
trunk/src/libs/xpcom18a4/python/gen_python_deps.py
r59795 r59798 2 2 3 3 """ 4 Copyright (C) 2009-201 3Oracle Corporation4 Copyright (C) 2009-2016 Oracle Corporation 5 5 6 6 This file is part of VirtualBox Open Source Edition (OSE), as … … 14 14 15 15 import os,sys 16 from distutils.version import StrictVersion 16 17 17 versions = ["2. 3", "2.4", "2.5", "2.6", "2.7",]18 versions = ["2.6", "2.7", "3.1", "3.2", "3.3", "3.4", "3.5"] 18 19 prefixes = ["/usr", "/usr/local", "/opt", "/opt/local"] 19 20 known = {} … … 41 42 42 43 def print_vars(vers, known, sep, bitness_magic): 43 print "VBOX_PYTHON%s_INC=%s%s" %(vers, known[0], sep)44 print("VBOX_PYTHON%s_INC=%s%s" %(vers, known[0], sep)) 44 45 if bitness_magic > 0: 45 print "VBOX_PYTHON%s_LIB=%s%s" %(vers, known[2], sep)46 print "VBOX_PYTHON%s_LIB_X86=%s%s" %(vers, known[1], sep)46 print("VBOX_PYTHON%s_LIB=%s%s" %(vers, known[2], sep)) 47 print("VBOX_PYTHON%s_LIB_X86=%s%s" %(vers, known[1], sep)) 47 48 else: 48 print "VBOX_PYTHON%s_LIB=%s%s" %(vers, known[1], sep)49 print("VBOX_PYTHON%s_LIB=%s%s" %(vers, known[1], sep)) 49 50 50 51 … … 91 92 92 93 for v in versions: 94 if StrictVersion(v) < StrictVersion('2.6'): 95 continue 93 96 for p in prefixes: 94 97 c = checkPair(p, v, dllpre, dllsuff, bitness_magic) … … 96 99 known[v] = c 97 100 break 98 keys = known.keys()101 keys = list(known.keys()) 99 102 # we want default to be the lowest versioned Python 100 103 keys.sort() -
trunk/src/libs/xpcom18a4/python/primitives.py
r59795 r59798 35 35 better = _primitives_map[prin.type] 36 36 except KeyError: 37 raise ValueError , "This primitive type (%d) is not supported" % (prin.type,)37 raise ValueError("This primitive type (%d) is not supported" % (prin.type,)) 38 38 prin = prin.QueryInterface(better) 39 39 return prin.data -
trunk/src/libs/xpcom18a4/python/server/__init__.py
r59795 r59798 38 38 # The xpcom.server package. 39 39 40 from policy import DefaultPolicy40 from xpcom.server.policy import DefaultPolicy 41 41 from xpcom import _xpcom 42 42 … … 80 80 # Python! 81 81 def NS_GetModule( serviceManager, nsIFile ): 82 import loader82 from . import loader 83 83 iid = _xpcom.IID_nsIModule 84 84 return WrapObject(loader.MakePythonComponentLoaderModule(serviceManager, nsIFile), iid, bWrapClient = 0) 85 85 86 86 def _shutdown(): 87 from policy import _shutdown87 from server.policy import _shutdown 88 88 _shutdown() -
trunk/src/libs/xpcom18a4/python/server/loader.py
r59795 r59798 38 38 import xpcom 39 39 from xpcom import components, logger 40 41 import module 42 43 import glob, os, types 44 40 from . import module 41 import glob 42 import os 45 43 from xpcom.client import Component 46 44 … … 57 55 # For now, just run over all classes looking for likely candidates. 58 56 comps = [] 59 for name, object in py_module.__dict__.items():57 for name, object in list(py_module.__dict__.items()): 60 58 try: 61 if (type(object) == type s.ClassTypeor issubclass(object, object)) and \59 if (type(object) == type or issubclass(object, object)) and \ 62 60 _has_good_attr(object, "_com_interfaces_") and \ 63 61 _has_good_attr(object, "_reg_clsid_") and \ … … 148 146 self.autoRegisterComponent(when, entry) 149 147 # Handle some common user errors 150 except xpcom.COMException ,details:148 except xpcom.COMException as details: 151 149 from xpcom import nsError 152 150 # If the interface name does not exist, suppress the traceback … … 156 154 else: 157 155 logger.exception("Registration of '%s' failed!", entry.leafName) 158 except SyntaxError ,details:156 except SyntaxError as details: 159 157 # Syntax error in source file - no useful traceback here either. 160 158 logger.error("Registration of '%s' failed\n %s", … … 226 224 227 225 def MakePythonComponentLoaderModule(serviceManager, nsIFile): 228 import module226 from . import module 229 227 return module.Module( [PythonComponentLoader] ) -
trunk/src/libs/xpcom18a4/python/server/module.py
r59795 r59798 39 39 from xpcom import nsError 40 40 41 import factory41 from . import factory 42 42 43 43 import types … … 66 66 # void function. 67 67 fname = os.path.basename(location.path) 68 for klass in self.components.values():68 for klass in list(self.components.values()): 69 69 reg_contractid = klass._reg_contractid_ 70 print "Registering '%s' (%s)" % (reg_contractid, fname)70 print("Registering '%s' (%s)" % (reg_contractid, fname)) 71 71 reg_desc = getattr(klass, "_reg_desc_", reg_contractid) 72 72 compMgr = compMgr.queryInterface(components.interfaces.nsIComponentRegistrar) … … 85 85 def unregisterSelf(self, compMgr, location, loaderStr): 86 86 # void function. 87 for klass in self.components.values():87 for klass in list(self.components.values()): 88 88 ok = 1 89 89 try: … … 99 99 ok = 0 100 100 if ok: 101 print "Successfully unregistered", klass.__name__101 print("Successfully unregistered", klass.__name__) 102 102 else: 103 print "Unregistration of", klass.__name__, "failed. (probably just not already registered)"103 print("Unregistration of", klass.__name__, "failed. (probably just not already registered)") 104 104 105 105 def canUnload(self, compMgr): -
trunk/src/libs/xpcom18a4/python/server/policy.py
r59795 r59798 43 43 import types 44 44 import logging 45 import sys 45 46 46 47 … … 61 62 _supports_primitives_map_ = {} # Filled on first use. 62 63 63 _interface_sequence_types_ = types.TupleType, types.ListType 64 _string_types_ = types.StringType, types.UnicodeType 64 _interface_sequence_types_ = tuple, list 65 if sys.version_info[0] <= 2: 66 _string_types_ = str, unicode 67 else: 68 _string_types_ = bytes, str 65 69 XPTI_GetInterfaceInfoManager = _xpcom.XPTI_GetInterfaceInfoManager 66 70 … … 142 146 self._iid_ = iid 143 147 if ni is None: 144 raise ValueError , "The object '%r' can not be used as a COM object" % (instance,)148 raise ValueError("The object '%r' can not be used as a COM object" % (instance,)) 145 149 # This is really only a check for the user 146 150 if __debug__: … … 286 290 if logger.isEnabledFor(logging.DEBUG): 287 291 try: 288 raise exc_info[0] , exc_info[1], exc_info[2]292 raise exc_info[0](exc_info[1]).with_traceback(exc_info[2]) 289 293 except: 290 294 logger.debug("'%s' raised COM Exception %s", … … 294 298 # As above, trick the logging module to handle Python 2.3 295 299 try: 296 raise exc_info[0] , exc_info[1], exc_info[2]300 raise exc_info[0](exc_info[1]).with_traceback(exc_info[2]) 297 301 except: 298 302 logger.exception("Unhandled exception calling '%s'", func_name) … … 331 335 _supports_primitives_data_ = [ 332 336 ("nsISupportsCString", "__str__", str), 333 ("nsISupportsString", "__unicode__", unicode),334 ("nsISupportsPRUint64", "__long__", long),335 ("nsISupportsPRInt64", "__long__", long),337 ("nsISupportsString", "__unicode__", str), 338 ("nsISupportsPRUint64", "__long__", int), 339 ("nsISupportsPRInt64", "__long__", int), 336 340 ("nsISupportsPRUint32", "__int__", int), 337 341 ("nsISupportsPRInt32", "__int__", int), -
trunk/src/libs/xpcom18a4/python/src/PyXPCOM.h
r59795 r59798 133 133 # endif 134 134 135 # if PY_MAJOR_VERSION >= 3 136 # define PyInt_FromLong(l) PyLong_FromLong(l) 137 # define PyInt_Check(o) PyLong_Check(o) 138 # define PyInt_AsLong(o) PyLong_AsLong(o) 139 # define PyNumber_Int(o) PyNumber_Long(o) 140 # ifndef PyUnicode_AsUTF8 141 # define PyUnicode_AsUTF8(o) _PyUnicode_AsString(o) 142 # endif 143 # ifndef PyUnicode_AsUTF8AndSize 144 # define PyUnicode_AsUTF8AndSize(o,s) _PyUnicode_AsStringAndSize(o,s) 145 # endif 146 typedef struct PyMethodChain 147 { 148 PyMethodDef *methods; 149 struct PyMethodChain *link; 150 } PyMethodChain; 151 # endif 152 135 153 #endif /* VBOX_PYXPCOM */ 136 154 … … 268 286 static int Py_setattr(PyObject *op, char *name, PyObject *v); 269 287 static int Py_cmp(PyObject *ob1, PyObject *ob2); 288 static PyObject *Py_richcmp(PyObject *ob1, PyObject *ob2, int op); 270 289 static long Py_hash(PyObject *self); 271 290 }; … … 419 438 /* Python support */ 420 439 static PyObject *PyTypeMethod_getattr(PyObject *self, char *name); 440 #if PY_MAJOR_VERSION <= 2 421 441 static int PyTypeMethod_compare(PyObject *self, PyObject *ob); 442 #endif 443 static PyObject *PyTypeMethod_richcompare(PyObject *self, PyObject *ob, int op); 422 444 static PyObject *PyTypeMethod_repr(PyObject *self); 423 445 static long PyTypeMethod_hash(PyObject *self); -
trunk/src/libs/xpcom18a4/python/test/test_test_component.py
r59795 r59798 253 253 test_attribute(c, "iid_value", component_iid, new_iid) 254 254 test_attribute(c, "iid_value", component_iid, str(new_iid), new_iid) 255 test_attribute(c, "iid_value", component_iid, xpcom._xpcom.I ID(new_iid))255 test_attribute(c, "iid_value", component_iid, xpcom._xpcom.ID(new_iid)) 256 256 257 257 test_attribute_failure(c, "no_attribute", "boo", AttributeError) -
trunk/src/libs/xpcom18a4/python/vboxxpcom.py
r59795 r59798 1 1 """ 2 Copyright (C) 2008-201 2Oracle Corporation2 Copyright (C) 2008-2016 Oracle Corporation 3 3 4 4 This file is part of VirtualBox Open Source Edition (OSE), as … … 47 47 _oVBoxPythonMod = __import__(m) 48 48 break 49 except Exception ,x:50 print 'm=%s x=%s' % (m, x);49 except Exception as x: 50 print('m=%s x=%s' % (m, x)) 51 51 #except: 52 52 # pass -
trunk/src/libs/xpcom18a4/python/xpt.py
r59795 r59798 72 72 import xpcom._xpcom 73 73 74 from xpcom_consts import *74 from .xpcom_consts import * 75 75 76 76 class Interface: … … 100 100 if xpcom.verbose: 101 101 # The user may be confused as to why this is happening! 102 print "The parent interface of IID '%s' can not be located - assuming nsISupports"102 print("The parent interface of IID '%s' can not be located - assuming nsISupports") 103 103 return Interface(xpcom._xpcom.IID_nsISupports) 104 104 105 105 def Describe_Python(self): 106 106 method_reprs = [] 107 methods = filter(lambda m: not m.IsNotXPCOM(), self.methods)107 methods = [m for m in self.methods if not m.IsNotXPCOM()] 108 108 for m in methods: 109 109 method_reprs.append(m.Describe_Python()) … … 130 130 s = s + ' Scriptable: ' + word + '\n' 131 131 s = s + ' Methods:\n' 132 methods = filter(lambda m: not m.IsNotXPCOM(), self.methods)132 methods = [m for m in self.methods if not m.IsNotXPCOM()] 133 133 if len(methods): 134 134 for m in methods: … … 153 153 except xpcom.Exception: 154 154 if xpcom.verbose: 155 print "** GetMethodCount failed?? - assuming no methods"155 print("** GetMethodCount failed?? - assuming no methods") 156 156 self.items = [] 157 157 def __len__(self): … … 252 252 253 253 def desc(a): return a.Describe() 254 method_desc = string.join( map(desc, self.params), ', ')254 method_desc = string.join(list(map(desc, self.params)), ', ') 255 255 result_type = TypeDescriber(self.result_desc[0], None) 256 256 return_desc = result_type.Describe() … … 329 329 except xpcom.Exception: 330 330 if xpcom.verbose: 331 print "** GetConstantCount failed?? - assuming no constants"331 print("** GetConstantCount failed?? - assuming no constants") 332 332 self.items = [] 333 333 def __len__(self): … … 452 452 describer_name = describer_name + "_" + mode.capitalize() 453 453 describer = getattr(interface, describer_name) 454 print describer()454 print(describer()) 455 455 456 456 if __name__=='__main__': 457 457 if len(sys.argv) == 1: 458 print "Usage: xpt.py [-xptinfo] interface_name, ..."459 print " -info: Dump in a style similar to the xptdump tool"460 print "Dumping nsISupports and nsIInterfaceInfo"458 print("Usage: xpt.py [-xptinfo] interface_name, ...") 459 print(" -info: Dump in a style similar to the xptdump tool") 460 print("Dumping nsISupports and nsIInterfaceInfo") 461 461 sys.argv.append('nsIInterfaceInfo') 462 462 sys.argv.append('-xptinfo')
Note:
See TracChangeset
for help on using the changeset viewer.

