vboxapi.py revision 5c57f3ae389a4fd2d1614c2a02a52bc7d56ee7b5
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync# Copyright (C) 2009 Sun Microsystems, Inc.
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync# available from http://www.virtualbox.org. This file is free software;
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync# you can redistribute it and/or modify it under the terms of the GNU
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync# General Public License (GPL) as published by the Free Software
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync# Clara, CA 95054 USA or visit http://www.sun.com if you need
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync# additional information or have any questions.
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsyncVboxBinDir = os.environ.get("VBOX_PROGRAM_PATH", None)
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync # Will be set by the installer
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsyncfrom VirtualBox_constants import VirtualBoxReflectionInfo
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync """ This class provides a wrapper over IPerformanceCollector in order to
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync get more 'pythonic' interface.
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync To begin collection of metrics use setup() method.
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync To get collected data use query() method.
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync It is possible to disable metric collection without changing collection
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync parameters with disable() method. The enable() method resumes metric
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync collection.
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync """ Initializes the instance.
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync """ Discards all previously collected values for the specified
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync metrics, sets the period of collection and the number of retained
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync samples, enables collection.
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync self.collector.setupMetrics(names, objects, period, nsamples)
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync """ Resumes metric collection for the specified metrics.
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync """ Suspends metric collection for the specified metrics.
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync """ Retrieves collected metric values as well as some auxiliary
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync information. Returns an array of dictionaries, one dictionary per
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync metric. Each dictionary contains the following entries:
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync 'name': metric name
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync 'object': managed object this metric associated with
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync 'unit': unit of measurement
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync 'scale': divide 'values' by this number to get float numbers
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync 'values': collected data
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync 'values_as_string': pre-processed values ready for 'print' statement
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync # Get around the problem with input arrays returned in output
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync # parameters (see #3953) for MSCOM.
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync (values, names, objects, names_out, objects_out, units, scales, sequence_numbers,
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync indices, lengths) = self.collector.queryMetricsData(names, objects)
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync (values, names_out, objects_out, units, scales, sequence_numbers,
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync indices, lengths) = self.collector.queryMetricsData(names, objects)
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync 'values':[int(values[j]) for j in xrange(int(indices[i]), int(indices[i])+int(lengths[i]))],
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync 'values_as_string':'['+', '.join([fmt % (int(values[j])/scale, units[i]) for j in xrange(int(indices[i]), int(indices[i])+int(lengths[i]))])+']'
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync 'setattr' : None}
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync # try case-insensitivity workaround for class attributes (COM methods)
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync self.__class__.__dict__[attr] = self.__class__.__dict__[k]
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync return _COMForward['getattr'](self,ComifyName(attr))
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync return _COMForward['setattr'](self, ComifyName(attr), value)
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync # Class to fake access to constants in style of foo.bar.boo
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync self.__dict__['_depth']=parent.__dict__['_depth']+1
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync if fake != None:
689e8c44f580478449d47bd48c9af52e82a028aevboxsync while parent != None:
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync if name is not None:
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync self.__dict__['_rootFake'] = PlatformMSCOM.ConstantFake(None, None)
ba0080e61ec19fbcb656e9652b099912e5cccc1avboxsync VBOX_TLB_GUID = '{46137EEC-703B-4FE5-AFD4-7C9BBBBA0259}'
import win32com
import pythoncom
import win32api
import win32com
import win32com
return False
import pythoncom
import pythoncom
exec (str,d,d)
import pythoncom
CloseHandle(h)
class PlatformXPCOM:
import xpcom
return False
import xpcom
import xpcom
str += "result = xpcom.components.classes['@virtualbox.org/VirtualBoxCallback;1'].createInstance()\n"
exec (str,d,d)
import xpcom
import xpcom
class PlatformWEBSERVICE:
import VirtualBox_services
import VirtualBox_wrappers
if params is not None:
if url is None:
if user is None:
if passwd is None:
return True
class SessionManager:
class VirtualBoxManager:
if style is None:
raise ne
except Exception,e:
return session