%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/virtualbox/
Upload File :
Create Path :
Current File : //usr/lib/virtualbox/vboxshell.pyc

�
M�\c@s.dZddlmZdZdZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZddlmZeadadaeayddlZddlZWnek
r�eanXdZeaid	d
6dd6d
d6dd6dd6dd6Zd�ZtrWdejfd��YZnd�Z ea!d�Z"dd�Z#d�Z$d�Z%d�Z&d�Z'd �Z(d!�Z)d"�Z*d#�Z+d$�Z,d%�Z-d&�Z.d'�Z/d(d1d)��YZ0d*�Z1eed+�Z2d,�Z3d-�Z4d.�Z5d/�Z6d0�Z7d1�Z8d2�Z9d3�Z:d4�Z;d5a<d6�Z=d7�Z>d8�Z?d9�Z@d:�ZAd;�ZBd<�ZCd=�ZDd>�ZEd?�ZFd@�ZGdA�ZHdB�ZIdC�ZJdD�ZKgedE�ZLgedF�ZMdG�ZNdHd2dI��YZOdJeOfdK��YZPdLeOfdM��YZQdNePfdO��YZRdPeOfdQ��YZSdRePfdS��YZTdTeOfdU��YZUdVeOfdW��YZVdX�ZWdY�ZXdZ�ZYd[�ZZd\�Z[d]�Z\d^�Z]d_�Z^d`�Z_da�Z`db�Zadddc�Zbdd�Zcdedf�Zddg�Zedh�Zfdi�Zgdj�Zhdk�Zidl�Zjdm�Zkdn�Zldo�Zmdp�Zndq�Zodr�Zpds�Zqdt�Zrdu�Zsdv�Ztdw�Zudx�Zvdy�Zwdz�Zxd{�Zyd|�Zzd}�Z{d~�Z|d�Z}d��Z~d��Zd��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�i1d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6Z�i%d�gd�6d�gd6d�gd6d�gd6dgd6d�gd6dgd6dgd	6d
dgd6d
d
gd6d
dgd6d
dgd6d
dgd6d
dgd6d
dgd6d
dgd6dgd6d
dgd6dgd6d
dgd 6d
d!gd"6d#gd$6d%gd&6d'gd(6d)gd*6d+gd,6d-gd.6d/gd06d1gd26d3gd46d5gd66d7gd86d9gd:6d
d;gd<6d
d=gd>6d
d?gd@6d
dAgdB6Z�dC�Z�dD�Z�dE�Z�dF�Z�dG�Z�dH�Z�dI�Z�dJ�Z�dK�Z�dL�Z�dM�Z�dN�Z�dO�Z�dP�Z�dQ�Z�dR�Z�dS�Z�dT�Z�dU�Z�dV�Z�dW�Z�dX�Z�dY�Z�dZ�Z�d[�Z�d\�Z�d]�Z�d^�Z�d_�Z�d`�Z�da�Z�db�Z�dc�Z�dd�Z�de�Z�gdf�Z�dg�Z�dh�Z�di�Z�dj�Z�dk�Z�dl�Z�dm�Z�dn�Z�do�Z�dp�Z�dq�Z�dr�Z�ds�Z�dt�Z�du�Z�dv�Z�dw�Z�dx�Z�dy�Z�dz�Z�d{�Z�d|�Z�d}�Z�d~�Z�d�Z�d��Z�i	d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6Z�iRd�eZd5gd�6d�e_d5gd�6d�e`d5gd�6d�ejd5gd�6d�ekd5gd�6d�end5gd�6d�eod5gd�6d�epd5gd�6d�eld5gd�6d�emd5gd�6d�e]d5gd�6d�e^d5gd�6d�ead5gd�6d�efd5gd�6d�egd5gd�6d�eid5gd�6d�e�d5gd�6d�e�d5gd�6d�e|d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�eqd5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�erd5gd�6d�esd5gd�6d�e�d5gd�6d�eud5gd�6d�evd5gd�6d�e�d5gd�6d�e~d5gd�6d�ewd5gd�6d�eyd5gd�6d�ezd5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd�6d�e�d5gd6de�d5gd6de�d5gd6de�d5gd6de�d5gd6d	e�d5gd
6de�d5gd6d
e�d5gd6de�d5gd6de�d5gd6de�d5gd6de�d5gd6de�d5gd6de�d5gd6de�d5gd6de�d5gd6de�d5gd 6d!e�d5gd"6d#e�d5gd$6d%e�d5gd&6Z�d'�Z�d(�Z�d)�Z�d*�Z�d+�Z�d,�Z�d-�Z�d.�Z�d/�Z�e�d0kr*e�ej��ndS(3s1
VirtualBox Python Shell.

This program is a simple interactive shell for VirtualBox. You can query
information and issue commands from a simple command line.

It also provides you with examples on how to use VirtualBox's Python API.
This shell is even somewhat documented, supports TAB-completion and
history if you have Python readline installed.

Finally, shell allows arbitrary custom extensions, just create
.VirtualBox/shexts/ and drop your extensions there.
                                               Enjoy.

