vboxapi.py revision 7225c19c065cadcc51171f0ad664cc4a93303edd
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync# Copyright (C) 2009 Oracle Corporation
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync# available from http://www.virtualbox.org. This file is free software;
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync# you can redistribute it and/or modify it under the terms of the GNU
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync# General Public License (GPL) as published by the Free Software
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync# To set Python bitness on OSX use 'export VERSIONER_PYTHON_PREFER_32_BIT=yes'
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsyncVboxBinDir = os.environ.get("VBOX_PROGRAM_PATH", None)
fe0336dab2332556574fab2b79ab4210a7989127vboxsync # Will be set by the installer
fe0336dab2332556574fab2b79ab4210a7989127vboxsync # Will be set by the installer
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsyncfrom VirtualBox_constants import VirtualBoxReflectionInfo
fe0336dab2332556574fab2b79ab4210a7989127vboxsync """ This class provides a wrapper over IPerformanceCollector in order to
fe0336dab2332556574fab2b79ab4210a7989127vboxsync get more 'pythonic' interface.
fe0336dab2332556574fab2b79ab4210a7989127vboxsync To begin collection of metrics use setup() method.
fe0336dab2332556574fab2b79ab4210a7989127vboxsync To get collected data use query() method.
fe0336dab2332556574fab2b79ab4210a7989127vboxsync It is possible to disable metric collection without changing collection
fe0336dab2332556574fab2b79ab4210a7989127vboxsync parameters with disable() method. The enable() method resumes metric
fe0336dab2332556574fab2b79ab4210a7989127vboxsync collection.
fe0336dab2332556574fab2b79ab4210a7989127vboxsync """ Initializes the instance.
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync """ Discards all previously collected values for the specified
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync metrics, sets the period of collection and the number of retained
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync samples, enables collection.
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync self.collector.setupMetrics(names, objects, period, nsamples)
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync """ Resumes metric collection for the specified metrics.
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync """ Suspends metric collection for the specified metrics.
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync """ Retrieves collected metric values as well as some auxiliary
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync information. Returns an array of dictionaries, one dictionary per
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync metric. Each dictionary contains the following entries:
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync 'name': metric name
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync 'object': managed object this metric associated with
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync 'unit': unit of measurement
a8d4049da2285bc369273acbf613b8b7990cb4bfvboxsync 'scale': divide 'values' by this number to get float numbers
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync 'values': collected data
21f41483611463008ef71e88d2c2b5ece30bc290vboxsync 'values_as_string': pre-processed values ready for 'print' statement
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync # Get around the problem with input arrays returned in output
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync # parameters (see #3953) for MSCOM.
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync (values, names, objects, names_out, objects_out, units, scales, sequence_numbers,
c0829c6fca24bd3a9a687c93f9b64da2c54b767cvboxsync indices, lengths) = self.collector.queryMetricsData(names, objects)
out = []
'values_as_string':'['+', '.join([fmt % (int(values[j])/scale, units[i]) for j in xrange(int(indices[i]), int(indices[i])+int(lengths[i]))])+']'
return out
except AttributeError:
except AttributeError:
class PlatformMSCOM:
class ConstantFake:
raise AttributeError
import win32com
raise AttributeError
if fake != None:
return fake
while parent != None:
if name is not None:
except AttributeError,e:
return fake
class InterfacesWrapper:
import win32com
raise AttributeError
except AttributeError,e:
import win32com
import pythoncom
import win32api
import threading
import win32com
import win32com
return False
import pythoncom
import pythoncom
exec (str,d,d)
import types
return rc;
return False;
return True;
import pythoncom
CloseHandle(h)
class PlatformXPCOM:
import xpcom
return False
import xpcom
import xpcom
exec (str,d,d)
import xpcom
import xpcom
import xpcom
class PlatformWEBSERVICE:
import VirtualBox_wrappers
if params is not None:
if url is None:
if user is None:
if passwd is None:
return True
return False;
exec (str,d,d)
class SessionManager:
class VirtualBoxManager:
if style is None:
raise ne
except Exception,e:
if permitSharing:
return session
if session is not None:
global VboxBinDir
return VboxBinDir
global VboxSdkDir
return VboxSdkDir