Current File : //usr/lib/python2.7/site-packages/vboxapi/__init__.pyc
�
$��]c@sdZdZdZddlZddlZddlZejddfkrZeZe Z
nddlZejj
de�aejj
de�atekr�ej�d kr�d
andanejjt�atekrej�d kr�dand
anejjt�atejd<tejd<ejjt�ddlmZdefd��YZd�Zied6ed6Zd�Zd�Zdefd��YZdefd��YZdefd��YZdefd��YZ eZ!defd ��YZ"dS(!s
VirtualBox Python API Glue.
s�
Copyright (C) 2009-2019 Oracle Corporation
This file is part of VirtualBox Open Source Edition (OSE), as
available from http://www.virtualbox.org. This file is free software;
you can redistribute it and/or modify it under the terms of the GNU
General Public License (GPL) as published by the Free Software
Foundation, in version 2 as it comes in the "COPYING" file of the
VirtualBox OSE distribution. VirtualBox OSE is distributed in the
hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
The contents of this file may alternatively be used under the terms
of the Common Development and Distribution License Version 1.0
(CDDL) only, as it comes in the "COPYING.CDDL" file of the
VirtualBox OSE distribution, in which case the provisions of the
CDDL are applicable instead of those of the GPL.
You may elect to license modified versions of this file under the
terms and conditions of either the GPL or the CDDL or both.
s$Revision: 131697 $i����NiitVBOX_PROGRAM_PATHt
VBOX_SDK_PATHtDarwins+/Applications/VirtualBox.app/Contents/MacOSs/usr/lib/virtualboxs//Applications/VirtualBox.app/Contents/MacOS/sdks/usr/lib/virtualbox/sdki(tVirtualBoxReflectionInfot
PerfCollectorcBs;eZdZd�Zd�Zd�Zd�Zd�ZRS(sz This class provides a wrapper over IPerformanceCollector in order to
get more 'pythonic' interface.
To begin collection of metrics use setup() method.
To get collected data use query() method.
It is possible to disable metric collection without changing collection
parameters with disable() method. The enable() method resumes metric
collection.
cCs+||_|jdk|_|j|_dS(s$ Initializes the instance.
tMSCOMN(tmgrttypetisMscomtperformanceCollectort collector(tselfRtvbox((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyt__init__[s cCs|jj||||�dS(s� Discards all previously collected values for the specified
metrics, sets the period of collection and the number of retained
samples, enables collection.
N(R
tsetupMetrics(Rtnamestobjectstperiodtnsamples((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytsetupcscCs|jj||�dS(s> Resumes metric collection for the specified metrics.
N(R
t
enableMetrics(RRR((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytenablejscCs|jj||�dS(s? Suspends metric collection for the specified metrics.
N(R
tdisableMetrics(RRR((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytdisableoscCs�|jr?|jj||�\
}}}}}}}}} }
n-|jj||�\}}}}}}} }
g}xPtdt|��D]9}t||�}
|
dkr�d}nd}|jit||�d6t||�d6t||�d6|
d6gtt| |�t| |�t|
|��D]}t||�^q.d 6d
djgtt| |�t| |�t|
|��D](}|t||�|
||f^q��dd
6�q�W|S(s� Retrieves collected metric values as well as some auxiliary
information. Returns an array of dictionaries, one dictionary per
metric. Each dictionary contains the following entries:
'name': metric name
'object': managed object this metric associated with
'unit': unit of measurement
'scale': divide 'values' by this number to get float numbers
'values': collected data
'values_as_string': pre-processed values ready for 'print' statement
iis%.2f%ss%d %stnametobjecttunittscaletvaluest[s, t]tvalues_as_string( RR
tqueryMetricsDatatxrangetlentinttappendtstrtjoin(RRRRt names_outtobjects_outtunitstscalestsequence_numberstindicestlengthstouttiRtfmttj((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytqueryts"
6- Oz(t__name__t
__module__t__doc__R
RRRR2(((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRNs cCs|dj�|dS(Nii(t
capitalize(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyt
ComifyName�stgetattrtsetattrcCs�|jjj|�}|dk r%|S|j�}x\t|jjj��D]B}|j�|krJt|j||jj|�t||�SqJWyt d|t
|��SWntk
r�t d||�SXdS(s0 Our getattr replacement for DispatchBaseClass. R8N(t __class__t__dict__tgettNonetlowertlisttkeysR9R8t_g_dCOMForwardR7tAttributeError(RtsAttrtoRett
sAttrLowertk((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyt_CustomGetAttr�s
cCsGytd|t|�|�SWn"tk
rBtd|||�SXdS(s0 Our setattr replacement for DispatchBaseClass. R9N(RAR7RB(RRCtoValue((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyt_CustomSetAttr�s
tPlatformBasecBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z
d �Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zed��ZRS(s4
Base class for the platform specific code.
cCs
|}dS(N((RtaoParamst_((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR
�scCsdS(s3
Gets a the IVirtualBox singleton.
N(R=(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyt
getVirtualBox�scCsdS(s�
Get a session object that can be used for opening machine sessions.
The oIVBox parameter is an getVirtualBox() return value, i.e. an
IVirtualBox reference.
See also openMachineSession.
N(R=(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytgetSessionObject�s cCsdS(s9 Returns the platform type (class name sans 'Platform'). N(R=(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytgetType�scCstS(sW
Returns True if remote (web services) and False if local (COM/XPCOM).
(tFalse(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytisRemote�scCs|}|}dS(s�
Retrives the value of the array attribute 'sAttrib' from
interface 'oInterface'.
This is for hiding platform specific differences in attributes
returning arrays.
N(R=(Rt
oInterfacetsAttribRL((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytgetArray�scCs|}|}|}dS(s�
Sets the value (aoArray) of the array attribute 'sAttrib' in
interface 'oInterface'.
This is for hiding platform specific differences in attributes
setting arrays.
N(R=(RRRRStaoArrayRL((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytsetArray�scCstS(sN
Does backend specific initialization for the calling thread.
(tTrue(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyt
initPerThreadscCstS(sP
Does backend specific uninitialization for the calling thread.
(RW(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytdeinitPerThreadscCs|}|}td��dS(sc
Instantiates and wraps an active event listener class so it can be
passed to an event source for registration.
oImplClass is a class (type, not instance) which implements
IEventListener.
dArgs is a dictionary with string indexed variables. This may be
modified by the method to pass platform specific parameters. Can
be None.
This currently only works on XPCOM. COM support is not possible due to
shortcuts taken in the COM bridge code, which is not under our control.
Use passive listeners for COM and web services.
s%No active listeners for this platformN(t Exception(Rt
oImplClasstdArgsRL((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytcreateListenerscCs
|}dS(s>
Wait for events to arrive and process them.
The timeout (cMsTimeout) is in milliseconds for how long to wait for
events to arrive. A negative value means waiting for ever, while 0
does not wait at all.
Returns 0 if events was processed.
Returns 1 if timed out or interrupted in some way.
Returns 2 on error (like not supported for web services).
Raises an exception if the calling thread is not the main thread (the one
that initialized VirtualBoxManager) or if the time isn't an integer.
i((Rt
cMsTimeoutRL((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyt
waitForEvents"scCstS(s�
Interrupt a waitForEvents call.
This is normally called from a worker thread to wake up the main thread.
Returns True on success, False on failure.
(RP(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytinterruptWaitEvents4scCsdS(s<
Unitializes the platform specific backend.
N(R=(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytdeinit=scCsdS(s�
IUnknown::QueryInterface wrapper.
oIUnknown is who to ask.
sClassName is the name of the interface we're asking for.
N(R=(Rt oIUnknownt
sClassName((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytqueryInterfaceCscCsdS(sP
Returns the COM status code from the VBox API given exception.
N(R=(RtoXcpt((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyt
xcptGetStatusPscCstS(sc
Returns True if the exception indicates that the interface is dead, False if not.
(RP(RRe((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytxcptIsDeadInterfaceVscCs{y|j|�}Wntk
r'tSX||kr8tSd|koOdknrw|dkrw|d|krwtSntS(s?
Checks if the exception oXcpt is equal to the COM/XPCOM status code
hrStatus.
The oXcpt parameter can be any kind of object, we'll just return True
if it doesn't behave like a our exception class.
Will not raise any exception as long as hrStatus and self are not bad.
i���I����iI(RfRBRPRW(RRethrStatusthrXcpt((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytxcptIsEqual\s
(cCsdS(s�
Returns the best error message found in the COM-like exception.
Returns None to fall back on xcptToString.
Raises exception if oXcpt isn't our kind of exception object.
N(R=(RRe((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytxcptGetMessagesscCsdS(s3
Returns the base exception class.
N(R=(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytxcptGetBaseXcpt{scCs|S(s>
Copy/whatever all error constants onto oDst.
((RtoDst((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytxcptSetupConstants�scCs�x{t|�D]m}|dj�r
|dj�sC|ddkr
t||�}t|�tkrzt|||�qzq
q
W|S(sT
Copy everything that looks like error constants from oDst to oSrc.
iiRL(tdirtisupperR8RR#R9(RmtoSrcRCtoAttr((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytxcptCopyErrorConstants�s0(R3R4R5R
RMRNRORQRTRVRXRYR]R_R`RaRdRfRgRjRkRlRntstaticmethodRs(((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRJ�s,
t
PlatformMSCOMcBs�eZdZdZdZdZdZd�Zd�Zd�Z d�Z
d �Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(s,
Platform specific code for MS COM.
s&{D7569351-1750-46F0-936E-BD127D5BC264}iiic CsPtj||�ddlm}ddlm}m}ddlm}m}ddl}ddl }ddl
} ddl}
ddlm
}ddl
m}m}
m}m}ddl}|
|_y/|jddd|j|jd|jd�WnVtj�\}}}t||j�r<|j|�dkr<dGHqKd tfGHnX|
�|_|�}|||�|d
d
|�g|_t ddkr�|j!dt d
<|j!dt d<t"|dt#�t"|dt$�n|j%|j&j�|j&jj'd�|j&jj'd�|j&jj'd�d|_(|j)�|_*t+|_,|}dS(Ni����(t universal(tgencachetDispatchBaseClass(t constantst getevents(tDUPLICATE_SAME_ACCESS(tGetCurrentThreadtGetCurrentThreadIdtDuplicateHandletGetCurrentProcessi�s0Warning: CoInitializeSecurity was already calleds&Warning: CoInitializeSecurity failed: iR9t__getattr__R8t__setattr__sVirtualBox.SessionsVirtualBox.VirtualBoxsVirtualBox.VirtualBoxClient(-RJR
twin32comRvtwin32com.clientRwRxRyRzt pythoncomtwin32apitwinerrortwin32conR{R|R}R~Rt threadingtCoInitializeSecurityR=tRPC_C_AUTHN_LEVEL_DEFAULTtRPC_C_IMP_LEVEL_IMPERSONATEt EOAC_NONEtsystexc_infot
isinstancet com_errorRftoXctpttidt aoHandlesRAR;R9RGRItflushGenPyCachetclienttEnsureDispatchtoClientt ConditiontoIntCvRPtfInterrupted(RtdParamsRvRwRxRyRzR�R�R�R�R{R|R}R~RR�RLRetpid((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR
�sT" ' $
cCs�|j|j|j|j|j�}|j�}t|�dkr�t|�dkr�tjj ||�}tjj
|�r�ddl}|j|dt
�q�n|j|j|j|j|j�S(s�
Flushes VBox related files in the win32com gen_py cache.
This is necessary since we don't follow the typelib versioning rules
that everyeone else seems to subscribe to.
i$ii����Nt
ignore_errors(tGetGeneratedFileNamet
VBOX_TLB_GUIDt
VBOX_TLB_LCIDtVBOX_TLB_MAJORtVBOX_TLB_MINORtGetGeneratePathR"tostpathR&tisdirtshutiltrmtreeRWtEnsureModule(Rt oGenCachetsNametsGenPathtsTypelibPathR�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR��s$cCs,ddl}ddlm}|jjd�S(Ni����(tDispatchsVirtualBox.Session(R�R�R�R�(RR�R�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRNscCsM|jdkrCddl}ddlm}|jjd�|_n|jjS(Ni����(R�sVirtualBox.VirtualBoxClient(R�R=R�R�R�R�t
virtualBox(RR�R�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRM
s
cCsdS(NR((R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyROscCs
|j|�S(N(R�(RRRRS((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRTscCs�t|d�}t|d�}t|d�}||kr?|n t|�}y||\}} ||}
Wntk
r�|j||�SXddl}|j|d|d|d|jdf|
df|�dS(Nt_oleobj_t_prop_map_get_t_prop_map_put_i����iii(R8R7tKeyErrorR�R�tInvokeTypest
VT_HRESULT(RRRRSRUtoOleObjtaPropMapGettaPropMapPutt
sComAttribtaArgstaDefaultArgstaGetArgsR�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRVs
cCsddl}|jd�dS(Ni����i(R�tCoInitializeEx(RR�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRX5scCsddl}|j�dS(Ni����(R�tCoUninitialize(RR�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRY9scBs�ered��ni}||d<||d<ej|d<ej|d<ej|d<d}|d7}|d 7}|d
7}|d7}|d7}|d
7}|d7}|d7}|d7}|d7}|d7}|||fdU|dS(Ns�no active listeners on Windows as PyGatewayBase::QueryInterface() returns new gateway objects all the time, thus breaking EventQueue assumptions about the listener interface pointer being constants between calls t BaseClassR\ttlb_guidt tlb_majort tlb_minortsimport win32com.server.util
simport pythoncom
sclass ListenerImpl(BaseClass):
s) _com_interfaces_ = ['IEventListener']
s _typelib_guid_ = tlb_guid
s, _typelib_version_ = tlb_major, tlb_minor
s1 _reg_clsctx_ = pythoncom.CLSCTX_INPROC_SERVER
sC _reg_policy_spec_ = 'win32com.server.policy.EventHandlerPolicy'
s% HandleEvent=BaseClass.handleEvent
s7 def __init__(self): BaseClass.__init__(self, dArgs)
s3result = win32com.server.util.wrap(ListenerImpl())
tresult(RWRZRuR�R�R�(RR[R\tdtstr_((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR]=s,
cCsjddlm}ddlm}ddlm}m}m}m}ddlm }ddl
} t|t�s|t
d��n|j|�kr�td��n|dkr�|}
n|}
||jd|
|�}||ko�|t|j�knrd }n/||t|j�kr+|�d}nd
}|jj�|jrYt|_d
}n|jj�|S(Ni����(R}(tINFINITE(tMsgWaitForMultipleObjectstQS_ALLINPUTtWAIT_TIMEOUTt
WAIT_OBJECT_0(tPumpWaitingMessagess&The timeout argument is not an integers0wait for events from the same thread you inited!iii(R�R}t
win32eventR�R�R�R�R�R�R�ttypesR�R#t TypeErrorR�RZR�R"R�tacquireR�RPtrelease(RttimeoutR}R�R�R�R�R�R�R�R^trc((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR_\s2" )
cCslddlm}ddlm}|jj�t|_|jj�y||j |dd�WntSXtS(sJ
Basically a python implementation of NativeEventQueue::postEvent().
The magic value must be in sync with the C++ implementation or this
won't work.
Note that because of this method we cannot easily make use of a
non-visible Window to handle the message like we would like to do.
i����(tPostThreadMessage(tWM_USERI�A�N(R�R�R�R�R�R�RWR�R�R�R=RP(RR�R�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR`�s
cCsIx*|jD]}|dk r
|j�q
q
Wd|_|`d|_dS(N(R�R=tClosetoHandleR�(RR�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRa�s cCsddlm}|||�S(Ni����(tCastTo(R�R�(RRbRcR�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRd�scCs=|j}||jjkr9y|jd}Wq9q9Xn|S(Ni(thresultR�tDISP_E_EXCEPTIONt excepinfo(RReRi((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRf�s cCs|j|�dkS(NI��i��I��i��I��i��I�i�I��i��(
I��i��I��i��I��i��I�i�I��i��(Rf(RRe((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRg�scCs�t|d�r_yCt|j�dkrQ|jd}t|�dkrQ|dSnWq_q_Xnt|d�r�y#|j}t|�dkr�|SWq�q�XndS(NR�iiitstrerror(thasattrR"R�R�R=(RRetsRet((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRk�s
cCsddl}|jS(Ni����(R�R�(RR�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRl�scCs�ddl}|j||�}|j|_|j|_|j|_|j|_ |j
|_|j|_
|j|_|j|_|j|_|S(Ni����(R�RstS_OKtNS_OKtE_FAILtNS_ERROR_FAILUREtE_ABORTtNS_ERROR_ABORTt E_POINTERtNS_ERROR_NULL_POINTERt
E_NOINTERFACEtNS_ERROR_NO_INTERFACEtE_INVALIDARGtNS_ERROR_INVALID_ARGt
E_OUTOFMEMORYtNS_ERROR_OUT_OF_MEMORYt E_NOTIMPLtNS_ERROR_NOT_IMPLEMENTEDtE_UNEXPECTEDtNS_ERROR_UNEXPECTED(RRmR�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRn�s(R3R4R5R�R�R�R�R
R�RNRMRORTRVRXRYR]R_R`RaRdRfRgRkRlRn(((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRu�s0 E % t
PlatformXPCOMcBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z
d �Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�ZRS(s+
Platform specific code for XPCOM.
cCsRtj||�tjjtd�ddl}ddl}ddl}|}dS(Ns/bindings/xpcom/python/i����( RJR
R�R�R$t
VBoxSdkDirtxpcom.vboxxpcomtxpcomtxpcom.components(RR�R�RL((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR
�scCs ddl}|jjdj�S(Ni����s@virtualbox.org/Session;1(R�t
componentstclassestcreateInstance(RR�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRN�scCs)ddl}|jjdj�}|jS(Ni����s"@virtualbox.org/VirtualBoxClient;1(R�R�R�R�R�(RR�R�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRM�scCsdS(NtXPCOM((R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRO�scCs|jdt|���S(NR<(R�R7(RRRRS((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRT�scCs|jdt|��|�S(Ntset(R�R7(RRRRSRU((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRVscCsddl}|jj�dS(Ni����(R�t_xpcomtAttachThread(RR�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRXscCsddl}|jj�dS(Ni����(R�R�tDetachThread(RR�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRY scBski}||d<||d<d}|d7}|d7}|d7}|d7}|d7}|||fdU|d S(
NR�R\R�simport xpcom.components
sclass ListenerImpl(BaseClass):
sA _com_interfaces_ = xpcom.components.interfaces.IEventListener
s7 def __init__(self): BaseClass.__init__(self, dArgs)
sresult = ListenerImpl()
R�((RR[R\R�R%((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR]
s
cCsddl}|jj|�S(Ni����(R�R�t
WaitForEvents(RR�R�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR_scCsddl}|jj�S(Ni����(R�R�t
InterruptWait(RR�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR`scCsddl}|jj�dS(Ni����(R�R�t DeinitCOM(RR�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRa"scCs(ddl}|jt|jj|��S(Ni����(R�RdR8R�t
interfaces(RRbRcR�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRd&scCs|jS(N(terrno(RRe((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRf*scCs|j|�dkS(NI@�i@�I��i��(I@�i@�I��i��(Rf(RRe((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRg-scCsCt|d�r?y#|j}t|�dkr1|SWq?q?XndS(Ntmsgi(R�RR"R=(RReR�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRk3s cCsddl}|jS(Ni����(R�RZ(RR�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRl=scCs�ddl}|j||j�}d|_|j|_|j|_|j|_ |j
|_|j|_
|j|_|j|_|j|_|j|_d|_|S(Ni����i�i �(R�RstnsErrortE_ACCESSDENIEDR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�(RRmR�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRnAs (R3R4R5R
RNRMRORTRVRXRYR]R_R`RaRdRfRgRkRlRn(((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR��s&
tPlatformWEBSERVICEcBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z
d �Zd
�Zd�Z
d�Zd
�ZRS(s4
VirtualBox Web Services API specific code.
cCs�tj||�tjjtdddd�}|tjkrPtjj|�nddl}ddlm }|dk r�|jdd�|_|jd d�|_
|jd
d�|_nd|_d|_
d|_d|_d|_dS(Ntbindingst
webservicetpythontlibi����(tIWebsessionManager2tuserR�tpasswordturl(RJR
R�R�R&R�R�R$tVirtualBox_wrappersRR=R<RR
RRtwsmgr(RR�tsWebServLibRR((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR
Ys cCs|jj|j�S(N(RRNR(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRNrscCs|j|j|j|j�S(N(tconnectRRR
(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRMuscCsdS(Nt
WEBSERVICE((R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyROxscCstS(s3 Returns True if remote VBox host, False if local. (RW(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRQ{scCs
|j|�S(N(R�(RRRRS((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRTscCs|j||�S(N(R�(RRRRSRU((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRV�scCsdS(Ni((RR�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR_�scCstS(N(RP(RR�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR`�scCsy|j�WnnXdS(N(t
disconnect(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRa�scBsSi}||d<d}|d|d7}|d|d7}|||fdU|dS(NRbR�s from VirtualBox_wrappers import s
s result = s"(oIUnknown.mgr, oIUnknown.handle)
R�((RRbRcR�R%((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRd�s
cCs�|jdk r|j�nddlm}|dkrAd}n||_|dkr_d}n||_|dkr}d}n||_||j�|_|jj |j|j�|_|jj
s�td|jd|jd��n|jS(Ni����(RR�scannot connect to 's' as 't'(RR=RRRRRR
RtlogonthandleRZ(RRRtpasswdR((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR�s"
%cCsJ|jdk rF|jdk rF|jj|j�d|_d|_ndS(N(RR=Rtlogoff(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR�s (R3R4R5R
RNRMRORQRTRVR_R`RaRdRR(((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRTs tVirtualBoxManagercBsGeZdZdefd��YZddd�Zd�Zd�Ze d��Z
d�Zdd�Zd �Z
d
�Zdd�Zd�Zd
�Zd�Zd�Zd�Zd�Zed�Zd�Zd�Zd�Zd�Zed�Zdd�Zdd�Zdd�Z d�Z!d�Z"dd�Z#dd�Z$RS( s�
VirtualBox API manager class.
The API users will have to instantiate this. If no parameters are given,
it will default to interface with the VirtualBox running on the local
machine. sStyle can be None (default), MSCOM, XPCOM or WEBSERVICES. Most
users will either be specifying None or WEBSERVICES.
The dPlatformParams is an optional dictionary for passing parameters to the
WEBSERVICE backend.
tStatusescBseZd�ZRS(cCsdS(N((R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR
�s(R3R4R
(((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR�scCs�|dkr-tjdkr$d}q-d}n|dkrKt|�|_nO|dkrit|�|_n1|dkr�t|�|_ntd|f��||_|jj�|_ |jj
�|_t|dk�|_
|jjtj��|_d|_i|_|jj�|_|jay|jj�}Wn]tk
r\dGHtj��n;tk
r�tj�\}}}d|fGHtj�nXdS(Ntwin32RR�RsUnknown sStyle=%ss:Installation problem: check that appropriate libs in placesinit exception: (R=R�tplatformR�RuRRZtstyleRORRQtremoteRRyRnRRtstatusest_dErrorValToNamet_ddEnumValueToNameRlt
oXcptClasstCurXcptClassRMt NameErrort tracebackt print_excR�(RtsStyletdPlatformParamsRRLte((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR
�s<
cCs|j�dS(N(Ra(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyt__del__scCsdS(s~
Returns a Python API revision number.
This will be incremented when features are added to this file.
i((R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytgetPythonApiRevisionscCs|S(s�
This used to be an attribute referring to a session manager class with
only one method called getSessionObject. It moved into this class.
((R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRscCs
|jj�S(s$ See PlatformBase::getVirtualBox(). (RRM(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRMscCs|}|jj�S(s' See PlatformBase::getSessionObject(). (RRN(RtoIVBoxRL((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRNscCs|jj||�S(s See PlatformBase::getArray(). (RRT(RRRRS((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRT$scCs|jj|||�S(s See PlatformBase::setArray(). (RRV(RRRRSRU((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRV(scCs|jj||�S(s% See PlatformBase::createListener(). (RR](RR[R\((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR],scCs|jj|�S(s$ See PlatformBase::waitForEvents(). (RR_(RR^((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR_0scCs
|jj�S(s* See PlatformBase::interruptWaitEvents(). (RR`(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR`4scCs|jj||�S(s% See PlatformBase::queryInterface(). (RRd(RRbRc((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRd8scCs|jj�dS(s& See PlatformBase::deinitPerThread(). N(RRX(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRX?scCs
|jj�S(s& See PlatformBase::deinitPerThread(). (RRY(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRYCscCs;t|d�r7|jdk r7|jj�d|_ntS(sc
For unitializing the manager.
Do not access it after calling this method.
RN(R�RR=RaRW(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRaGs
cCsA|j�}|r!|jj}n|jj}|j||�|S(s�
Attempts to open the a session to the machine.
Returns a session object on success.
Raises exception on failure.
(RNRytLockType_SharedtLockType_WritetlockMachine(Rt oIMachinetfPermitSharingtoSessionteType((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytopenMachineSessionTscCs|dk r|j�ntS(sa
Closes a session opened by openMachineSession.
Ignores None parameters.
N(R=t
unlockMachineRW(RR3((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytcloseMachineSessionbs
cCs
t||�S(s�
Returns a helper class (PerfCollector) for accessing performance
collector goodies. See PerfCollector for details.
(R(RR-((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytgetPerfCollectorkscCstS(s:
Returns the VirtualBox binary directory.
(t
VBoxBinDir(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyt getBinDirrscCstS(s7
Returns the VirtualBox SDK directory.
(R�(R((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyt getSdkDiryscCs�|jj|�}|dk rN|j|�}|r�|s=|Sd||fSn�|jj|�}t|�dkr�t�}x|D]}||||<q�W||j|<|j|�}|r�|s�|Sd||fSnd||fS(sM
Returns the name (string) for the corresponding enum value.
s%s_%sis
%s_Unknown_%sN(R"R<R=Ryt
all_valuesR"tdict(RtsEnumTypeNmt
oEnumValuetfTypePrefixtdValueNamest
sValueNametdNamedValuesR�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytgetEnumValueName�s
cCs/|dkrtj�d}n|jj|�S(s�
Gets the status code from an exception. If the exception parameter
isn't specified, the current exception is examined.
iN(R=R�R�RRf(RRe((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRf�scCs/|dkrtj�d}n|jj|�S(s�
Returns True if the exception indicates that the interface is dead,
False if not. If the exception parameter isn't specified, the current
exception is examined.
iN(R=R�R�RRg(RRe((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRg�scCsB|jdkrtS|dkr2tj�d}nt||j�S(s�
Checks if the exception is one that could come from the VBox API. If
the exception parameter isn't specified, the current exception is
examined.
iN(R#R=RPR�R�R�(RRe((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytxcptIsOurXcptKind�s
cCs2|dkrtj�d}n|jj||�S(s�
Checks if the exception oXcpt is equal to the COM/XPCOM status code
hrStatus.
The oXcpt parameter can be any kind of object, we'll just return True
if it doesn't behave like a our exception class. If it's None, we'll
query the current exception and examine that.
Will not raise any exception as long as hrStatus and self are not bad.
iN(R=R�R�RRj(RReRh((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRj�scCs|j||�S(s&
Negated xcptIsEqual.
(Rj(RReRh((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytxcptIsNotEqual�scCs
|dks|j|�r-|j|�}n|}|jdkr�t�}xdt|j�D]S}|dj�r[t|j|�}t |t
tf�r�||t
|�<q�q[q[W||_ny|jt
|�}Wn1tk
rt|�}d|d@|f}nX|S(s�
Converts the specified COM status code, or the status code of the
specified exception, to a C constant string. If the parameter isn't
specified (is None), the current exception is examined.
is%#x (%d)I����N(
R=RERfR!R=RoR RpR8R�R#tlongR�(RthrStatusOrXcptRhtdErrorValToNametsKeyRHtsStrthrLong((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pytxcptToString�s"
cCsS|dkrtj�d}n|jj|�}|dkrO|j|�}n|S(s�
Returns the best error message found in the COM-like exception. If the
exception parameter isn't specified, the current exception is examined.
iN(R=R�R�RRkRM(RReR�((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyRk�sN(%R3R4R5RRR=R
R+R,tpropertyRRMRNRTRVR]R_R`RdRXRYRaRWR5R7R8R:R;RPRDRfRgRERjRFRMRk(((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyR�s</
(#R5t
__copyright__t__version__R�R�R&tversion_infotrangeR!R#RGRtenvironR<R=R9R�tsystemR�tabspathR$tVirtualBox_constantsRRRR7RARGRIRJRuR�RtCurXctpClassR(((s4/usr/lib/python2.7/site-packages/vboxapi/__init__.pyt<module>sN
O
��Snn