P.S. Our apologies for the code quality.
i����(tprint_functions�
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.
s$Revision: 129735 $N(tOptionParser(tpprintsvbox> stredstbluestgreenstyellowstmagentastcyancCs8ts
|Stj|d�}|r4|t|�dS|S(sM
    Translates a string to one including coloring settings, if enabled.
    sN(tg_fHasColorst
g_dTermColorstgettNonetstr(tstrgtcolortcol((s /usr/lib/virtualbox/vboxshell.pytcoloredNstCompleterNGcBs>eZd�Zd�Zd�Zd�Zd�Zd�ZRS(cCs ||_tjj||�dS(N(tctxtrlcompletert	Completert__init__(tselftdicR((s /usr/lib/virtualbox/vboxshell.pyR[s	cCs:tr |dkr ddg|Stjj|||�SdS(sp
            taken from:
            http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496812
            ts	N(tFalseRRRtcomplete(Rttexttstate((s /usr/lib/virtualbox/vboxshell.pyR_scCs
|jd�S(Nt/(t
startswith(Rt_phrasetword((s /usr/lib/virtualbox/vboxshell.pyt	canBePathiscCsT|jd�}tj�}|dkp0||k}|r=tS|jd�rPtStS(Nt i����thelp(tfindtreadlinet
get_begidxtTrueRR(Rtphraset_wordtspaceIdxtbegIdxt	firstWord((s /usr/lib/virtualbox/vboxshell.pytcanBeCommandlscCs$|j||�o#|j||�S(N(R"R.(RR)R!((s /usr/lib/virtualbox/vboxshell.pytcanBeMachinevscCs�g}tj�}y�|j||�r�tjj|�\}}t|�}xUtj|�D]A}|dks}|| |kr[|jtjj	||��q[q[Wn|j
||�rt|�}xH|jgD]7}x.|D]&}|| |kr�|j|�q�q�Wq�Wn|j||�r�t|�}x�t
|jtt�D]s}	tjddt|	j��}|| |kr�|j|�nt|	j�}|| |kr@|j|�q@q@WnWn6tk
r�}
t|j|
�tr�tj�q�nX|S(s�
            Compute matches when text is a simple name.
            Return a list of all names currently defined
            in self.namespace that match.
            is(?<!\\) s\ (R&tget_line_bufferR"tostpathtsplittlentlistdirtappendtjoinR.t	namespaceR/tgetMachinesRRR(tretsubR
tnametidt	ExceptiontprintErrt
g_fVerboset	tracebackt	print_exc(RRtmatchesR)t	directorytresttcR!tlsttmachte((s /usr/lib/virtualbox/vboxshell.pytglobal_matchesys:&
(t__name__t
__module__RRR"R.R/RJ(((s /usr/lib/virtualbox/vboxshell.pyRZs		
		
	cCs�ts
dSi}x*t|j��D]\}}d||<q#Wt||�}tj|j�tj�}tj	t
jdd|��tjd�t
j�dkr�tjd�tjd�ntjd�dS(Ns[\./-]Rsset editing-mode emacstDarwinsbind ^I rl_completesbind ^W ed-delete-prev-words
tab: complete(tg_fHasReadlinetlisttitemsRRR&t
set_completerRtget_completer_delimstset_completer_delimsR:R;tparse_and_bindtplatformtsystem(tcmdsRtcompstkeyt_valuet	completertdelims((s /usr/lib/virtualbox/vboxshell.pytautoCompletion�s

cCs
tj|�S(N(tshlexR3(ts((s /usr/lib/virtualbox/vboxshell.pytsplit_no_quotes�si�cCs�y�x^|jsctdtt|j�d�dd�tjj�|j|�|dj	d�qWt
|j�dkr�t||�ndSWnFt
k
r�td�t|d	<|jr�td
�|j�ndSXdS(Ns%s %%
RtendRtglobaliisInterrupted.t	interruptsCanceling task...(t	completedtprintRR
tpercenttsyststdouttflushtwaitForCompletiont
waitForEventstintt
resultCodetreportErrortKeyboardInterruptR(t
cancelabletcancel(Rtprogresstwait((s /usr/lib/virtualbox/vboxshell.pytprogressBar�s &




	

cCsh|d}|j|�rKttd|j|�|j|�fd��nttt|�d��dS(NRbs%s: %sR(terrIsOurXcptKindReRtxcptToStringtxcptGetMessageR
(t_ctxRItoVBoxMgr((s /usr/lib/virtualbox/vboxshell.pyR?�s
2cCs9|j}|r5ttd|j|jfd��ndS(NsError in module '%s': %sR(t	errorInfoReRt	componentR(RxRrt	errorinfo((s /usr/lib/virtualbox/vboxshell.pyRn�s	cCs
t|d�S(NR(R(RxR((s /usr/lib/virtualbox/vboxshell.pytcolCat�scCs
t|d�S(NR(R(Rxtvmname((s /usr/lib/virtualbox/vboxshell.pytcolVm�scCs
t|d�S(NR(R(RxR2((s /usr/lib/virtualbox/vboxshell.pytcolPath�scCs
t|d�S(NR(R(Rxtbyte((s /usr/lib/virtualbox/vboxshell.pytcolSize�scCs
t|d�S(NR(R(Rxtpcidev((s /usr/lib/virtualbox/vboxshell.pytcolPci�scCs
t|d�S(NR(R(RxR�((s /usr/lib/virtualbox/vboxshell.pytcolDev�scCstt|�dd�S(NtMR(RR
(Rxtmbyte((s /usr/lib/virtualbox/vboxshell.pytcolSizeM�scCs]|d}|jd|g|d�}|j�td|j�|j|�t|t�dS(NtvbRscreated machine with UUID(t
createMachinetsaveSettingsReR=tregisterMachineR9R((RR<tkindtvboxRH((s /usr/lib/virtualbox/vboxshell.pytcreateVm�s


cCs�|j}td|jd|�t||tdg�|j|djj�}|r�|j|�}t	||d�r�t
|j�dkr�td�q�t||�nt
|t�dS(Nsremoving machine s	with UUIDtALLRbidisSuccess!(R=ReR<tcmdClosedVmtdetachVmDevicet
unregistert	constantstCleanupMode_FulltdeleteConfigRtRlRmRnR9R((RRHtuuidtdisksRr((s /usr/lib/virtualbox/vboxshell.pytremoveVm�s	'
cCs�|d}|d}|dj�}|j||d�}t||d�r�t|j�dkr�|r�y |jdg|gdd	�Wq�tk
r�}t||�tr�t	j
�q�q�Xn|j�ndS(
NR�tperfRbRidit*i
i(tgetSessionObjecttlaunchVMProcessRtRlRmtsetupR>R?R@RARBt
unlockMachine(RRHtvmtypeR�R�tsessionRrRI((s /usr/lib/virtualbox/vboxshell.pytstartVm
s

' 
t
CachedMachcBseZd�ZRS(cCs1|jr|j|_n	d|_|j|_dS(Ns<inaccessible>(t
accessibleR<R=(RRH((s /usr/lib/virtualbox/vboxshell.pyRs		(RKRLR(((s /usr/lib/virtualbox/vboxshell.pyR�scCs4g}x'|D]}t|�}|j|�q
W|S(N(R�R6(RxRGtresultRHtelem((s /usr/lib/virtualbox/vboxshell.pyt
cacheMachines#s

cCs|ddk	rw|ddks&|r^|dj|dd�|d<t||d�|d<n|rl|dS|dSngSdS(NR�t	_machlistRbtmachinest_machlistsimple(RtgetArrayR�(Rt
invalidatetsimple((s /usr/lib/virtualbox/vboxshell.pyR9*scCs$|rtdd�Stdd�SdS(NtonRtoff(R(tvar((s /usr/lib/virtualbox/vboxshell.pytasState6s
cCs|r
dSdSdS(Ntyestno((R�((s /usr/lib/virtualbox/vboxshell.pytasFlag<scCs%|j|�\}}t|d|�S(NtAdditionsFacilityStatus(tgetFacilityStatust
asEnumElem(RtguesttfacilityTypetstatust
_timestamp((s /usr/lib/virtualbox/vboxshell.pyR�BscCsN|dsdSx9|djdg|g�D]}t|d|d�q+WdS(NR�R�R<tvalues_as_string(tqueryRe(RRHtmetric((s /usr/lib/virtualbox/vboxshell.pyt	perfStatsFs
#cBs|dUdS(N((RtmachinetconsoleRW((s /usr/lib/virtualbox/vboxshell.pyt	guestExecLscCs6td|j|j|j|j|j|jf�dS(Ns.Mouse : mode=%d x=%d y=%d z=%d w=%d buttons=%x(Retmodetxtytztwtbuttons(Rxtmev((s /usr/lib/virtualbox/vboxshell.pytprintMouseEventOscCs!td|dj|d��dS(NsKbd: Rbt	scancodes(ReR�(Rtkev((s /usr/lib/virtualbox/vboxshell.pyt
printKbdEventRsc	Cs�td|j|jf�|dj|d�}|dj|d�}|dj|d�}|dj|d�}xGtd|j�D]3}td|||||||||f�q�WdS(	Ns MultiTouch : contacts=%d time=%dRbt
xPositionst
yPositionst
contactIdstcontactFlagsis  [%d] %d,%d %d %d(RetcontactCounttscanTimeR�trange(RtmtevR�R�R�R�ti((s /usr/lib/virtualbox/vboxshell.pytprintMultiTouchEventUsc	sG�fd��dtf��fd��Y}|rJ�dj|�}n|j�}t}|dkrqd}ny�|j|�djjg|�t}tj�|}xetj�|kr|r��djd�q�|j	|d�}|r��|�|j
||�q�q�WWntj�nX|rC|rC|j
|�ndS(Nc
s�|j}tdt|�t�d|�f�|�djjkr��dj|d�}|r~td|j|jf�q~n�|�djj	kr��dj|d�}|r~td|j|j
f�q~n�|�djjkr%�dj|d�}|r~td	|j|j
f�q~nY|�djjkr��dj|d
�}|r~�dj|d�}|dkr�td�q�td
|j|jt|�f�q~n�|�djjkr��dj|d�}|r~t�|�q~n�|�djjkr9�dj|d�}|r~t�|�q~nE|�djjkr~�dj|d�}	|	r~t�|	�q~ndS(Nsgot event: %s %st
VBoxEventTypeRbtIMachineStateChangedEvents%machine state event: mach=%s state=%stISnapshotTakenEvents%snapshot taken event: mach=%s snap=%stIGuestPropertyChangedEvents'guest property change: name=%s value=%stIMousePointerShapeChangedEventtshapes!pointer shape event - empty shapes+pointer shape event: w=%d h=%d shape len=%dtIGuestMouseEventtIGuestKeyboardEventtIGuestMultiTouchEvent(ttypeReR
R�R�t#VBoxEventType_OnMachineStateChangedtqueryInterfacet	machineIdRtVBoxEventType_OnSnapshotTakent
snapshotIdt$VBoxEventType_OnGuestPropertyChangedR<tvaluet(VBoxEventType_OnMousePointerShapeChangedR�RtwidththeightR4tVBoxEventType_OnGuestMouseR�tVBoxEventType_OnGuestKeyboardR�tVBoxEventType_OnGuestMultiTouchR�(
teventtevtypetscevtstevtgpcevtpsevR�R�R�R�(R(s /usr/lib/virtualbox/vboxshell.pythandleEventImpl`sB	&   
)t
EventListenercs#eZd�Z��fd�ZRS(cSsdS(N((Rtarg((s /usr/lib/virtualbox/vboxshell.pyR�scs6y��dj|d��Wntj�nXdS(NRbtIEvent(R�RARB(RR�(RR�(s /usr/lib/virtualbox/vboxshell.pythandleEvent�s
(RKRLRR�((RR�(s /usr/lib/virtualbox/vboxshell.pyR��s	Rbi����i��i�(tobjecttcreateListenerRtregisterListenerR�tVBoxEventType_AnyR(ttimeRktgetEventteventProcessedRARBtunregisterListener(	RteventSourcetactivetdurR�tlistenert
registeredRaR�((RR�s /usr/lib/virtualbox/vboxshell.pyt
monitorSource_s0$	 

ics�t|d��d|jjd}�j|�tj�ad�����fd�}|jj�}t}|jj	|j
j|jjg�}t|d��d|jjd}�j|�|dkr�d}nyx|j|�dj
jgt�t}tj�|}	x;tj�|	krN|j|d	�}
|
r||
�qqWWntj�nX�j�|r�|r�|j|�ndS(
NR�sVM=s
cSs*tj�}t|td�}|a|S(Ni�(R�Rltg_tsLast(ttsCurt
timePassed((s /usr/lib/virtualbox/vboxshell.pytstamp�scs�|j}|�djjkr��dj|d�}|r�d��|j|j|j|j|j|j	f}�j
|�q�nn|�djjkr��dj|d�}|r�d��t�dj
|d��f}�j
|�q�ndS(NRbR�s%d: m %d %d %d %d %d %d
R�s	%d: k %s
R�(R�R�R�R�R�R�R�R�R�R�twriteR�R
R�(R�R�R�tlineR�(RtdemoR(s /usr/lib/virtualbox/vboxshell.pyR��s	4)i����i��Rbi�(topenR�R<RR�RRR�RtcreateAggregatortkeyboardtmouseR�R�R�R(R�RARBtcloseR(RR�tfilenameRtheaderR�RRtaggRaR�((RRRs /usr/lib/virtualbox/vboxshell.pyt
recordDemo�s8
	$
	 

c	Csbt|d�}|dkr$d}n|j�}td|�tjd�}tjd�}tjd�}|j}	|j}
y�tj�|}x�|D]�}tj�|kr�Pn|j|�}
|
dkr�q�n|
j
�}|d}|d	}|d
}tjt|�d�|dkr?|j
|�}|	j|�q�|d
kr�|j|�}|dk	r!|j
�}|ddkr�|
jt|d�t|d�t|d�t|d�t|d��q|
jt|d�t|d�t|d�t|d�t|d��q!q�q�WWn+tk
rCt|d<ntj�nX|j�dS(Ntri����i��s	Header iss!(?P<s>\d+): (?P<t>[km]) (?P<p>.*)sK(?P<a>\d+) (?P<x>-*\d+) (?P<y>-*\d+) (?P<z>-*\d+) (?P<w>-*\d+) (?P<b>-*\d+)s\d+R_tptti�tktmtat1R�R�R�R�tbRc(RR&ReR:tcompileRRR�tsearchRt	groupdicttsleeptfloattfindalltputScancodestputMouseEventAbsoluteRlt
putMouseEventRoR(RARBR(RR�RRRRtbaseretmretkretkbdRRaR
tmatchtrdictRtparamstrtypetcodestmmtmdict((s /usr/lib/virtualbox/vboxshell.pytplaybackDemo�sN	
		



NY


cCsfddlm}|j}t|�dkr8|d}nd}t|�dkrct|d�}nd}|j|�\}}}	}
}}t|�dkr�t|d�}
n|}
t|�dkr�t|d�}n|}td|
|||f�|j||
|td	j	�}|
|f}d
}|j
||t|�d|dd�}|j|d�dS(
Ni����(tImageis/tmp/screenshot.pngiiis.Saving screenshot (%d x %d) screen %d in %s...tconsttRGBAtrawtPNG(
tPILR5tdisplayR4RltgetScreenResolutionRettakeScreenShotToArrayRtBitmapFormat_RGBAt
frombufferR
tsave(RxR�targsR5R;tftscreentfbwtfbht_fbbpptfbxtfbyt_R�thtdatatsizeR�tim((s /usr/lib/virtualbox/vboxshell.pyttakeScreenshotOld s*	
!'cCs3|j}t|�dkr(|d}nd}t|�dkrSt|d�}nd}|j|�\}}}}	}
}t|�dkr�t|d�}n|}t|�dkr�t|d�}
n|}
td||
||f�|j|||
tdj�}t|d�}|j	|�|j
�dS(	Nis/tmp/screenshot.pngiiis.Saving screenshot (%d x %d) screen %d in %s...R6twb(R;R4RlR<ReR=RtBitmapFormat_PNGRRR(RxR�RAR;RBRCRDRERFRGRHRIR�RJRKtpngfile((s /usr/lib/virtualbox/vboxshell.pyttakeScreenshot<s&	
!
c	Cs
|djd�dkr'td�dS|djd�\}}t|�dkr_|d}nd}t|�dkr�t|d�}nd}t|�}td	||f�|j||||�}t||d
�r�t|j�dkr�td�n
t||�dS(Nit:i����s(Use host:port format for teleport targetiRii�sTeleporting to %s:%d...idsSuccess!(	R%ReR3R4RltteleportRtRmRn(	Rt_sessionR�RAthosttporttpasswdtmaxDowntimeRr((s /usr/lib/virtualbox/vboxshell.pyRTVs 

'
c	Cs�|j}t|�dkr(|d}nd}|j|krn||_ytjt|�d�WqnqnXn|djd�}d}xRt|j��D]>}y.|j	|||�}t
d||f�Wq�q�Xq�WdS(Niig�������?R6tGuestStatisticTypes%s: %d(R�R4tstatisticsUpdateIntervalR�R#R$t
all_valuesROtkeystgetStatisticRe(	RR�RAR�tupdatet	all_statstcpuR_tval((s /usr/lib/virtualbox/vboxshell.pyt
guestStatsns$	
	cCs/t|d�}td|�|j|�dS(NisAdding CPU %d...(RlRet
hotPlugCPU(RxR�RURARa((s /usr/lib/virtualbox/vboxshell.pytplugCpu�scCs/t|d�}td|�|j|�dS(NisRemoving CPU %d...(RlRethotUnplugCPU(RxR�RURARa((s /usr/lib/virtualbox/vboxshell.pyt	unplugCpu�scCs;|j|d|d|d|d|d�|j�dS(Niiiii(tmountMediumR�(RxR�RURA((s /usr/lib/virtualbox/vboxshell.pytmountIso�s-cCs|r
|S|SdS(N((RFtv1tv2((s /usr/lib/virtualbox/vboxshell.pytcond�scCsKtd|jt|jd�|j|j|jt|d|j�f�dS(Ns0  %s: %s (vendorId=%d productId=%d serial=%s) %sRtUSBDeviceState(	ReR=RtproducttvendorIdt	productIdtserialNumberR�R(Rtud((s /usr/lib/virtualbox/vboxshell.pytprintHostUsbDev�scCs9td|jt|jd�|j|j|jf�dS(Ns-  %s: %s (vendorId=%d productId=%d serial=%s)R(ReR=RRnRoRpRq(RxRr((s /usr/lib/virtualbox/vboxshell.pytprintUsbDev�sc	CsKtd|jt||j�t|jdd�t|jdd�f�dS(Ns    name=%s host=%s %s %sR�snot accessibletwritables	read-only(ReR<R�thostPathRlR�Ru(Rtsf((s /usr/lib/virtualbox/vboxshell.pytprintSf�sc	Csc|j}|j|djkr�td|j�tdt|||dj��tdt|||dj��td|j�td|j	�n
td�|dj
|d	�}td
�x|D]}t||�q�W|dj
|d�}td�x|D]}t||�qWtd
�|dj
|d�}}x|D]}t
||�qHWdS(NR6sAdditions active, version %ssSupport seamless: %ssSupport graphics: %ssBalloon size: %dsStatistic update interval: %dsNo additionsRbt
USBDevicess
Attached USB:tremoteUSBDevicessRemote USB:sTransient shared folders:t
sharedFolders(R�tadditionsRunLeveltAdditionsRunLevelType_NoneRetadditionsVersionR�tAdditionsFacilityType_SeamlesstAdditionsFacilityType_GraphicstmemoryBalloonSizeR[R�RtRsRx(	RR�t_argsR�tusbsRrtrusbstsfsRw((s /usr/lib/virtualbox/vboxshell.pytginfo�s(	!!






cs�d�y'�d}�dj�dt��WnGtk
rv}t�d�jt|�f�trrtj	�ndSX�j
�djkr�td�j�j
f��j
�dS�dr�|dkr�td	��j
�dS�j�i�fd
�d6�fd�d
6�fd�d6�fd�d6��fd�d6����fd�d6���fd�d6����fd�d6��fd�d6���fd�d6����fd�d6���fd �d!6���fd"�d#6���fd$�d%6���fd&�d'6}y||�WnMtk
rSt�d(<n3tk
r�}t�|�tr�tj	�q�nX�j
�dS()NR�RbtfPermitSharingsSession to '%s' not open: %sR6s"Session to '%s' in wrong state: %stremotetsome_local_only_commands/Trying to use local only functionality, ignoredcs
�j�S(N(tpause((R�(s /usr/lib/virtualbox/vboxshell.pyt<lambda>�sR�cs
�j�S(N(tresume((R�(s /usr/lib/virtualbox/vboxshell.pyR��sR�cs
�j�S(N(t	powerDown((R�(s /usr/lib/virtualbox/vboxshell.pyR��st	powerdowncs
�j�S(N(tpowerButton((R�(s /usr/lib/virtualbox/vboxshell.pyR��stpowerbuttoncs
t���S(N(R�((RRH(s /usr/lib/virtualbox/vboxshell.pyR��ststatscst�����S(N(R�((RAR�RRH(s /usr/lib/virtualbox/vboxshell.pyR��sR�cst����S(N(R�((RAR�R(s /usr/lib/virtualbox/vboxshell.pyR��sR�cs�d����d�S(Nii(((RAR�RRH(s /usr/lib/virtualbox/vboxshell.pyR��stguestlambdacst��jj��S(N(RtR�t	saveState((RR�(s /usr/lib/virtualbox/vboxshell.pyR��sR@cst����S(N(RR((RAR�R(s /usr/lib/virtualbox/vboxshell.pyR��st
screenshotcst�����S(N(RT((RAR�RR�(s /usr/lib/virtualbox/vboxshell.pyR��sRTcst����S(N(Rc((RAR�R(s /usr/lib/virtualbox/vboxshell.pyR��st
gueststatscst��j���S(N(ReR�((RARR�(s /usr/lib/virtualbox/vboxshell.pyR��stplugcpucst��j���S(N(RgR�((RARR�(s /usr/lib/virtualbox/vboxshell.pyR��st	unplugcpucst��j���S(N(RiR�((RARR�(s /usr/lib/virtualbox/vboxshell.pyR��stmountisoRc(RtopenMachineSessionR(R>R?R<R
R@RARBRtSessionState_LockedReR�R�Ro(RRHtcmdRAR�RItops((RAR�RRHR�s /usr/lib/virtualbox/vboxshell.pyt
cmdExistingVm�sT
 



	


cCs�|dj|dt�}|j}y||||�Wn9tk
rq}t}t||�trrtj�qrnX|r�y|j	�Wq�tk
r�}t||�tr�tj�q�q�Xn|dj
|�dS(NRbR�(R�R(R�R>RR?R@RARBR�tcloseMachineSession(RRHR�RAR@R�RI((s /usr/lib/virtualbox/vboxshell.pyR��s"	

cCs�|dj|dt�}|j}y||||j|�Wn9tk
rw}t}t||�trxtj	�qxnX|r�|j
�n|dj|�dS(NRbR�(R�R(R�R�R>RR?R@RARBR�R�(RRHR�RAR@R�RI((s /usr/lib/virtualbox/vboxshell.pytcmdAnyVm�s	

cCs|dj|�}|S(NR�(tfindMachine(RR�RH((s /usr/lib/virtualbox/vboxshell.pytmachById
st	XPathNodecBs>eZd�Zd�Zd�Zd�Zd�Zd�ZRS(cCs||_||_||_dS(N(tparenttobjtntype(RR�R�R�((s /usr/lib/virtualbox/vboxshell.pyRs		cCsF|j�}g}x-|D]%}|j|�r|j|�qqW|S(N(tenumRCR6(RtsubpathtchildrenRCRI((s /usr/lib/virtualbox/vboxshell.pytlookups
cCsgS(N((R((s /usr/lib/virtualbox/vboxshell.pyR�scCs�||jkrtS|j|j�s)tStjd|�}t}yQ|dk	r�|j�}|d}|d}tt	|j
|��|k}nWnnX|S(Ns@(?P<a>\w+)=(?P<v>[^\'\[\]]+)Rtv(R�R(RRR:R!RR"R
tgetattrR�(RtsubexpR-RCtxdicttattrRb((s /usr/lib/virtualbox/vboxshell.pyRCs

%cBs3|i|jd6|d6|j�d6ifdUdS(NR�tnodeR(R�tgetCtx(RR�((s /usr/lib/virtualbox/vboxshell.pytapply/scCs#t|d�r|jS|jj�S(NR(thasattrRR�R�(R((s /usr/lib/virtualbox/vboxshell.pyR�1s(RKRLRR�R�RCR�R�(((s /usr/lib/virtualbox/vboxshell.pyR�s					tXPathNodeHoldercBs#eZd�Zd�Zd�ZRS(cCs9tj|||d|�||_||_||_dS(Nshld (R�RR�t	heldClasst	xpathname(RR�R�R�R�R�((s /usr/lib/virtualbox/vboxshell.pyR7s		cCsVg}xI|j�dj|j|j�D]%}|j||�}|j|�q)W|S(NRb(R�R�R�R�R�R6(RR�R�tnodexml((s /usr/lib/virtualbox/vboxshell.pyR�<s
)cCs
||jkS(N(R�(RR�((s /usr/lib/virtualbox/vboxshell.pyRCBs(RKRLRR�RC(((s /usr/lib/virtualbox/vboxshell.pyR�6s		tXPathNodeValuecBseZd�Zd�ZRS(cCs'tj|||d|�||_dS(Nsval (R�RR�(RR�R�R�((s /usr/lib/virtualbox/vboxshell.pyRFscCs
||jkS(N(R�(RR�((s /usr/lib/virtualbox/vboxshell.pyRCIs(RKRLRRC(((s /usr/lib/virtualbox/vboxshell.pyR�Es	tXPathNodeHolderVMcBseZd�ZRS(cCs tj|||dtd�dS(NR�tvms(R�RtXPathNodeVM(RR�R�((s /usr/lib/virtualbox/vboxshell.pyRMs(RKRLR(((s /usr/lib/virtualbox/vboxshell.pyR�LsR�cBseZd�Zd�ZRS(cCstj|||d�dS(Ntvm(R�R(RR�R�((s /usr/lib/virtualbox/vboxshell.pyRQscCs(t||j�t||jjd�gS(Ntbios(tXPathNodeHolderNICR�R�tBIOSSettings(R((s /usr/lib/virtualbox/vboxshell.pyR�Us(RKRLRR�(((s /usr/lib/virtualbox/vboxshell.pyR�Ps	R�cBseZd�Zd�ZRS(cCsEtj|||dtd�|j�djj|jj�|_dS(NtnicsR�(	R�RR�R�tsystemPropertiestgetMaxNetworkAdaptersR�tchipsetTypetmaxNic(RR�RH((s /usr/lib/virtualbox/vboxshell.pyRZscCsOg}xBtd|j�D].}t||jj|��}|j|�qW|S(Ni(R�R�tXPathNodeNICR�tgetNetworkAdapterR6(RR�R�R�((s /usr/lib/virtualbox/vboxshell.pyR�]s
(RKRLRR�(((s /usr/lib/virtualbox/vboxshell.pyR�Ys	R�cBseZd�Zd�ZRS(cCstj|||d�dS(Ntnic(R�R(RR�R�((s /usr/lib/virtualbox/vboxshell.pyRescCs
|dkS(NR�((RR�((s /usr/lib/virtualbox/vboxshell.pyRCgs(RKRLRRC(((s /usr/lib/virtualbox/vboxshell.pyR�ds	t
XPathNodeRootcBs#eZd�Zd�Zd�ZRS(cCs#tj|ddd�||_dS(Ntroot(R�RRR(RR((s /usr/lib/virtualbox/vboxshell.pyRkscCst||jd�gS(NR�(R�R(R((s /usr/lib/virtualbox/vboxshell.pyR�nscCstS(N(R((RR�((s /usr/lib/virtualbox/vboxshell.pyRCps(RKRLRR�RC(((s /usr/lib/virtualbox/vboxshell.pyR�js		c
Cs�|jd�d}t|�g}x�|D]�}g}x/t|�dkrf|j�}|j|�q8Wx;|D]3}|j|�}x|D]}	|j|	�q�WqnWt|�dkr)Pq)q)W|S(NRii(R3R�R4tpopR6R�(
Rtscopet	pathnamestnodesR2tseenR�R_RCR-((s /usr/lib/virtualbox/vboxshell.pyt
eval_xpathss


cCsbt|�dkr(td|d�dS|d}t||�}|dkr^td|�n|S(Nisusage: %s [vmname|uuid]iisDMachine '%s' is unknown, use list command to find available machines(R4ReRR�(RRAR�RH((s /usr/lib/virtualbox/vboxshell.pyt
argsToMach�s
cCsG|dkrd|d}nd}tdt|d�||f�dS(Nis [ext from t]Rs    %s: %s%sR(ReR(R�RJtsptspec((s /usr/lib/virtualbox/vboxshell.pyt
helpSingleCmd�scCs�t|�dkrltd�ttj��}|j�x|D]&}t|t|dt|d�q?WnN|d}tj|�}|dkr�td|�nt||d|d�dS(Nis
Help page:iisCommand '%s' not known(	R4ReROtcommandsR]tsortR�RR(RxRAtnamesR�R�RF((s /usr/lib/virtualbox/vboxshell.pythelpCmd�s


'
cCsf|dj|�}xCt|j��D]/}t|�t||�kr&t|d�Sq&Wtdd�S(NR6Rs	<unknown>(R\ROR]R
R(RR�R�tenumValsRI((s /usr/lib/virtualbox/vboxshell.pyR��s
cCs#|dj|�}|j|d�S(NR6(R\RR(RR�RR�((s /usr/lib/virtualbox/vboxshell.pytenumFromString�scCs�x�t|t�D]�}yf|jr+d}nPd}td|t||j�|jt|d|j�t|d|j	�f�Wqt
k
r�}t||�tr�t
j�q�qXqWdS(Ns[T] s    s5%sMachine '%s' [%s], machineState=%s, sessionState=%stMachineStatetSessionStatei(R9R(tteleporterEnabledReRR<R=R�RtsessionStateR>R?R@RARB(RR�RHtteleRI((s /usr/lib/virtualbox/vboxshell.pytlistCmd�s		N
c
Cs�t|�dkr td�dSt||�}|dkr?dSy|dj|j�}Wn
d}nXtd�tdt||j��td|j�td|j	�td	|dk	r�|jn|j�td
t
|d|j�|jf�t�td|j�td
|j
�td|j�td|j�tdt
|d|j�|jf�t�tdt
|d|j�|jf�tdt
|d|j�|jf�t�|jr�td|j|jf�t�n|j}tdt|j��tdt|j��|j|djj�}tdt|��|j|dj�}tdt|��|j|dj�}tdt|��tdt|j��tdt|j ��td t|j!��td!t|j"��|j#j$rNtd"t
|d#|j#j%�t
|d$|j#j&�f�ntd%t|j'��td&t
|d'|j(�|j(f�td(t
|d)|j)�|j)f�td*t*j+t*j,t-|j.�d+���ytd,t|j/j$��WnnXt�tt0|d-��xJ|dj1|d.�D]2}td/|jt
|d0|j2�|j3f�q7Wt�tt0|d1��td2t|j4��td3|j5�|dj1|d4�}	|	r�t�tt0|d5��nxF|	D]>}
td6|
jt
|d7|
j6�t
|d8|
j7�f�q�W|dj1|d9�}|rjt�tt0|d:��nx|D]}td;|j8|j9|j:t
|d<|j2�|j2f�|j;}
|j2|djj<kr+td=�td>|
j	�td?t=||
j>��td@|
j�tdA|
j?�n|j2|djj@kr�tdB�|
r�td>|
j	�td@|
j�|
jAr�tdCt=||
j>��|jBr�tdD�q�q�tdEt=||
j>��tdF|
jC�q�n|j2|djjDkrqtdG�|
r�td>|
j	�td@|
j�|
jArTtdHt=||
j>��q�tdEt=||
j>��tdF|
jC�q�qqqqWt�tt0|dI��x+|dj1|dJ�D]}tE||�q�WdS(KNisusage: info [vmname|uuid]iR�sN One can use setvar <mach> <var> <value> to change variable, using name in [].s  Name [name]: %ss  Description [description]: %ss  ID [n/a]: %ss  OS Type [via OSTypeId]: %ss"  Firmware [firmwareType]: %s (%s)tFirmwareTypes  CPUs [CPUCount]: %ds  RAM [memorySize]: %dMs  VRAM [VRAMSize]: %dMs  Monitors [monitorCount]: %ds   Chipset [chipsetType]: %s (%s)tChipsetTypes)  Clipboard mode [clipboardMode]: %s (%s)t
ClipboardModes  Machine status [n/a]: %s (%s)R�s!  Teleport target on port %d (%s)s%  ACPI [BIOSSettings.ACPIEnabled]: %ss'  APIC [BIOSSettings.IOAPICEnabled]: %sRbsw  Hardware virtualization [guest win machine.setHWVirtExProperty(ctx[\'const\'].HWVirtExPropertyType_Enabled, value)]: R6si  VPID support [guest win machine.setHWVirtExProperty(ctx[\'const\'].HWVirtExPropertyType_VPID, value)]: sr  Nested paging [guest win machine.setHWVirtExProperty(ctx[\'const\'].HWVirtExPropertyType_NestedPaging, value)]: s2  Hardware 3d acceleration [accelerate3DEnabled]: s=  Hardware 2d video acceleration [accelerate2DVideoEnabled]: s$  Use universal time [RTCUseUTC]: %ss  HPET [HPETEnabled]: %ss3  Audio [via audioAdapter]: chip %s; host driver %stAudioControllerTypetAudioDriverTypes)  CPU hotplugging [CPUHotPlugEnabled]: %ss%  Keyboard [keyboardHIDType]: %s (%s)tKeyboardHIDTypes,  Pointing device [pointingHIDType]: %s (%s)tPointingHIDTypes  Last changed [n/a]: i�s&  VRDE server [VRDEServer.enabled]: %ss  USB Controllers:tUSBControllerss     '%s': type %s  standard: %#xtUSBControllerTypes  I/O subsystem info:s%   Cache enabled [IOCacheEnabled]: %ss    Cache size [IOCacheSize]: %dMtstorageControllerss  Storage Controllers:s    '%s': bus %s type %st
StorageBustStorageControllerTypetmediumAttachmentss  Media:s5   Controller: '%s' port/device: %d:%d type: %s (%s):t
DeviceTypes   HDD:s
    Id: %ss    Location: %ss    Name: %ss    Format: %ss   DVD:s    Host DVD %ss    [passthrough mode]s    Virtual image at %ss    Size: %ss
   Floppy:s    Host floppy %ss  Shared folders:R{(FR4ReR�RtgetGuestOSTypetOSTypeIdRR<tdescriptionR=R�tfirmwareTypetCPUCountt
memorySizetVRAMSizetmonitorCountR�t
clipboardModeR�R�tteleporterPorttteleporterPasswordR�R�tACPIEnabledt
IOAPICEnabledtgetHWVirtExPropertyR�tHWVirtExPropertyType_EnabledtHWVirtExPropertyType_VPIDt!HWVirtExPropertyType_NestedPagingtaccelerate3DEnabledtaccelerate2DVideoEnabledt	RTCUseUTCtHPETEnabledtaudioAdaptertenabledtaudioControllertaudioDrivertCPUHotPlugEnabledtkeyboardHIDTypetpointingHIDTypeR�tasctimet	localtimeRltlastStateChanget
VRDEServerR}R�R�tUSBStandardtIOCacheEnabledtIOCacheSizetbustcontrollerTypet
controllerRWtdevicetmediumtDeviceType_HardDiskR�tlocationtformattDeviceType_DVDt	hostDrivetpassthroughRLtDeviceType_FloppyRx(RRARHtvmosR�t
hwVirtEnabledt
hwVirtVPIDthwVirtNestedPagingtoUsbCtrltcontrollersRtattachesRRRw((s /usr/lib/virtualbox/vboxshell.pytinfoCmd�s�


&&&&&	
	;&&-*
<
8	

		
	cCsxt|�dkr td�dSt||�}|dkr?dSt|�dkr^|d}nd}t|||�dS(Nisusage: start name <frontend>itgui(R4ReR�RR�(RRARHR�((s /usr/lib/virtualbox/vboxshell.pytstartCmd6s

cCst|�dkr td�dS|d}|d}y|dj|�Wntk
rjtd|�dSXt|||�dS(Nisusage: createvm name ostypeiiiR�sUnknown OS type:(R4ReR�R>R�(RRAR<toskind((s /usr/lib/virtualbox/vboxshell.pytcreateVmCmdDs




cCsVt|�dkr td�dSt||�}|dkr?dSt||dd�dS(Nisusage: ginfo [vmname|uuid]iR�R(R4ReR�RR�(RRARH((s /usr/lib/virtualbox/vboxshell.pytginfoCmdRs
c	Cs�t|�dkr td�dS|j}	|	j||dd�}
|}td|d||f�d}|dk	r}d}nt|d�|
j|d||g|�}
td|
j�tdkr�y�x�trL|dk	rv||�}|dk	rOt|�}d}xg|dkrK|	j	tdd||�}||}||}qWqvy|	j	tddd
�WqvqvXn|	j
tddd�}|r�t|�dkr�tjj
|�q�ntjd
�|djd�|	j
tddd�}|r<t|�dkr<|dk	r&|||�q�tjj
|�q�ntjr�Pq�q�WWn;tk
r�td�t|d<tjr�tj�q�nX|	jt�\}}}td|�dSt|t�dS(Nis)exec in guest needs at least program nameRsvboxshell guest execsexecuting %s with args %s as %sisexecuted with pid %di
i�R#i'iidRbsInterrupted.Rcs
Exit code: %di'i'(R4ReR�t
createSessionRt
processCreatetPIDtpidR(tsetProcessInputtgetProcessOutputRgRhRRrRjRkRdRoRpRqtgetProcessStatusRn(RR�RAtenvtuserRXttmot	inputPipet
outputPipeR�tguestSessiontgargstflagstprocesstindataRR�R�RKt_reasontcodet_flags((s /usr/lib/virtualbox/vboxshell.pytexecInGuest\sh
			

	


	c	Cs]|d}|d}d}td||f�|jj|||||�}t||�dS(NiisCopying host %s to guest %s(ReR�tcopyToGuestRt(	RR�RAR2RXtsrctdstR8Rr((s /usr/lib/virtualbox/vboxshell.pyR?�s

RcCsjtj}t|�}|r+|j|�ntjj�}|sIt�n|ddkrf|d }n|S(Ni����s
(RgRhR
RtstdinR&tEOFError(tprompttstreamR
((s /usr/lib/virtualbox/vboxshell.pytnh_raw_input�s		
cCsYddl}|j�}td|�}t|�dkrC|}n|j�}||fS(Ni����sUser (%s): i(tgetpasstgetuserRFR4(RxRGR2tuser_inpRX((s /usr/lib/virtualbox/vboxshell.pytgetCred�s	cs�t|�dkr td�dSt||�}|dkr?dS|d}g�t|�\��|jd���fd��t||d|�dS(Nis'usage: gexec [vmname|uuid] command argsicst|||���d�S(Ni'(R>(RRHR�RA(R1RXR2(s /usr/lib/virtualbox/vboxshell.pyR��sR�(R4ReR�RRJtinsertR�(RRARHR7((R1RXR2s /usr/lib/virtualbox/vboxshell.pytgexecCmd�s

cs�t|�dkr td�dSt||�}|dkr?dS|d}t|�\��|jd��fd��t||d|�dS(Nis/usage: gcopy [vmname|uuid] host_path guest_pathicst|||���S(N(R?(RRHR�RA(RXR2(s /usr/lib/virtualbox/vboxshell.pyR��sR�(R4ReR�RRJRKR�(RRARHR7((RXR2s /usr/lib/virtualbox/vboxshell.pytgcopyCmd�s

cCs%y|dj�dSWndSXdS(NR9i(tcommunicateR(Rt_hcmd((s /usr/lib/virtualbox/vboxshell.pytreadCmdPipe�scst|�dkr td�dSt||�}|dkr?dS|d�|d}t|�\��ddl}|jt��d|j�|d<t|�}g�|j	d����fd	��t
||d
|�y|dj�WnnXd|d<dS(Nis�usage: gpipe [vmname|uuid] hostProgram guestProgram, such as gpipe linux  '/bin/uname -a' '/bin/sh -c "/usr/bin/tee; /bin/uname -a"'iiii����RhR9c
s(t|||���d�fd��S(Ni'cs
t|��S(N(RP(R(thcmd(s /usr/lib/virtualbox/vboxshell.pyR��s(R>(RRHR�RA(R1RQRXR2(s /usr/lib/virtualbox/vboxshell.pyR��sR�(R4ReR�RRJt
subprocesstPopenR`tPIPERKR�t	terminate(RRARHtgcmdRRR7((R1RQRXR2s /usr/lib/virtualbox/vboxshell.pytgpipeCmd�s*


""
cCs0t||�}|dkrdSt||�dS(Ni(R�RR�(RRARH((s /usr/lib/virtualbox/vboxshell.pytremoveVmCmd�s

cCs6t||�}|dkrdSt||dd�dS(NiR�R(R�RR�(RRARH((s /usr/lib/virtualbox/vboxshell.pytpauseCmd�s
cCs6t||�}|dkrdSt||dd�dS(NiR�R(R�RR�(RRARH((s /usr/lib/virtualbox/vboxshell.pytpowerdownCmd�s
cCs6t||�}|dkrdSt||dd�dS(NiR�R(R�RR�(RRARH((s /usr/lib/virtualbox/vboxshell.pytpowerbuttonCmds
cCs6t||�}|dkrdSt||dd�dS(NiR�R(R�RR�(RRARH((s /usr/lib/virtualbox/vboxshell.pyt	resumeCmds
cCs6t||�}|dkrdSt||dd�dS(NiR@R(R�RR�(RRARH((s /usr/lib/virtualbox/vboxshell.pytsaveCmds
cCs6t||�}|dkrdSt||dd�dS(NiR�R(R�RR�(RRARH((s /usr/lib/virtualbox/vboxshell.pytstatsCmds
cs�t��dkr td�dSt|��}|dkr?dS|j|djkrqt||�fd��n t||ddj�d��dS(	Nisusage: guest name commandsiR6cs t||ddj�d��S(NR#i(R�RR7(RRHR(RA(s /usr/lib/virtualbox/vboxshell.pyR�)sR�R#i(	R4ReR�RRtMachineState_RunningR�R�R7(RRARH((RAs /usr/lib/virtualbox/vboxshell.pytguestCmd!s
 cCsZt|�dkr td�dSt||�}|dkr?dSt||d|d�dS(Nis6usage: screenshot vm <file> <width> <height> <monitor>iR�(R4ReR�RR�(RRARH((s /usr/lib/virtualbox/vboxshell.pyt
screenshotCmd.s
cCsZt|�dkr td�dSt||�}|dkr?dSt||d|d�dS(Nis)usage: teleport name host:port <password>iRTi(R4ReR�RR�(RRARH((s /usr/lib/virtualbox/vboxshell.pytteleportCmd8s
cCsF|d}||_|rB|d}|d}||_||_ndS(Niii(R�R�R�(RxRHRARRWRX((s /usr/lib/virtualbox/vboxshell.pytportalsettingsBs
	

	c	Cs�t|�dkr td�dSt||�}|dkr?dSt|d�}t|�dkrn|d}nd}|js�|j|ks�|r�t||tt	||g�nt
||d�dS(Nis&usage: openportal name port <password>iiRR%(R4ReR�RRlR�R�R�RcR(R�(RRARHRWRX((s /usr/lib/virtualbox/vboxshell.pyt
openportalCmdKs

cCset|�dkr td�dSt||�}|dkr?dS|jrat||ttg�ndS(Nisusage: closeportal namei(R4ReR�RR�R�RcR(RRARH((s /usr/lib/virtualbox/vboxshell.pytcloseportalCmd\s
	cCsZt|�dkr td�dSt||�}|dkr?dSt||d|d�dS(Nis'usage: gueststats name <check interval>iR�(R4ReR�RR�(RRARH((s /usr/lib/virtualbox/vboxshell.pyt
gueststatsCmdgs
cCsW|d}|d}|r8td|�|j|�ntd|�|j|�dS(NiisAdding CPU %d...sRemoving CPU %d...(ReRdRf(RxRHRAtplugRa((s /usr/lib/virtualbox/vboxshell.pyR�qs

cCs�t|�dkr td�dSt||�}|dkr?dSt|j�t|dj�kr�|jr�t||t	t
t|d�g�q�nt||d|d�dS(Nisusage: plugcpu name cpuidiR6R�(
R4ReR�RR
R�R�RR�R�R(RlR�(RRARH((s /usr/lib/virtualbox/vboxshell.pyt
plugcpuCmd{s
"	)cCs�t|�dkr td�dSt||�}|dkr?dSt|j�t|dj�kr�|jr�t||t	t
t|d�g�q�nt||d|d�dS(Nisusage: unplugcpu name cpuidiR6R�(
R4ReR�RR
R�R�RR�R�RRlR�(RRARH((s /usr/lib/virtualbox/vboxshell.pytunplugcpuCmd�s
"	)cBs3d|dd|d}ed|�|dUdS(Nsmach.is = it	Executing(Re(Rxt_machRAtexpr((s /usr/lib/virtualbox/vboxshell.pytsetvar�s
cCsZt|�dkr td�dSt||�}|dkr?dSt||t|d�dS(Nis&usage: setvar [vmname|uuid] expr valueii(R4ReR�RR�Rm(RRARH((s /usr/lib/virtualbox/vboxshell.pyt	setvarCmd�s
cCsN|d}|d}td|j||r/|ndf�|j||�dS(Niis%s: setting %s to %s(ReR<RtsetExtraData(RxRHRARYR�((s /usr/lib/virtualbox/vboxshell.pyt
setvmextra�s

&cCs�t|�dkr td�dS|d}t|�dkrI|d}nd}|ddkrw|d	j||�dSt||�}|dkr�dSt||t||g�dS(
Nis0usage: setextra [vmname|uuid|global] key <value>iiiRiRbR�(R4ReRoR�RR�Rp(RRARYR�RH((s /usr/lib/virtualbox/vboxshell.pytsetExtraDataCmd�s


cCstd|||f�dS(Ns%s: '%s' = '%s'(Re(R�RYR�((s /usr/lib/virtualbox/vboxshell.pyt
printExtraKey�scCs�t|�dkr td�dSt|�dkr?|d}nd}|ddkrb|d}nt||�}|dkr�dS|dkr�|j�}n	|g}x+|D]#}t|d||j|��q�WdS(Nis*usage: getextra [vmname|uuid|global] <key>iiiRbR�(R4ReRR�tgetExtraDataKeysRrtgetExtraData(RRARYR�R]R((s /usr/lib/virtualbox/vboxshell.pytgetExtraDataCmd�s"


	
!cCsdS(Ni((RxR�((s /usr/lib/virtualbox/vboxshell.pytquitCmd�scCsct|�dkr(|dt|d<dSx4ttj��D] \}}td||f�q;WdS(Niiiis'%s' is an alias for '%s'(R4taliasesRORPRe(RRARYR�((s /usr/lib/virtualbox/vboxshell.pytaliasCmd�scCs0t|�dkr%|ddkantadS(NiR�i(R4R@(RRA((s /usr/lib/virtualbox/vboxshell.pyt
verboseCmd�scCs0t|�dkr%|ddkantadS(NiR�i(R4R	(RRA((s /usr/lib/virtualbox/vboxshell.pyt	colorsCmd�scCs|d}ytdt|jd��Wn3tk
r]}t||�tr^tj�q^nX|j}tdt	||j
��|j}|j}tt
|d��td||jf�x@td|�D]/}td||j|�|j|�f�q�Wtt
|d	��td
|j|jf�tt
|d��td|j|jf�|jrytt
|d
��ntt
|d��tt
|d��x8|dj|d�D] }td|j|jf�q�Wtt
|d��x8|dj|d�D] }	td|	j|	jf�qWtt
|d��x8|dj|d�D] }	td|	j|	jf�qRWtt
|d��x+|dj|d�D]}
t||
�q�W|drx<|djdg|g�D]}t|d|d�q�WndS(NR�sVirtualBox version %sRsMachines: %ssProcessors:s  available/online: %d/%d is  processor #%d speed: %dMHz %ssRAM:s  %dM (free %dM)sOS:s	  %s (%s)s3D acceleration availables3D acceleration NOT availablesNetwork interfaces:RbtnetworkInterfacessDVD drives:t	DVDDrivess	  %s - %ssFloppy drives:tfloppyDrivessUSB devices:RyR�R�R<R�(ReRtversionR>R?R@RARBR�R�tdefaultMachineFolderRVtprocessorCountR}tprocessorOnlineCountR�tgetProcessorSpeedtgetProcessorDescriptionR�tmemoryAvailabletoperatingSystemt	OSVersiontacceleration3DAvailableR�R<t	IPAddressR�RsR�(RRAR�RItpropsRVtcntR�tnitddRrR�((s /usr/lib/virtualbox/vboxshell.pythostCmd�sL

			-	
#cs�t|�dkr td�dSt||�}|dkr?dSd�t|�dkrjt|d��nt�t||d��fd�g�dS(Nis#usage: monitorGuest name (duration)iiR�cst||j���S(N(RR(RRHR�RA(RR(s /usr/lib/virtualbox/vboxshell.pyR�6s(R4ReR�RR$RR�(RRARH((RRs /usr/lib/virtualbox/vboxshell.pytmonitorGuestCmd+s
"cs�t|�dkr td�dSt||�}|dkr?dSd�t|�dkrjt|d��nt�t||d��fd�g�dS(Nis&usage: monitorGuestKbd name (duration)iiR�cst||jj���S(N(RRR(RRHR�RA(RR(s /usr/lib/virtualbox/vboxshell.pyR�Ds(R4ReR�RR$RR�(RRARH((RRs /usr/lib/virtualbox/vboxshell.pytmonitorGuestKbdCmd9s
"cs�t|�dkr td�dSt||�}|dkr?dSd�t|�dkrjt|d��nt�t||d��fd�g�dS(Nis(usage: monitorGuestMouse name (duration)iiR�cst||jj���S(N(RRR(RRHR�RA(RR(s /usr/lib/virtualbox/vboxshell.pyR�Rs(R4ReR�RR$RR�(RRARH((RRs /usr/lib/virtualbox/vboxshell.pytmonitorGuestMouseCmdGs
"cs�t|�dkr td�dSt||�}|dkr?dSd�t|�dkrjt|d��nt�t||d��fd�g�dS(Nis-usage: monitorGuestMultiTouch name (duration)iiR�cst||jj���S(N(RRR(RRHR�RA(RR(s /usr/lib/virtualbox/vboxshell.pyR�`s(R4ReR�RR$RR�(RRARH((RRs /usr/lib/virtualbox/vboxshell.pytmonitorGuestMultiTouchCmdUs
"cCsut|�dkr td�dSd}t|�dkrKt|d�}n|d}t}t||j||�dS(Nisusage: monitorVBox (duration)iiiR�(R4ReR$RRR(RRARR�R((s /usr/lib/virtualbox/vboxshell.pytmonitorVBoxCmdcs

cCs�||djjks,||djjkr0dS||djjksr||djjksr||djjkrvdS||djjkr�dS||djjkr�dSt	d|��dS(NRbtpcnette1000tvirtiosUnknown adapter type: (
R�tNetworkAdapterType_Am79C970AtNetworkAdapterType_Am79C973tNetworkAdapterType_I82540EMtNetworkAdapterType_I82545EMtNetworkAdapterType_I82543GCtNetworkAdapterType_VirtiotNetworkAdapterType_NullRR>(Rtnatype((s /usr/lib/virtualbox/vboxshell.pytgetAdapterTypeoscCsct|�dkr td�dSt||�}|dkr?dSt|d�}t|d�}t|d�}d}|dj|d	t�}|j}|j|�}t	||j
�}	|d
t|�d
t|�}
d|	d}|t|j�d
|
}|j
|d|�|j
|dt|��|j
|dt|��|j�|j�dS(Nis8usage: portForward <vm> <adapter> <hostPort> <guestPort>iiiitTCPRbR�RIsVBoxInternal/Devices/Rs/LUN#0/Config/s	/Protocols	/HostPorts
/GuestPort(R4ReR�RRlR�R(R�R�R�tadapterTypeR
tslotRoR�R�(RRARHt
adapterNumthostPortt	guestPorttprotoR�tadapterR�tprofile_nametconfig((s /usr/lib/virtualbox/vboxshell.pytportForwardCmds.
	"

cCs�t|�dkr td�dSt||�}|dkr?dSd}t|�dkrd|d}nd}x[tr�|j||d�}t|�dkr�Pntjjt	|��|t|�7}qmWdS(Nisusage: showLog vm <num>ii(
R4ReR�RR(treadLogRgRhRR
(RRARHtlogtuOffsetRK((s /usr/lib/virtualbox/vboxshell.pyt
showLogCmd�s"

	cCsCt|�dkr td�dSt||�}|dkr?dSd}t|�dkrd|d}n|d}d}x�tr>|j||d	�}t|�dkr�Pnt|�jd�}xk|D]c}tj	||�}	t|	�dkr�x)|	D]!}
|j
|
t|
d��}q�Wt|�q�q�W|t|�7}qwWdS(
Nisusage: findLog vm pattern <num>iiiis
Ri(R4ReR�RR(R�R
R3R:R%treplaceR(RRARHR�tpatternR�RKtdR_R-tmt((s /usr/lib/virtualbox/vboxshell.pyt
findLogCmd�s0


	

cCsft|�dkr td�dSt||�}|dkr?dSd}t|�dkrd|d}nd}tjd�}t}d}x�tra|j||d
�}t|�dkr�Pnt	|�j
d�}	x}|	D]u}
|rt|
�|dkrt}q�|d}q�n|j|
�}t|�dkr�t}d	}t|
�q�q�W|t|�7}q�WdS(Nisusage: findAssert vm <num>is(Expression:|\!\!\!\!\!\!)iis
ii2i(R4ReR�RR:R RR(R�R
R3R%(RRARHR�R�tereRtcontextRKR�R_R-((s /usr/lib/virtualbox/vboxshell.pyt
findAssertCmd�s@

	

	
cBsYdj|d�}y|dUWn3ek
rT}e||�erUej�qUnXdS(NR#ii(R7R>R?R@RARB(RRARlRI((s /usr/lib/virtualbox/vboxshell.pytevalCmd�s
cCs't|tt|��tt|�dS(Ni(tcheckUserExtensionsR�t
getHomeFolderR](RRA((s /usr/lib/virtualbox/vboxshell.pytreloadExtCmds
cCs3t|�dkr td�dSyt|dd�}Wn+tk
rd}td|dd|�dSXy�|j�}d|d<t|d	<xc|dt|�kr�||d}|dd|d<t||�}|dks�|d	r�Pq�q�WWn3tk
r$}t||�t	r%t
j�q%nX|j�dS(
Nisusage: runScript <script>iiRscannot open:RSt
scriptLineRc(
R4ReRtIOErrort	readlinesRt
runCommandR>R?R@RARBR(RRAtlfRItlinesR
tdone((s /usr/lib/virtualbox/vboxshell.pytrunScriptCmds0




cCsIt|�dkr td�dSytjt|d��WnnXdS(Nisusage: sleep <secs>ii(R4ReR�R#R$(RRA((s /usr/lib/virtualbox/vboxshell.pytsleepCmd's
cCs\t|�dkr td�dSdj|d�}ytj|�Wntk
rWnXdS(Nisusage: shell <commands>iR#i(R4ReR7R1RVRo(RRAR�((s /usr/lib/virtualbox/vboxshell.pytshellCmd4s

cCsNt|�dkr td�dS|ddk	r>td�dSt|�dkr]|d}nd}t|�dkr�|d}nd}t|�d	kr�|d	}nd}|||g|d
<|djj|||�|d<ytd|dj�Wn3tk
r.}t||�tr/t	j
�q/nX|dj|d�|d
<dS(Nis&usage: connect url <username> <passwd>iR�s&Already connected, disconnect first...iiRitwsinfoRbsRunning VirtualBox version %sR�(R4ReRRUtconnectR~R>R?R@RARBtgetPerfCollector(RRAturlR2RXRI((s /usr/lib/virtualbox/vboxshell.pyt
connectCmdBs2




 
cCsxt|�dkr td�dS|ddkr>td�dSy|djj�Wnd|d<�nXd|d<dS(Nisusage: disconnectiR�sNot connected yet.Rb(R4ReRRUt
disconnect(RRA((s /usr/lib/virtualbox/vboxshell.pyt
disconnectCmdes



cCs�|ddkrtd�dSy|djj�WnnX|d\}}}|djj|||�|d<ytd|dj�Wn3tk
r�}t||�tr�t	j
�q�nX|dj|d�|d<dS(NR�sNever connected...iRbR�sRunning VirtualBox version %sR�(RReRUR�R�R~R>R?R@RARBR�(RRAR�R2RXRI((s /usr/lib/virtualbox/vboxshell.pytreconnectCmdws"
 
c	Cs-t|�dkr td�dSt||�}|dkr?dS|d}t|�dkrh|d}nd}t|�dkr�|d}nd}|dj�}|j|�}|j|d	jj|d
�|j	||�}t
||�rt|j�dkrtd||f�n
t
||�dS(Nis3usage: exportVm <machine> <path> <format> <license>iisovf-1.0itGPLR�RbRsExported to %s in format %s(R4ReR�RtcreateAppliancetexporttaddDescriptionR�t$VirtualSystemDescriptionType_LicenseRRtRlRmRn(	RRARHR2tfmttlictapptdescRr((s /usr/lib/virtualbox/vboxshell.pytexportVMCmd�s*



$
iRi0Ri.RFi R�iRIi!RBi"tgi#RJiR�i$tji%Ri&tli2Ri1tnitoiRitqiRiR_iRitui/R�iR�i-R�iR�i,R�it0iRit2it3it4it5it6it7i	t8i
t9i9R#it-i
t=it[iR�i't;i(s'i3t,i4t.i5Ris	is
i)t`itESCitBKSPtSPACEtTABi:tCAPStENTERi*tLSHIFTi6tRSHIFTi�iRtINSiStDELiOtENDiGtHOMEiItPGUPiQtPGDOWNi[tLGUIi\tRGUIitLCTRtRCTRi8tLALTtRALTi]tAPPSi;tF1i<tF2i=tF3i>tF4i?tF5i@tF6iAtF7iBtF8iCtF9iDtF10iWtF11iXtF12iHtUPiKtLEFTiPtDOWNiMtRIGHTcCs]tj|d�}|dkr%|gStj|g�}t|�dkrYtd|�n|S(Nisbad ext(R�RtextScancodesR4Re(tchR<textCode((s /usr/lib/virtualbox/vboxshell.pytkeyDownscCs@t|�}t|�dkr<|t|�dcd7<n|S(Niii�(RR4(RR1((s /usr/lib/virtualbox/vboxshell.pytkeyUp
s
cCs�g}t}t}d}|j}x^|t|�kr�||}|d}|dkrbt}q$n|dkr�x!|D]}	|jt|	��quWg}t}q$n|dkr�tjd�q$n|dks�|dks�|d	ks�|d
krY|dkrd}n|dkrd}n|d
kr2d
}n|d	krGd}n|st}qn�|dkr�|t|�kr||}|d}|dkr�d}q�qnb|dkrd}
xD|t|�kr�||}|d}|dkr�Pn|
|7}
q�W|
}nt}|jt|��|j	d|�|rq|rqx!|D]}	|jt|	��qEWg}t}ntj|�q$WdS(Niit{t}tWg333333�?t^t|t$RIR�R�R�R�s\R�s
t&RR�(
RR(RR4R&RR�R#RRK(R�RtdelaytpressedtgrouptmodGroupEndR�R,RRFtcombo((s /usr/lib/virtualbox/vboxshell.pyttypeInGuestsn	



0				



	

	cs�t|�dkr td�dSt||�}|dkr?dS|d�t|�dkrnt|d��nd���fd�g}t||d|�dS(Nis-usage: typeGuest <machine> <text> <charDelay>iig�������?cst|���S(N(R#(RRHR�RA(RR(s /usr/lib/virtualbox/vboxshell.pyR�_sR�(R4ReR�RR$R�(RRARHR7((RRs /usr/lib/virtualbox/vboxshell.pyttypeGuestCmdPs

cCs|rd|SdSdS(Ns: R((tverboseR�((s /usr/lib/virtualbox/vboxshell.pytoptIddscCs"|rt|�dSt|�SdS(Nii(Rl(RbtinBytes((s /usr/lib/virtualbox/vboxshell.pytasSizejsc	CsQt|�dkr%t|d�}nt}|dj|dd�}tt|d��x�|D]�}|j|djjkr�|j	�ntdt
||j�|jt
||j�t|t|jt��t|t|jt��f�q_W|dj|dd�}tt|d��x~|D]v}|j|djjkrQ|j	�ntd	t
||j�|jt
||j�t|t|jt��f�q%W|dj|dd
�}tt|d��x~|D]v}|j|djjkr�|j	�ntd	t
||j�|jt
||j�t|t|jt��f�q�WdS(
NiRbR�t	hardDiskssHard disks:s   %s (%s)%s %s [logical %s]t	DVDImagess
CD/DVD disks:s   %s (%s)%s %stfloppyImagess
Floppy disks:i(R4RlRR�ReR}RR�tMediumState_CreatedtrefreshStateR�RRR&R=R�R(RLR(tlogicalSize(	RRAR%thddsthddtdvdstdvdtfloppystfloppy((s /usr/lib/virtualbox/vboxshell.pytlistMediaCmdps,

f

N

NcCs_t|�dkr td�dS|dj}x+|dj|d�D]}t||�qDWdS(Nisusage: listUsbiR�RbRy(R4ReRVR�Rs(RRARVRr((s /usr/lib/virtualbox/vboxshell.pyt
listUsbCmd�s

cCsY|dj|d�}x3|D]+}|j|kr|j|j|jgSqWdddgS(NRbR�i(R�R�RRWRR(RRHtdevtypetattsR((s /usr/lib/virtualbox/vboxshell.pyt
findDevOfType�s

cCst|�dkr td�dSt|d�}|d}t|�dkrY|d}nd}|dj|||djj|djj�}|j||djjf�}t	||�r�|j
r�td	t||j�|j
f�ntd
|�t
||�dSdS(Nis$usage: createHdd sizeM location typeiiitvdiR�Rbscreated HDD at %s as %ss#cannot create disk (file %s exist?)(R4ReRltcreateMediumR�tAccessMode_ReadWriteRtcreateBaseStoragetMediumVariant_StandardRtR=R�RRn(RRARLtlocR�R0Rr((s /usr/lib/virtualbox/vboxshell.pytcreateHddCmd�s 


0&
c	Cs�t|�dkr td�dS|d}|d}t}d}t}d}|j||djj|djjt�}td|j�dS(	Nisusage: registerHdd locationiR�iRRbsregistered HDD as %s(R4ReRt
openMediumR�RR<R=(	RRAR�R?t
setImageIdtimageIdtsetParentIdtparentIdR0((s /usr/lib/virtualbox/vboxshell.pytregisterHddCmd�s


,cCs2|\}}}}}|j|||||�dS(N(tattachDevice(RRHRAtctrRWR�R7R�((s /usr/lib/virtualbox/vboxshell.pyt
controldevice�scst|�dkr td�dSt||�}|dkr?dS|d}|d}y0|j||djj|djjt��Wntd|�dSXt|�dkr�|d�|dj	d	�\��n%t
|||djj�\���t||����fd
��dS(Nis,usage: attachHdd vm hdd controller port:slotiR�iRbsno HDD with path %s registerediRScs&|j���|djj�j�S(NRb(RGR�RR=(RRHRA(RHR0RWR�(s /usr/lib/virtualbox/vboxshell.pyR��s(R4ReR�RRAR�RR<RR3R9R�(RRARHR�R?((RHR0RWR�s /usr/lib/virtualbox/vboxshell.pytattachHddCmd�s&


0
%"cCs~|dj|d�}|d}xW|D]O}|jr'|dksT|jj|krv|j|j|j|j�qvq'q'WdS(NRbR�iR�(R�RR=tdetachDeviceRRWR(RRHRAR8thidR((s /usr/lib/virtualbox/vboxshell.pyR��s

	cCs#t|t||�t|g�dS(N(R�R�R�(RtmidR((s /usr/lib/virtualbox/vboxshell.pytdetachMedium�scCs�t|�dkr td�dSt||�}|dkr?dS|d}|d}y0|j||djj|djjt�}Wntd|�dSXt	||j
|�dS(Nisusage: detachHdd vm hddiR�iRbsno HDD with path %s registered(R4ReR�RRAR�RR<RRNR=(RRARHR�R?R0((s /usr/lib/virtualbox/vboxshell.pytdetachHddCmd�s


0c	Cs2t|�dkr td�dS|d}|d}t|�dkrYt|d�}nd}y0|j||djj|djjt�}Wntd|�dSX|dkr$|dj|d�}y3x,|D]$}td	|�t	|||�q�WWq$t
k
r }td
|�dSXn|j�dS(Nis#usage: unregisterHdd path <vmunreg>iR�iRbsno HDD with path %s registeredt
machineIdssTrying to detach from %ssfailed: (R4ReRlRAR�RR<RR�RNR>R(	RRAR�R?tvmunregR0tmachsRHRI((s /usr/lib/virtualbox/vboxshell.pytunregisterHddCmd�s0


0


cCs�t|�dkr td�dS|d}|d}y0|j||djj|djjt�}Wntd|�dSX|j�}t||�dS(Nisusage: removeHdd pathiR�iRbsno HDD with path %s registered(	R4ReRAR�RR<Rt
deleteStorageRt(RRAR�R?R0Rr((s /usr/lib/virtualbox/vboxshell.pytremoveHddCmd	s


0
cCsut|�dkr td�dS|d}|d}|j||djj|djjt�}td|j�dS(Nisusage: registerIso locationiR�iRbsregistered ISO as %s(R4ReRAR�RtAccessMode_ReadOnlyRR=(RRAR�R?tiso((s /usr/lib/virtualbox/vboxshell.pytregisterIsoCmd-	s


,cCs�t|�dkr td�dS|d}|d}y0|j||djj|djjt�}Wntd|�dSX|j�}tdt||��dS(	Nisusage: unregisterIso pathiR�iRbsno DVD with path %s registeredsUnregistered ISO at %s(	R4ReRAR�RRVRRR�(RRAR�R?R2Rr((s /usr/lib/virtualbox/vboxshell.pytunregisterIsoCmd8	s


0cCs�t|�dkr td�dS|d}|d}y0|j||djj|djjt�}Wntd|�dSX|j�}t||�r�tdt	||j
��n
t||�dS(	Nisusage: removeIso pathiR�iRbsno DVD with path %s registeredsRemoved ISO at %s(R4ReRAR�RRVRRTRtR�RRn(RRAR�R?R2Rr((s /usr/lib/virtualbox/vboxshell.pytremoveIsoCmdJ	s


0
cst|�dkr td�dSt||�}|dkr?dS|d}|d}y0|j||djj|djjt��Wntd|�dSXt|�dkr�|d�|dj	d	�\��n%t
|||djj�\���t||����fd
��dS(Nis,usage: attachIso vm iso controller port:slotiR�iRbsno DVD with path %s registerediRScs#|j���|djj��S(NRb(RGR�R(RRHRA(RHR2RWR�(s /usr/lib/virtualbox/vboxshell.pyR�r	s(R4ReR�RRAR�RRVRR3R9R�(RRARHR�R?((RHR2RWR�s /usr/lib/virtualbox/vboxshell.pytattachIsoCmd^	s&


0
%"cCs�t|�dkr td�dSt||�}|dkr?dS|d}|d}y0|j||djj|djjt�}Wntd|�dSXt	||j
|�dS(Nisusage: detachIso vm isoiR�iRbsno DVD with path %s registered(R4ReR�RRAR�RRVRRNR=(RRARHR�R?R2((s /usr/lib/virtualbox/vboxshell.pytdetachIsoCmdu	s


0c		Cst|�dkr td�dSt||�}|dkr?dS|d}|d}y0|j||djj|djjt�}Wntd|�dSXt|�dkr�|d}|dj	d	�\}}n%t
|||djj�\}}}t||d
||||tg�dS(Nis+usage: mountIso vm iso controller port:slotiR�iRbsno DVD with path %s registerediRSR�(
R4ReR�RRAR�RRVRR3R9R�R((	RRARHR�R?R2RHRWR�((s /usr/lib/virtualbox/vboxshell.pytmountIsoCmd�	s&


0
%"c	Cs�t|�dkr td�dSt||�}|dkr?dS|d}t|�dkr�|d}|djd�\}}n%t|||djj�\}}}t||d|||dt	g�dS(	Nis)usage: unmountIso vm controller port:slotiR�iRSRbR�(
R4ReR�RR3R9R�RR�R((RRARHR�RHRWR�((s /usr/lib/virtualbox/vboxshell.pyt
unmountIsoCmd�	s


%"cCs=|\}}}|j||�}|dkr9||_ndS(N(taddStorageControllerRR(RRHRAR<RtctrltypeRH((s /usr/lib/virtualbox/vboxshell.pyt	attachCtr�	scCs�t|�dkr td�dSt|�dkrmt|d|d�}|dkrstd|d�dSnd}t||�}|dkr�dSt|d|d�}|dkr�td|d�dS|d	}t||t|||g�dS(
Nis$usage: attachCtr vm cname bus <type>iR�sController type %s unknownR�isBus type %s unknowni(R4ReR�RR�R�Ra(RRAR`RHRR<((s /usr/lib/virtualbox/vboxshell.pytattachCtrCmd�	s&

csft|�dkr td�dSt||�}|dkr?dS|d�t||�fd��dS(Nisusage: detachCtr vm nameiics
|j��S(N(tremoveStorageController(RRHRA(RH(s /usr/lib/virtualbox/vboxshell.pyR��	s(R4ReR�RR�(RRARH((RHs /usr/lib/virtualbox/vboxshell.pytdetachCtrCmd�	s

cCs6|dr!|j|dd�n|j|d�dS(NiiR(tattachUSBDevicetdetachUSBDevice(RRHR�RA((s /usr/lib/virtualbox/vboxshell.pytusbctr�	s
cCsit|�dkr td�dSt||�}|dkr?dS|d}t||dtt|g�dS(Nisusage: attachUsb vm deviceuidiiR�(R4ReR�RR�RgR((RRARHtdev((s /usr/lib/virtualbox/vboxshell.pytattachUsbCmd�	s

cCsit|�dkr td�dSt||�}|dkr?dS|d}t||dtt|g�dS(Nisusage: detachUsb vm deviceuidiiR�(R4ReR�RR�RgR(RRARHRh((s /usr/lib/virtualbox/vboxshell.pytdetachUsbCmd�	s

cCsnt|�dkr td�dS|dj�}tjj|d�}ytj|�Wntk
rinXdS(Nis
usage: guiiRbt
VirtualBox(R4Ret	getBinDirR1R2R7RVRo(RRAtbinDirR�((s /usr/lib/virtualbox/vboxshell.pytguiCmd
s

cst|�dkr td�dSt||�}|dkr?dS|d�|d�t�t}t|�dkr�x?|dD]0}|dkr�t�n|dkr|t}q|q|Wn|r�t||���fd�g�n%t||d	���fd
�g�dS(Nis7usage: shareFolder vm path name <writable> <persistent>iiiRut
persistentcs|j����S(N(tcreateSharedFolder(RRHRA(R<R2Ru(s /usr/lib/virtualbox/vboxshell.pyR�#
sR�cs|j����S(N(Rp(RRHR�RA(R<R2Ru(s /usr/lib/virtualbox/vboxshell.pyR�%
s(R4ReR�RRR(R�R�(RRARHRoR((R<R2Rus /usr/lib/virtualbox/vboxshell.pytshareFolderCmd
s(


	%%cs�t|�dkr td�dSt||�}|dkr?dS|d�t}xS|dj|d�D];}|j�krft||�fd�g�t}PqfqfW|s�t	||d�fd	�g�ndS(
Nisusage: unshareFolder vm nameiiRbR{cs
|j��S(N(tremoveSharedFolder(RRHRA(R<(s /usr/lib/virtualbox/vboxshell.pyR�4
sR�cs
|j��S(N(Rr(RRHR�RA(R<(s /usr/lib/virtualbox/vboxshell.pyR�8
s(
R4ReR�RRR�R<R�R(R�(RRARHtfoundRw((R<s /usr/lib/virtualbox/vboxshell.pytunshareFolderCmd(
s 

"cst|�dks"|ddkrDtd�td�td�dSt||�}|dkrcdS|d}|dkr�t|�d	kr�td
�dS|d�t|�d	kr�|d	�nd�t||��fd
��dS|dkrJt|�d	krtd�dS|d�|j���t||�fd��dS|dkr�t|�d	krvtd�dS|j��t||�fd��dS|dkrt|�d	kr�td�dS|d�|j���t||�fd��dStd|�dS(NiiR$s5Take snapshot:    snapshot vm take name <description>s*Restore snapshot: snapshot vm restore names(Merge snapshot:   snapshot vm merge nameittakeis*usage: snapshot vm take name <description>iRcs t||j��t�d�S(Ni(RtttakeSnapshotR((RRHR�RA(R�R<(s /usr/lib/virtualbox/vboxshell.pyR�P
strestoresusage: snapshot vm restore namecst||j���S(N(RttrestoreSnapshot(RRHR�RA(tsnap(s /usr/lib/virtualbox/vboxshell.pyR�Y
strestorecurrents!usage: snapshot vm restorecurrentcst||j���S(N(RtRx(RRHR�RA(Ry(s /usr/lib/virtualbox/vboxshell.pyR�a
stdeletesusage: snapshot vm delete namecst||j�j��S(N(RttdeleteSnapshotR=(RRHR�RA(Ry(s /usr/lib/virtualbox/vboxshell.pyR�j
ssCommand '%s' is unknown(R4ReR�RR�tfindSnapshottcurrentSnapshot(RRARHR�((R�R<Rys /usr/lib/virtualbox/vboxshell.pytsnapshotCmd<
sX"











cCsSidd6dd6dd6}t|�dkr�d}d}x}t|j��D]i\}}	|dkrmd}n
|d	7}t|j�|	@r�|d
|df7}qL|d
|df7}qLWd|gfSd|_d
|krOxqtdt|��D]W}
||
|kr*td||
�ttj�dSt|j�|||
B|_q�WndS(s)This command shows/alters NAT's alias settings.
    usage: nat <vm> <nicnum> alias [default|[log] [proxyonly] [sameports]]
    default - set settings to default values
    log - switch on alias logging
    proxyonly - switch proxyonly mode on
    sameports - enforces NAT using the same ports
    iR�it	proxyonlyit	sameportsiRs, s%s: %sR�R�tdefaultsInvalid alias mode: N(iN(iN(
R4RORPRlt	aliasModeR�RetnatAliast__doc__R(RRHtnicnumtnatRAtaliastfirsttmsgt	aliasmodetaliaskeyR((s /usr/lib/virtualbox/vboxshell.pyR�p
s0
	

	
%c
Cs[t|�dkr�|j�\}}}}}	|dkrBd}n|dkrWd}n|dkrld}n|dkr�d}n|	dkr�d}	nd|||||	f}
d|
gfS|ddkr�td|d�dSxvtdt|��D]_}||j�s;t||�d	ks;t||�d
kr�td|||f�dSq�W|dg}t|�dkr�x.tdt|��D]}|j||�q�Wx^tt|�d�D]}|jd�q�Wn1x.tdt|��D]}|j||�q�W|jt|d�t|d�t|d�t|d
�t|d��dS(sJThis command shows/alters NAT settings.
    usage: nat <vm> <nicnum> settings [<mtu> [[<socsndbuf> <sockrcvbuf> [<tcpsndwnd> <tcprcvwnd>]]]]
    mtu - set mtu <= 16000
    socksndbuf/sockrcvbuf - sets amount of kb for socket sending/receiving buffer
    tcpsndwnd/tcprcvwnd - sets size of initial tcp sending/receiving window
    iii�i@s4mtu:%s socket(snd:%s, rcv:%s) tcpwnd(snd:%s, rcv:%s)i�>s0invalid mtu value (%s not in range [65 - 16000])iiis/invalid %s parameter (%i not in range [8-1024])iiiN(iN(iN(iN(	R4tgetNetworkSettingsReRR�tisdigitRlR6tsetNetworkSettings(
RRHR�R�RAtmtut
socksndbuft
sockrcvbuft	tcpsndwndt	tcprcvwndR�R�R((s /usr/lib/virtualbox/vboxshell.pytnatSettings�
s>					
=
KcCs�idd6dd6}t|�dkrmd|t|j�|t|j�|t|j�f}d|gfSd|k|_d|k|_d|k|_d
S(s9This command shows/alters DNS's NAT settings
    usage: nat <vm> <nicnum> dns [passdomain] [proxy] [usehostresolver]
    passdomain - enforces builtin DHCP server to pass domain
    proxy - switch on builtin NAT DNS proxying mechanism
    usehostresolver - proxies all DNS requests to Host Resolver interface
    R�iR�is+passdomain:%s, proxy:%s, usehostresolver:%st
passdomaintproxytusehostresolverN(iN(R4Rlt
DNSPassDomaintDNSProxytDNSUseHostResolverR(RRHR�R�RAtyesnoR�((s /usr/lib/virtualbox/vboxshell.pytnatDns�
s:
cCs�t|�dkr-|j}|dkr�|j}|dkrSdt|�d}n|jd�\}}x#|jd�dkr�|d7}qkW|jd�\}}}	}
d|||	f}n|j}|dkr�d	|d
j}n|j	}|dkr
d|j
}nd|||f}
d
|
gfS|d}t|�dkrgtd|�ttj
�dS|dkr�|d|_nI|dkr�|d|_	n-|dkr�|d|_ntd|�dSdS(s�This command shows/alters TFTP settings
    usage nat <vm> <nicnum> tftp [prefix <prefix>| bootfile <bootfile>| server <server>]
    prefix - alters prefix TFTP settings
    bootfile - alters bootfile TFTP settings
    server - sets booting server
    is
10.0.%d/24iRR�is.0s
%d.%d.%d.4s%s/TFTP/R�s%s.pxes!server:%s, prefix:%s, bootfile:%sis
invalid args:tprefixtbootfiletserversinvalid cmd:N(iN(iN(iN(R4tTFTPNextServerRtnetworkRlR3tcountt
TFTPPrefixt
homeFoldertTFTPBootFileR<RetnatTftpR�(RRHR�R�RAR�tmaskRRRFR�R�R�R�R�((s /usr/lib/virtualbox/vboxshell.pyR��
sB				




c	s�t��dkr�idd6dd6�g}|dj�d�}xb|D]Z}t|�jd�\}}	}
}}}
|jd|�t|	�|
|||
f�qIWd|fSidd6dd6�ii���fd	�d
6���fd�d6d
6i���fd�d
6���fd�d6d6i���fd�d
6���fd�d6d6i�fd�d
6��fd�d6d6���dd
�s�td�d�ttj�dS��dd�}dS(sBThis command shows/manages port-forwarding settings
    usage:
        nat <vm> <nicnum> <pf> [ simple tcp|udp <hostport> <guestport>]
            |[no_name tcp|udp <hostip> <hostport> <guestip> <guestport>]
            |[ex tcp|udp <pf-name> <hostip> <hostport> <guestip> <guestport>]
            |[delete <pf-name>]
    itudpittcpRbt	redirectss, s%s: %s %s:%s => %s:%scsH�dt�j��koG�dt�j��koGt��dkS(Niii(ROR]R4((RAtpfcmdR�(s /usr/lib/virtualbox/vboxshell.pyR�stvalidatec	s8�jd��ddt�d�dt�d��S(NRiii(taddRedirectRl((RAR�R�(s /usr/lib/virtualbox/vboxshell.pyR�stfuncR�csH�dt�j��koG�dt�j��koGt��dkS(Niii(ROR]R4((RAR�R�(s /usr/lib/virtualbox/vboxshell.pyR�
sc	s@�jd��d�dt�d��dt�d��S(NRiiiii(R�Rl((RAR�R�(s /usr/lib/virtualbox/vboxshell.pyR�stno_namecsH�dt�j��koG�dt�j��koGt��dkS(Niii(ROR]R4((RAR�R�(s /usr/lib/virtualbox/vboxshell.pyR�sc	sD�j�d��d�dt�d��dt�d��S(Niiiiii(R�Rl((RAR�R�(s /usr/lib/virtualbox/vboxshell.pyR�stexcst��dkS(Ni(R4((RA(s /usr/lib/virtualbox/vboxshell.pyR�scs�j�d�S(Ni(tremoveRedirect((RAR�(s /usr/lib/virtualbox/vboxshell.pyR�sR{s/invalid port-forwarding or args of sub command N(iN(iN(
R4R�R
R3R6RlRetnatPortForwardingR�R(RRHR�R�RAR�tpfstpftpfnmetpfptpfhiptpfhptpfgiptpfgpR((RAR�R�R�s /usr/lib/virtualbox/vboxshell.pyR��
s8
'1

cCs�t|�dkrm|jdk	rLtt|j��dkrLd|j}ndt|�d}d|gfS|djd�\}}|jd�dks�t|�dks�t|�d	kr�td
�dS|d|_d
S(sdThis command shows/alters NAT network settings
    usage: nat <vm> <nicnum> network [<network>]
    iis'%s's10.0.%d.0/24iRR�ii sInvalid argumentsN(iN(iN(R4R�RR
RlR3R�Re(RRHR�R�RAR�taddrR�((s /usr/lib/virtualbox/vboxshell.pyt
natNetworks*
9

cCs�itd6td6td6td6td6td6}t|�dksR|dd	kr�t|�dkr|t||dj�n
tt	j�d
St|�dks�t|�dks�|d|kr�tt	j�d
S|d
|�}|dkr�td�d
St|�dksW|dj�sWt|d�t
td
|djj|j���kr�td|d|djj|j�f�d
St|d�}g}x.tdt|��D]}|j||�q�W|d}d}d}	t|�dkr d
}|dj|dt�}	|	j}n|j|�}
|
j}|||||||�\}}
|d
kr�|d
kr|j�n|	j�nC|
dk	r�x4|
D])}d|j|||f}t|�q�Wnd
S(s�This command is entry point to NAT settins management
    usage: nat <vm> <nicnum> <cmd> <cmd-args>
    cmd - [alias|settings|tftp|dns|pf|network]
    for more information about commands:
    nat help <cmd>
    R�tsettingsttftptdnsR�R�iiR$iiiR�splease specify vmR�s3please specify adapter num %d isn't in range [0-%d]RbR�s%s nic%d %s: %sN(R�R�R�R�R�R�R4ReR�tnatCmdRR�RlROR�R�R�R�R6R�RR�R�t	NATEngineR�R�R<(RRAtnatcommandsRHR�tcmdargsR�R�t	rosessionR�R�t	natEnginetrctreportRR�((s /usr/lib/virtualbox/vboxshell.pyR�1sZ
"
4

[+
	"


cCs�t|�dkrIidd6dd6}|t|j|��}d|fSidd6dd6}|d|kr�td|dt|j��f�dS|j|||d�dS(NiR�iR�s%%s isn't acceptable, please choose %s(iN(iN(R4Rlt__getattr__ReROR]Rt__setattr__(R�R�RAR�R((s /usr/lib/virtualbox/vboxshell.pytnicSwitchOnOffns
$cCs�t|d|�\}}t|�dkrS|dkrSd||jf}d|fSt|�dkr�|dkr�|d|_ndS(	s8
    usage: nic <vm> <nicnum> trace [on|off [file]]
    ttraceEnablediis
%s file:%siiN(iN(R�R4t	traceFileR(RR�R�R�RAR�R((s /usr/lib/virtualbox/vboxshell.pytnicTraceSubCmd{s
cCsft|�dkr)d|j}d|fS|dj�sOtd|d�dSt|d�|_dS(Nis%d kbpsis%s isn't a number(iN(iN(R4t	lineSpeedR�ReRRl(RR�R�R�RAR((s /usr/lib/virtualbox/vboxshell.pytnicLineSpeedSubCmd�s

cCst|d|�S(s1
    usage: nic <vm> <nicnum> cable [on|off]
    tcableConnected(R�(RR�R�R�RA((s /usr/lib/virtualbox/vboxshell.pytnicCableSubCmd�scCst|d|�S(s2
    usage: nic <vm> <nicnum> enable [on|off]
    R(R�(RR�R�R�RA((s /usr/lib/virtualbox/vboxshell.pytnicEnableSubCmd�scCs�t|�dkru|djd�}xIt|j��D]5}t|j�t||�kr8dt|�fSq8WdS|djd�}|dt|j��kr�td|dt|j��f�dS||d|_d	S(
s_
    usage: nic <vm> <nicnum> type [Am79c970A|Am79c970A|I82540EM|I82545EM|I82543GC|Virtio]
    iR6tNetworkAdapterTypeis %s not in acceptable values (%s)N(iN(iN(iN(R4R\ROR]R
R�RRe(RR�R�R�RAtnictypesRY((s /usr/lib/virtualbox/vboxshell.pyt
nicTypeSubCmd�s$c	s�t��dkr�id"�djj6d#�djj6d�jf�djj6d�jf�djj6d�jf�djj	6d$�djj
6}t�j�t
kr�t�j�}n	�j}||\}}d
d||ffSii�fd�d
6d�d6�fd�d6d6i�fd�d
6d�d6�fd�d6d6i�fd�d
6��fd�d6�fd�d6d6i�fd�d
6��fd�d6�fd�d6d6i�fd�d
6��fd�d6�fd�d6d6i�fd�d
6d�d6�fd �d6d	6}�dt|j��krxtd!�dt|j��f�d&S|�dd
�s�t|j�d'S|�dd�|�dd��_d(S()sp
    usage: nic <vm> <nicnum> attachment [Null|NAT|Bridged <interface>|Internal <name>|HostOnly <interface>
    itNullRRbtNATtBridgedtInternaltHostOnlytGenericisattachment:%s, name:%scst��dkS(Ni(R4((RA(s /usr/lib/virtualbox/vboxshell.pyR��sR�cSsdS(Ns
do nothing((((s /usr/lib/virtualbox/vboxshell.pyR��sRcs�djjS(NRb(R�tNetworkAttachmentType_Null((R(s /usr/lib/virtualbox/vboxshell.pyR��sRBcst��dkS(Ni(R4((RA(s /usr/lib/virtualbox/vboxshell.pyR��scSsdS(Ns
do nothing((((s /usr/lib/virtualbox/vboxshell.pyR��scs�djjS(NRb(R�tNetworkAttachmentType_NAT((R(s /usr/lib/virtualbox/vboxshell.pyR��scst��dkS(Ni(R4((RA(s /usr/lib/virtualbox/vboxshell.pyR��scs�jd�d�S(NtbridgedInterfacei(R�((R�RA(s /usr/lib/virtualbox/vboxshell.pyR��scs�djjS(NRb(R�tNetworkAttachmentType_Bridged((R(s /usr/lib/virtualbox/vboxshell.pyR��scst��dkS(Ni(R4((RA(s /usr/lib/virtualbox/vboxshell.pyR��scs�jd�d�S(NtinternalNetworki(R�((R�RA(s /usr/lib/virtualbox/vboxshell.pyR��scs�djjS(NRb(R�tNetworkAttachmentType_Internal((R(s /usr/lib/virtualbox/vboxshell.pyR��scst��dkS(Ni(R4((RA(s /usr/lib/virtualbox/vboxshell.pyR��scs�jd�d�S(NthostOnlyInterfacei(R�((R�RA(s /usr/lib/virtualbox/vboxshell.pyR��scs�djjS(NRb(R�tNetworkAttachmentType_HostOnly((R(s /usr/lib/virtualbox/vboxshell.pyR��scst��dkS(Ni(R4((RA(s /usr/lib/virtualbox/vboxshell.pyR��scSsdS(Ns
do nothing((((s /usr/lib/virtualbox/vboxshell.pyR��scs�djjS(NRb(R�tNetworkAttachmentType_Generic((R(s /usr/lib/virtualbox/vboxshell.pyR��ss %s not in acceptable values (%s)(R�R(R�R(R�RN(iN(iN(iN(R4R�R�R�R�R�R�R�R�R�R�R�tattachmentTypeRlR
ROR]ReRR�(	RR�R�R�RAtnicAttachmentTypeRRR((R�RARs /usr/lib/virtualbox/vboxshell.pytnicAttachmentSubCmd�s^	


$
cCs6itd6td6td6td6td6td6}t|�dkst|dd	kstt|�dkr�|d
|kr�t|�d
kr�|d|kr�t||dj�n
tt	j�dS|d|�}|dkr�td
�dSt|�d
ks3t|d�tt
d|djj|j���krbtd|d|djj|j�f�dSt|d�}|d
}|d
}d}|dj|dt�}|j}|j|�}|||||||�\}	}
|	dkr�|j�n|
dk	r(td|j||d
|
f�n|j�dS(s�
    This command to manage network adapters
    usage: nic <vm> <nicnum> <cmd> <cmd-args>
    where cmd : attachment, trace, linespeed, cable, enable, type
    t
attachmentttracet	linespeedtcabletenableR�iiR$iiR�splease specify vmR�s3please specify adapter num %d isn't in range [0-%d]RbR�s%s nic %d %s: %sN(R�R�R�R�R�R�R4ReR�tnicCmdRRlROR�R�R�R�R�R(R�R�R�R<R�(RRAt	niccomandR�R�R�R�R�R�R�R�((s /usr/lib/virtualbox/vboxshell.pyR��sJ
"

8+

	"
$
cCs:t|�dkr(td|d�dS|d|d<dS(NisCurrent prompt: '%s'RDii(R4Re(RRA((s /usr/lib/virtualbox/vboxshell.pyt	promptCmds
cCs�t|�dkr td�dS|d}|d}t||�}y"x|D]}|j|�qMWWntd�tj�nXdS(NisZusage: foreach scope command, where scope is XPath-like expression //vms/vm[@CPUCount='2']iiisError executing(R4ReR�R�RARB(RRAR�R�telemsRI((s /usr/lib/virtualbox/vboxshell.pyt
foreachCmd$s




cCsot|�dkr td�dS|d}|jdd�x.t|�D] }|j|d<t||�qGWdS(Nisforeachvm command <args>iiR(R4ReRKR9R=trunCommandArgs(RRAR�RH((s /usr/lib/virtualbox/vboxshell.pytforeachvmCmd4s


cs�t|�dkr td�dSt||�}|dkr?dS|d�d�t|�dkrtt|d��nt||d��fd�g�dS(Nis(usage: recordDemo vm filename (duration)iii'R�cst||���S(N(R(RRHR�RA(RR(s /usr/lib/virtualbox/vboxshell.pyR�Js(R4ReR�RR$R�(RRARH((RRs /usr/lib/virtualbox/vboxshell.pyt
recordDemoCmd?s

"cs�t|�dkr td�dSt||�}|dkr?dS|d�d�t|�dkrtt|d��nt||d��fd�g�dS(Nis*usage: playbackDemo vm filename (duration)iii'R�cst||���S(N(R4(RRHR�RA(RR(s /usr/lib/virtualbox/vboxshell.pyR�Xs(R4ReR�RR$R�(RRARH((RRs /usr/lib/virtualbox/vboxshell.pytplaybackDemoCmdMs

"cCs0d|d?|d@d?|d@f}t||�S(Ns%02x:%02x.%dii�ii(R�(RR�R((s /usr/lib/virtualbox/vboxshell.pytpciAddr\s#cCs|dj|jd�}xU|D]M}|jr tdt||j�t||j�t||j�f�q q W|dj|d�}x�|D]y}|jr�tdt||j�t||j�t||j�f�q�tdt||j�t||j�f�q�WdS(NRbtPCIDeviceAssignmentss$%s: assigned host device %s guest %stattachedPCIDevicess%s: physical, guest %s, host %ss%s: virtual, guest %s(	R�R�tisPhysicalDeviceReR�R<R�thostAddresstguestAddress(RR�tassignedRR8((s /usr/lib/virtualbox/vboxshell.pytlspci`s
	B
	>0cCsrtjd�}|j|�}|dkr.dS|j�}t|dd�d>t|dd�d>Bt|d�BS(	Ns2(?P<b>[0-9a-fA-F]+):(?P<d>[0-9a-fA-F]+)\.(?P<f>\d)i����RiiR�iRB(R:R R!RR"Rl(RtpcireR-tpdict((s /usr/lib/virtualbox/vboxshell.pytparsePcinscCs\t|�dkr td�dSt||�}|dkr?dSt||dd�g�dS(Nisusage: lspci vmiR�cSs
t||�S(N(R�(RRHR�RA((s /usr/lib/virtualbox/vboxshell.pyR�}s(R4ReR�RR�(RRARH((s /usr/lib/virtualbox/vboxshell.pytlspciCmdvs
cs�t|�dkr td�dSt||�}|dkr?dSt|d���dkrqtd|d�dSt|�dkr�t|d���dkr�td|d�dSn��t||��fd��dS(	Nis&usage: attachpci vm hostpci <guestpci>iii����sLinvalid host PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3sMinvalid guest PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3cs|j��t�S(N(tattachHostPCIDeviceR((RRHR(t	guestaddrthostaddr(s /usr/lib/virtualbox/vboxshell.pyR��s(R4ReR�RRR�(RRARH((RRs /usr/lib/virtualbox/vboxshell.pytattachpciCmd�s$
cs�t|�dkr td�dSt||�}|dkr?dSt|d���dkrqtd|d�dSt||�fd��dS(Nisusage: detachpci vm hostpciiii����sLinvalid host PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3cs
|j��S(N(tdetachHostPCIDevice(RRHR(R(s /usr/lib/virtualbox/vboxshell.pyR��s(R4ReR�RRR�(RRARH((Rs /usr/lib/virtualbox/vboxshell.pytdetachpciCmd�s
cCs>t|�dkr td�dSt|d�}||d<dS(Nisusage: goto lineiiR�(R4ReRl(RRAR
((s /usr/lib/virtualbox/vboxshell.pytgotoCmd�s

tstarttinfoROR$R�tquittexitt	typeGuestttgR%sPrints help informations;Start virtual machine by name or uuid: start Linux headlesss,Create virtual machine: createVm macvm MacOSR�sRemove virtual machineR�sPause virtual machineR�sResume virtual machineR�s'Save execution state of virtual machineR@sStats for virtual machineR�sPower down virtual machineR�sEffectively press power buttonR�sShows known virtual machinessShows info on machinesShows info on guestR�sExecutes program in the guesttgexecsCopy file to the guesttgcopysPipe between host and guesttgpipesControl aliasessToggle verbositys=Set VMs variable: setvar Fedora BIOSSettings.ACPIEnabled TrueRmsqEvaluate arbitrary Python construction: eval 'for m in getMachines(ctx): print(m.name, "has", m.memorySize, "M")'tevaltExitssShow host informationRVsUExecute command for guest: guest Win32 'console.mouse.putMouseEvent(20, 20, 0, 0, 0)'R�sHMonitor what happens with the guest for some time: monitorGuest Win32 10tmonitorGuests>Monitor guest keyboard for some time: monitorGuestKbd Win32 10tmonitorGuestKbds=Monitor guest mouse for some time: monitorGuestMouse Win32 10tmonitorGuestMousesIMonitor guest touch screen for some time: monitorGuestMultiTouch Win32 10tmonitorGuestMultiTouchsBMonitor what happens with VirtualBox for some time: monitorVBox 10tmonitorVBoxstSetup permanent port forwarding for a VM, takes adapter number host port and guest port: portForward Win32 0 8080 80tportForwards(Show log file of the VM, : showLog Win32tshowLogsMShow entries matching pattern in log file of the VM, : findLog Win32 PDM|CPUMtfindLogs5Find assert in log file of the VM, : findAssert Win32t
findAsserts#Reload custom extensions: reloadExtt	reloadExts&Run VBox script: runScript script.vboxt	runScripts4Sleep for specified number of seconds: sleep 3.14159R#s3Execute external shell command: shell "ls /etc/rc*"tshells2Export VM in OVF format: exportVm Win /tmp/win.ovftexportVmsDTake VM screenshot to a file: screenshot Win /tmp/win.png 1024 768 0R�saTeleport VM to another box (see openportal): teleport Win anotherhost:8000 <passwd> <maxDowntime>RTsWType arbitrary text in guest: typeGuest Linux "^lls\n&UP;&BKSP;ess /etc/hosts\nq^c" 0.7saOpen portal for teleportation of VM from another box (see teleport): openportal Win 8000 <passwd>t
openportalsFClose teleportation portal (see openportal, teleport): closeportal Wintcloseportals?Get extra data, empty key lists all: getextra <vm|global> <key>tgetextrasKSet extra data, empty value removes key: setextra <vm|global> <key> <value>tsetextrasYPrint available guest stats (only Windows guests with additions so far): gueststats Win32R�s(Add a CPU to a running VM: plugcpu Win 1R�s]Remove a CPU from a running VM (additions required, Windows cannot unplug): unplugcpu Linux 1R�s.Create virtual HDD:  createHdd 1000 /disk.vdi t	createHdds3Permanently remove virtual HDD: removeHdd /disk.vdit	removeHddsBRegister HDD image with VirtualBox instance: registerHdd /disk.vditregisterHddsFUnregister HDD image with VirtualBox instance: unregisterHdd /disk.vdit
unregisterHddsBAttach HDD to the VM: attachHdd win /disk.vdi "IDE Controller" 0:1t	attachHdds/Detach HDD from the VM: detachHdd win /disk.vdit	detachHddsCRegister CD/DVD image with VirtualBox instance: registerIso /os.isotregisterIsosGUnregister CD/DVD image with VirtualBox instance: unregisterIso /os.isot
unregisterIsos2Permanently remove CD/DVD image: removeIso /os.isot	removeIsosCAttach CD/DVD to the VM: attachIso win /os.iso "IDE Controller" 0:1t	attachIsos0Detach CD/DVD from the VM: detachIso win /os.isot	detachIsosIMount CD/DVD to the running VM: mountIso win /os.iso "IDE Controller" 0:1RisCUnmount CD/DVD from running VM: unmountIso win "IDE Controller" 0:1t
unmountIsos@Attach storage controller to the VM: attachCtr win Ctr0 IDE ICH6Ras*Detach HDD from the VM: detachCtr win Ctr0t	detachCtrsWAttach USB device to the VM (use listUsb to show available devices): attachUsb win uuidt	attachUsbs1Detach USB device from the VM: detachUsb win uuidt	detachUsbs&List media known to this VBox instancet	listMediasList known USB devicestlistUsbsJMake host's folder visible to guest: shareFolder win /share share writabletshareFoldersRemove folder sharingt
unshareFoldersStart GUI frontendR%s
Toggle colorstcolorss5VM snapshot manipulation, snapshot help for more infotsnapshotsMNAT (network address translation engine) manipulation, nat help for more infoR�sNetwork adapter managementR�sControl shell promptRDsPerform command for each VMt	foreachvmsqGeneric "for each" construction, using XPath-like notation: foreach //vms/vm[@OSTypeId='MacOS'] "print(obj.name)"tforeachs)Record demo: recordDemo Win32 file.dmo 10Rs-Playback demo: playbackDemo Win32 file.dmo 10R4s0List PCI devices attached to the VM: lspci Win32R�s9Attach host PCI device to the VM: attachpci Win32 01:00.0t	attachpcis;Detach host PCI device from the VM: detachpci Win32 01:00.0t	detachpcis"Go to line in script (script-only)tgotocCs�|d}tj|d�dkr/t|}ntj|d�}|dkr_td|�dS|dr�|ddkr�|dkr�td	tdd
��dSn|d||�S(
Nis=Unknown command: '%s', type 'help' for list of known commandsR�R�R�t	reconnectR$Rs/First connect to remote server with %s command.Ri(sconnectR@shelpsquit(RwRRR�ReR(RRARFtci((s /usr/lib/virtualbox/vboxshell.pyR�

s

cCs9|s
dSt|�}t|�dkr,dSt||�S(Ni(R`R4R�(RR�RA((s /usr/lib/virtualbox/vboxshell.pyR�
scBs�ejj|�sdSi}y�ee|�j�|d�||fdUx`e|dj��D]H\}}er�e	d||df�n|d|d|g||<q_WWne	d|�e
j�nXdS(NtexecR�scustomize: adding "%s" - %siis%Error loading user extensions from %s(R1R2tisfileR RtreadRORPR@ReRARB(RRWRR�RR�((s /usr/lib/virtualbox/vboxshell.pytaddExtsFromFile3
s)##cCs�t|�}tjj|d�}t|||�tjj|d�}tjj|�s\dStj|�}x?|D]7}|jd�rrt||tjj||��qrqrWdS(Nsshellext.pytshextss.py(R
R1R2R7REtisdirR5tendswith(RRWtfolderR<tshextdirtextsRI((s /usr/lib/virtualbox/vboxshell.pyR�B
s
cCsn|ds|ddkr_dtjkr@tjjtjd�Stjjtjjd�d�S|djSdS(NR�R�tVBOX_USER_HOMEt~s.VirtualBox(RR1tenvironR2R7t
expanduserR�(R((s /usr/lib/virtualbox/vboxshell.pyR�P
s
c	Cs3|drYdtdgtd<dtdgtd<dtdgtd<d	d
d
g|d<n|d}|dk	r�ytd
|j�Wn3tk
r�}t||�t	r�t
j�q�nXd|d<n
d|d<t|�}t
|t|�tj�dkrtantjj|d�}tt|�trRtjj|�rRtj|�n|dr�y'|djdg|jgdd�Wq�q�Xng}tdk	r�tjd�}n|j�}xtr�y�t r�dt!}nQtdk	r�t"|�}n6t#j$ddkr t%|d�}nt&|d�}t'||�}|dkrOPnt rYPnWnot(k
rwtd�nUt)k
r�PnDt*k
r�Pn3tk
r�}t||�t	r�t
j�q�nX|dj+d�q�Wy.t,dr|dj-dg|jg�nWnnXtr/tj.|�ndS(NR�sJConnect to remote VBox instance: connect http://server:18083 user passwordiR�s$Disconnect from remote VBox instanceR�s!Reconnect to remote VBox instanceR@shttp://localhost:18083RR�R�sRunning VirtualBox version %sR�tWindowst	Microsofts.vboxshellhistoryR�i
iR�srunScript %siRDs&====== You can type quit or q to leaveRb(RPRQ(/R�R�R�R�RReR~R>R?R@RARBR�R�RURVRR	R1R2R7R]RNtexistsR&tread_history_fileR�RVtg_sCmdR3t__iter__R(tg_fBatchModet
g_sScriptFiletnextRgtversion_infot	raw_inputtinputR�Rot
StopIterationRCRktcttdisabletwrite_history_file(	RR�RIthomet	hist_fileRWtitR�R�((s /usr/lib/virtualbox/vboxshell.pyt	interpretX
s�




	

'	






$cCs|jd|�t||�S(Ni(RKR�(RR�RA((s /usr/lib/virtualbox/vboxshell.pytrunCommandCb�
scCsFt||�}|dkrdS|jd|�t||d|�dS(NiR�(R�RRKR�(RR�tguestLambdaRARH((s /usr/lib/virtualbox/vboxshell.pytrunGuestCommandCb�
scs�t�}|jdddddddtdd	�|jd
ddddddtdd
�|jdddddddddd�|jdddddd�|jddddd�|jddddd�|j�\}}|ja|j}|jdk	r t	a
tata|ja
n|jdk	rGtata|jand}|jdk	r�i}|j}|jd�}x0|D]%}|jd �\}	}
|
||	<q�Wn|jr�tj�g}y"tjjtjjt��}Wnn?Xtj�dEkr"|jtjj|d"��n|j|�tjjd#�}
|
dkr�xw|D]l}tjjtjj|d$��s�tjjtjj|d%��rTt d&|�|tjd#<|}
PqTqTWn|
r�t!jjtjj|
d'd(��ntjjd)�}
|
dkr�xq|D]f}tjjtjj|d'd*d+��rtjj|d'�}t d,|�|tjd)<|}
PqqWn|
r�|
}tjj|d*d-d.�}tjj"|�r�t!jj|�n~n~
~nd/d0l#m$}|||�}i|d16|j%�d26|j&d6|j'd36|j(d46�fd5�d66�fd7�d86�fd9�d:6�fd;�d<6�fd=�d>6t)d?6dd@6t*dA6dBdC6tdD6�t+��x!t,�j-��D]
}�|=q�Wd�t.j/�|j0�~dS(FNs-vs	--verbosetdestR%tactiont
store_trueR�R$sswitch on verboses-as
--autopathtautopathsswitch on autopaths-ws--webservicetstyletstore_constR6t
WEBSERVICEsconnect to webservices-bs--batcht
batch_filesscript file to executes-ctcommand_linescommand sequence to executes-otopt_linesoption lineR�R�tSunOStamd64tVBOX_PROGRAM_PATHRksVirtualBox.exes!Autodetected VBOX_PROGRAM_PATH astsdkt	installert
VBOX_SDK_PATHtbindingssVirtualBox.xidlsAutodetected VBOX_SDK_PATH astxpcomtpythoni����(tVirtualBoxManagerRbR�R�R�cst�||�S(N(Rd(R�RA(R(s /usr/lib/virtualbox/vboxshell.pyR�struncst�|||�S(N(Rf(R�ReRA(R(s /usr/lib/virtualbox/vboxshell.pyR�	sR�cs
t�|�S(N(R�(R�(R(s /usr/lib/virtualbox/vboxshell.pyR�
sR�cs
t�|�S(N(R�(RA(R(s /usr/lib/virtualbox/vboxshell.pyR�sR�cs
t�|�S(N(Rt(R(R(s /usr/lib/virtualbox/vboxshell.pyR�sRtR#R�RDiR�Rc(Rq(1Rt
add_optionRt
parse_argsR%R@RkRnRR(RVR	RNRWRoRTRpR3RjR1tgetcwdR2tdirnametabspatht__file__RURVR6R7RNRRCReRgRGtvboxapiRzt
getVirtualBoxR�R�R�R#t	g_sPromptRcROR]tgctcollecttdeinit(targvtparsetoptionsRARkR/t	strparamststrparamlisttstrparamRYR�tasLocationst
sScriptDirtsPathtsCurLoctsTmpRzRytsKey((Rs /usr/lib/virtualbox/vboxshell.pytmain�
s�	(((			
	"

!!

%
'

	







t__main__(((�R�t
__future__Rt
__copyright__t__version__R�R1RgRAR^R�R:RUtoptparseRRRRVRRWRTR(RNR&RtImportErrorR�R	R
RRRR]R@R`RtR?RnR}RR�R�R�R�R�R�R�R�R�R�R9R�R�R�R�R�R�R�R�RRRR4RNRRRTRcReRgRiRlRsRtRxR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R$R&R(R)R>R?RFRJRLRMRPRWRXRYRZR[R\R]R^R`RaRbRcRdReRfR�RhRiRmRnRpRqRrRuRvRxRyRzR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RRRR#R$R&R(R5R6R9R@RFRIRJR�RNRORSRURXRYRZR[R\R]R^RaRbRdRgRiRjRnRqRtRR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RRRRR	RwR�R�R�RER�R�RcRdRfR�RKR�(((s /usr/lib/virtualbox/vboxshell.pyt<module>s,



	K																								
	N	9	9													1	%				
						y			
<	
	
		
										
	
	
					
	
				
										4										'	
			
		#			




































				=																												
				4%	"		)	.		=	
						:	2									
			

						N			n

Zerion Mini Shell 1.0