+
    KiCQ  c                   s.   R t ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 ^ RI
Ht ^ RIHtHtHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHtHt ^ RIHt ^ RIHtHtHtHt ^ RI H!t! ^ RI"H#t# ^ RI$H%t% ^ RI&H't' ^ RI(H)t) ^ RI*H+t+  ! R R]PX                  ]4      t-R# )z/Install a game by following its install script.N)gettext)GObject)settings)LutrisConfigget_game_by_field)AuthenticationErrorMisconfigurationErrorUnavailableGameError)Delegate)AUTO_EXE_PREFIX)CommandsMixin)MissingGameDependencyErrorScriptingError)LutrisInstaller)NonInstallableRunnerErrorRunnerInstallationErrorsteamwine)download_lutris_media)system)DISPLAY_MANAGER)	AsyncCall)logger)unpack_dependenciesc                   sN  a a ] tR t^t oRtR]P                  RR#3/t ! R R]4      t	R$V 3R llt
R tR tR	 tR
 t]R 4       tR t]R 4       t]R 4       t]R 4       tR tR tR tR tR tR tR tR tR tR%R lt]R 4       t R t!R t"R t#R&R lt$R t%R  t&R! t'R"t(Vt)V ;t*# )'ScriptInterpreterz%Control the execution of an installerrunners-installedNc                   sR   a  ] tR t^!t o RtRR ltR tR tR tR t	R t
R	 tR
tV tR# )'ScriptInterpreter.InterpreterUIDelegatezvThis is a base class for objects that provide UI services
for running scripts. The InstallerWindow inherits from this.Nc                s    Wn         W n        R # Nserviceappid)selfr   r      &&&A/usr/lib/python3.14/site-packages/lutris/installer/interpreter.py__init__Z0ScriptInterpreter.InterpreterUIDelegate.__init__%   s    "LJ    c                    R# )zOCalled to report an error during installation. The installation will then stop.N r    error   &&r"   report_errorZ4ScriptInterpreter.InterpreterUIDelegate.report_error)   s    r$   c                r%   )z7Called to report the current activity of the installer.Nr&   )r    statusr)   r"   report_statusZ5ScriptInterpreter.InterpreterUIDelegate.report_status-       r$   c                r%   )zJCalled to attach the command to a log UI, so its log output can be viewed.Nr&   )r    commandr)   r"   
attach_logZ2ScriptInterpreter.InterpreterUIDelegate.attach_log0   r-   r$   c                    \        4       h)zyCalled to prompt for a disc. When the disc is provided, the callback is invoked.
The method returns immediately, however.ZNotImplementedError)r    messagerequires	installercallback   &&&&&r"   begin_disc_promptZ9ScriptInterpreter.InterpreterUIDelegate.begin_disc_prompt3        &''r$   c                r0   )zCalled to prompt the user to select among a list of options. When the user
does so, the callback is invoked. The method returns immediately, however.r1   )r    aliasZoptionsZ	preselectr5   r6   r"   begin_input_menuZ8ScriptInterpreter.InterpreterUIDelegate.begin_input_menu8   r8   r$   c                s4    \         P                  ! RV4       R# )z?Called to report the successful completion of the installation.z"Installation of game %s completed.N)r   info)r    game_idr+   r!   r"   report_finishedZ7ScriptInterpreter.InterpreterUIDelegate.report_finished=   s    KK<gFr$   )r   r   NN)__name__
__module____qualname____firstlineno____doc__r#   r*   r,   r/   r7   r:   r=   __static_attributes____classdictcell__)__classdict__s   @r"   InterpreterUIDelegater   !   s7     	H			J	]	(
	(
	G 	Gr$   rG   c                s$  < \         SV `  4        R V n        T;'       g    \        P	                  4       V n        V P
                  P                  V n        V P
                  P                  pRV n        R V n	        / V n
        RV n        R V n        . V n        ^ V n        . V n        \         P"                  ! 4       V n        \'        WV P                  VR7      V n        V P(                  P*                  '       g   \-        \/        R4      4      hV P                  '       g8   V P(                  P                  '       d   V P(                  P                  V n        V P(                  P1                  4       pV'       dI   \-        \/        R4      P3                  RP5                  V4      4      V P(                  P*                  R7      hV P7                  4        V P9                  4        V P(                  P:                  '       d   V P=                  4       V n        R # R # )NFr   z.This installer doesn't have a 'script' sectionzInvalid script: 
{}Z
Zfaulty_data)Zsuperr#   target_pathr   rG   interpreter_ui_delegater   r   game_dir_created	game_disc
game_files	cancelledabort_current_taskuser_inputscurrent_commandrunners_to_installr   Zget_current_resolutioncurrent_resolutionr   r4   scriptr   _Z
get_errorsformatjoin_check_binary_dependencies_check_dependencycreates_game_folderget_default_target)r    r4   rJ   Z_appidZscript_errors	__class__s   &&&  r"   r#   ZScriptInterpreter.__init__A   s   '>'k'kBSBiBiBk$33;;--33 % "& "$"1"H"H"J($,,V\]~~$$$ #S!TUU||| 6 6 6>>11DL113 ()00=1IJX\XfXfXmXm  	'') >>---#668D .r$   c                <    V P                   P                  V4       R # r   rJ   r*   r'   r)   r"   on_timeout_errorZ"ScriptInterpreter.on_timeout_errorc       $$11%8r$   c                r]   r   r^   r'   r)   r"   on_idle_errorZScriptInterpreter.on_idle_errorf   r`   r$   c                r]   r   r^   r'   r)   r"   on_signal_errorZ!ScriptInterpreter.on_signal_errori   r`   r$   c                r]   r   r^   r'   r)   r"   on_emission_hook_errorZ(ScriptInterpreter.on_emission_hook_errorl   r`   r$   c                sZ    \         P                  ! R 4       V P                  P                  # )z$Do not access appid from interpreter)r   warningr4   service_appidr       &r"   r   ZScriptInterpreter.appido   s    =>~~+++r$   c                s   \        V P                  P                  R7      pVP                  P	                  R\
        P                  P                  R4      4      pV P                  '       d   V P                  P                  pMRp\
        P                  P                  \
        P                  P                  W#V P                  P                  4      4      # )zReturn default installation dir)Zrunner_slugZ	game_path~ )r   r4   runnerZsystem_configgetospath
expanduserr   ZidrW   	game_slug)r    ZconfigZ	games_dirZservice_dir   &   r"   r[   Z$ScriptInterpreter.get_default_targett   s    $..*?*?@((,,["'':L:LS:QR	<<<,,//KKww!!"'',,yt~~G_G_"`aar$   c                s    \         P                  P                  \        P                  RV P
                  P                  ,          4      # )zIReturn the directory used as a cache for the duration of the installationz%s)rl   rm   rW   r   ZINSTALLER_CACHE_DIRr4   ro   rf   rg   r"   
cache_pathZScriptInterpreter.cache_path~   s.     ww||H88$AYAY:YZZr$   c                s    V P                   P                  P                  R/ 4      P                  R/ 4      P                  4        UUu/ uF  w  rWP	                  V4      bK  	  upp# u uppi )zReturn the script's own environment variable with values
susbtituted. This value can be used to provide the same environment
variable as set for the game during the install process.
r   Zenv)r4   rT   rk   items_substitute)r    keyvalue   &  r"   
script_envZScriptInterpreter.script_env   sg     #nn3377"EII%QSTZZ\
\
 !!%((\
 	
 
s   A(c                s    \        V RR7      pV'       g   \        V R4      pV'       d%   VR,          '       d   VR,          '       d   V# R# R# R# )z1Return a game database row from a dependency nameinstaller_slug)ZfieldslugZ	installed	directoryNr   )
dependencygame   & r"   _get_game_dependencyZ&ScriptInterpreter._get_game_dependency   sH     !3CD$Z8D D%%${*;*;K +<%4r$   c                s
   \        V P                  P                  P                  R4      4      pV F  p\	        V\
        4      '       dz   V Uu/ uF  q3\        P                  ! V4      bK  	  pp\        VP                  4       4      '       g4   \        \        R4      \        R4      P                  V4      ,          4      hK  \        P                  ! V4      '       d   K  \        \        R4      V,          4      h	  R# u upi )zCheck if all required binaries are installed on the system.

This reads a `require-binaries` entry in the script, parsed the same way as
the `requires` entry.
zrequire-binariesz)This installer requires %s on your system or N)r   r4   rT   rk   
isinstancetupler   Zcan_find_executableZanyZvaluesr   rU   rW   )r    Zbinary_dependenciesr{   Zdependency_optionZinstalled_binariess   &    r"   rX   Z,ScriptInterpreter._check_binary_dependencies   s     2$..2G2G2K2KL^2_`-J*e,,nx&nxYjv'A'ABS'TTnx # & -44677(+V)WZ[\bZcZhZhisZt)tuu 8 11*==(+V)WZd)dee .&s   D c                sJ   V P                   P                  '       d   V P                   P                  .pM\        V P                   P                  4      p\	        R4      p\        V4       EF*  w  r4\        V\        4      '       d   V Uu. uF  qPP                  V4      NK  	  up Uu. uF  qU'       g   K  VNK  	  ppV'       gO   \        V4      ^8X  d   \        VR7      h\        VP                  \	        R4      P                  V4      4      4      hV^ 8X  d-   V^ ,          R,          V n        V^ ,          R,          V n        K  K  V P                  V4      pV'       g   \        VR7      hV^ 8X  g   EK  VR,          V n        VR,          V n        EK-  	  R# u upi u upi )a  When a game is a mod or an extension of another game, check that the base
game is installed.
If the game is available, install the game in the base game folder.
The first game available listed in the dependencies is the one picked to base
the installed on.
zYou need to install {} before)ry   r   rz   rx   N)r4   Zextendsr   r3   rU   Z	enumerater   r   r~   lenr   r   rV   rW   rI   )r    ZdependenciesZerror_messageZindexr{   ZdepZinstalled_gamesr|   s   &       r"   rY   Z#ScriptInterpreter._check_dependency   sN    >>!!! NN223L.t~~/F/FGL9:!*<!8E*e,,]g2h]gVY3L3LS3Q]g2h"p2h3lo332h"p&:!+8jII()=)=ainnZ>X)YZZA:'6q'9+'FD$$3A$67G$HDM  00<4*EEA:'+K'8D$$()9$:DM! "92h"ps   
F(	F 6F c                sh   V P                   '       d9   V P                   P                  '       d   V P                  P                  '       g   . #  V P                   P	                  V P                  P                  4      #   \
        \        3 d$   p\        P                  ! RT4       . u Rp?# Rp?ii ; i)z@Get extras and store them to move them at the end of the installz%Unable to download list of extras: %sN)	r   Z
has_extrasr4   re   
get_extrasr   r   r   	exception)r    exr}   r"   r   ZScriptInterpreter.get_extras   s~    |||4<<#:#:#:$..B^B^B^I	<<**4>>+G+GHH#%9: 	DbII	s   .A= =B1B,&B1,B1c                sR    V P                  4       V n        V P                  V4       R# )zCLaunch the install process; returns False if cancelled by the user.T)get_runners_to_installrR   install_runnersr    ui_delegater)   r"   launch_installZ ScriptInterpreter.launch_install   s$    "&"="="?[)r$   c                sN   V P                   P                  '       d   V P                  '       d   \        P                  ! V P                  4      '       gj   V P                   P
                  '       dL    \        P                  ! RV P                  4       \        P                  ! V P                  4       RV n
        R# R# R# R# R#   \         d'   p\        \        R4      T P                  R7      ThRp?i\         d'   p\        \        R4      T P                  R7      ThRp?ii ; i)z<Create the game folder if needed and store if is was createdzCreating destination path %sTzBLutris does not have the necessary permissions to install to path:rH   NzEPath %s not found, unable to create game folder. Is the disk mounted?)r4   ZfilesrI   r   Zpath_existsrZ   r   debugrl   makedirsrK   ZPermissionErrorr   rU   ZFileNotFoundError)r    errr}   r"   create_game_folderZ$ScriptInterpreter.create_game_folder   s     NN      &&t'7'788222;T=M=MND,,-(,% 3 9 ! ! # $Z[ $ 0 0  % $]^ $ 0 0 s+   2AC D$!C00D$=D$>!DD$c                s   . p. pV P                  V P                  P                  4      pVP                  V! 4       4       V P                  P                  P                  R. 4       F  pV P                  V4      w  rVVR8X  g   K  V P                  VR,          4      w  rxV U	u. uF  qP                  NK  	  p
p	Wz9  g   K[  VP                  V P                  V4      ! 4       4       K  	  V FN  pVP                  V 4      '       d   K  \        P                  ! RVP                  4       VP                  V4       KP  	  V# u up	i )zCheck if the runner is installed before starting the installation
Install the required runner(s) if necessary. This should handle runner
dependencies or runners used for installer tasks.
r4   tasknamezRunner %s needs to be installed)Zget_runner_classr4   rj   ZappendrT   rk   _get_command_name_and_paramsZ_get_task_runner_and_namer   Zis_installed_forr   r;   )r    rR   Zrequired_runnersrj   r.   command_namecommand_paramsZrunner_nameZ
_task_nameZrZrunner_namess   &          r"   r   Z(ScriptInterpreter.get_runners_to_install   s   
  &&t~~'<'<=)~~,,00bAG+/+L+LW+U(Lv%*.*H*HX^I_*`'0@A0@10@A2$++D,A,A+,N,PQ B 'F**400=v{{K"))&1 '
 "!  Bs   #E c                s    V P                   '       d.   V P                  V P                   P                  ^ 4      V4       R# V P                  R4       R# )z#Install required runners for a gameNr   )rR   install_runnerpopZemitr   r)   r"   r   Z!ScriptInterpreter.install_runners
  s?    """ 7 7 ; ;A >L		%&r$   c                sV  a a V V3R lp\         P                  ! RVP                  4        VP                  SVP	                  S P
                  4      VR7       R#   \        \        3 d=   p\         P                  ! TP                  4       \        P                  ! T4      ThRp?ii ; i)z-Install runner required by the install scriptc                  s*   < S P                  S4       R # r   )r   r   s   r"   install_more_runnersZ>ScriptInterpreter.install_runner.<locals>.install_more_runners  s      -r$   zInstalling %s)versionr5   N)r   r   r   ZinstallZget_installer_runner_versionr4   r   r   r(   r2   r   Zwrap)r    rj   r   r   r   s   f&f  r"   r   Z ScriptInterpreter.install_runner  s    	. 	_fkk2	2NN;;DNNK-  
 *+BC 	2LL$ %%b)r1	2s   -A B(,7B##B(c                s    V P                  4        \        P                  ! V P                  RR7       V P	                  4        R# )z2Run the pre-installation steps and launch install.T)Zexist_okN)r   rl   r   rq   _iter_commandsrf   rg   r"   launch_installer_commandsZ+ScriptInterpreter.launch_installer_commands#  s,    !
DOOd3r$   c                s  a a	a
 VR 8X  g   S P                   '       d   R#  S P                  P                  P                  R. 4      pV'       d4   \        P
                  ! R4       S P                  P                  V4       R# S P                  \        V4      8  Ed!    VS P                  ,          pS ;P                  ^,          un        S P                  T4      w  o	o
\        S
\        4      '       d   S
P!                  RR4      pMRpT'       d   S P                  P#                  T4       \        P$                  ! RT4       S P&                  '       dP   \(        P*                  P-                  S P&                  4      '       d!   T	T
T 3R lp\/        TS P0                  4       R# \/        S	S P0                  S
4       R# \        P$                  ! RS P                  \        V4      4       S P3                  4        R#   \         d   p\        \        R4      4      ThRp?ii ; i  \4         d>   p\        P6                  ! R	T4       S P                  P                  T4        Rp?R# Rp?ii ; i)
ZSTOPNr4   z'Last install command failed, show errorz.Installer commands are not formatted correctlyZdescriptionzInstaller command: %sc                  s   < \         P                  ! 4       p \         P                  ! SP                  4        S! S4      \         P                  ! V 4       #   \         P                  ! T 4       i ; ir   )rl   ZgetcwdchdirrI   )Zprev_cwdmethodparamsr    s    r"   dispatchZ2ScriptInterpreter._iter_commands.<locals>.dispatchG  sE    #%99;!1!12/#)&>HHX.BHHX.s   A A.zCommands %d out of %s completedzError during installation: %s)rN   r4   rT   rk   r   r(   rJ   r*   rQ   r   ZKeyErrorr   rU   _map_commandr   dictr   r,   r   rI   rl   rm   Zexistsr   r   _finish_install	Exceptionr   )r    Zresultr   Zcommandsr.   r   Zstatus_textr   r   r   r   s   f&&      @@r"   r   Z ScriptInterpreter._iter_commands+  s   Vt~~~)	:~~,,00bAHFG,,99)D%%H5g&t';';<G $$)$!%!2!27!;fd++"(**]D"AK"&K00>>{K4g>###t7G7G(H(H/ h(;(;<fd&9&96B>@T@TVYZbVcd$$&;   g(+[)\]cffg<  	:<bA((55b99	:sg   -H! 1H! H! G9 0AH! AH! .H! H! #H! <;H! 9HHHH! !I),2I$$I)c                s    \        V \        4      '       d*   \        V P                  4       4      ^ ,          pW,          pMT p/ pVP	                  RR4      pVP                  R4      pW3# )i    -rU   )r   r   ZlistZkeysreplaceZstrip)command_datar   r   rv   r"   r   Z.ScriptInterpreter._get_command_name_and_paramsZ  sd    lD)) 1 1 34Q7L)7N'LN#++C5#))#.++r$   c                s    V P                  V4      w  r#\        W4      '       g   \        \        R4      V,          4      h\	        W4      V3# )zCMap a directive from the `installer` section to an internal
method.z The command "%s" does not exist.)r   Zhasattrr   rU   Zgetattr)r    r   r   r   s   &&  r"   r   ZScriptInterpreter._map_commandg  sH     (,'H'H'V$t** #E!F!UVVt*N::r$   c                s(   V P                   P                  4       pR pV'       dv   \        V9  dk   \        P                  P                  V4      '       gF   V P                   P                  R8w  d+   \        R4      V,          p\        P                  ! RV4       M8V P                   P                  P                  R4      ;'       g    \        R4      p\        \        R V P                   P                  4       V P                  P!                  W4       R # )NZwebzThe executable at path %s can't be found, please check the destination folder.
Some parts of the installation process may have not completed successfully.z,No executable found at specified location %sZinstall_complete_textzInstallation completed!)r4   Zsaver
   rl   rm   Zisfilerj   rU   r   rd   rT   rk   r   r   ro   rJ   r=   )r    r<   rm   r+   rp   r"   r   Z!ScriptInterpreter._finish_installo  s    ..%%'O4/t8L8LQUQ_Q_QfQfjoQob 	  NNI4P^^**../FGgg1MfKgF't~~/G/GH$$44WEr$   c                s    \         P                  ! \         P                  P                  R4      4       \        P
                  ! V P                  4       R# )z/Clean up install dir after a successful installrh   N)rl   r   rm   rn   r   Zdelete_folderrq   rf   rg   r"   cleanupZScriptInterpreter.cleanup  s/    
##C()T__-r$   c                s"  a aaa \         P                  ! RS P                  P                  4       RS n        VVVV 3R lpS P                  P
                  P                  R4      '       d   \        S P                  VRR/4       R# V! RR4       R# )zRevert installation in case of an error. Since winekill can be slow,
this runs asynchronously and calls cocompletion_function() when successful,
or error_function(err) if it fails.zCancelling installation of %sTc                 s6  < V'       d   S! V4       R #  SP                   '       d   SP                  4        SP                  '       d)   S'       d!   \        P                  ! SP                  4       S! 4        R #   \         d   pS! T4        R p?R # R p?ii ; ir   )rO   rI   r   Zremove_folderr   )Z_resultr(   r   completion_functionerror_functionremove_game_dirr    s   && r"   on_completeZ-ScriptInterpreter.revert.<locals>.on_complete  sq    u%	#***++-###(()9)9:#% #r""#s(   A: !A: 	A: 'A: :BBBr   r   ZwinekillN)	r   r;   r4   Z	game_namerN   rj   Z
startswithr   r   )r    r   r   r   r   s   ffff r"   revertZScriptInterpreter.revert  sk     	3T^^5M5MN	# 	#  >>  ++F33diivz.BCd#r$   c                sR   V P                   pRV P                  RV P                  P                  RV P                  R\
        P                  P                  R4      R\        P                  ! 4       P                  RV P                  R\
        P                  ! R4      R	V P                  '       d   V P                  R,          R
,          MRRV P                  P                  RRP                  V4      RV^ ,          RV^,          /p \        \!        V^ ,          4      4      VR&   \        \!        V^,          4      4      VR&    V P'                  4       VR&   VP+                  4        UUu. uF  w  r4Ve   K  VNK  	  upp F  pW# K  	  VP-                  V P                  P.                  4       V P                   F!  pVR,          pV'       g   K  VR
,          W&&   K#  	  VP-                  V P0                  4       V#   \"        \$        3 d     Li ; i  \(         d     Li ; iu uppi )z3Return a mapping of variables to their actual valueZGAMEDIRZ	SCRIPTDIRZCACHEZHOMErh   ZSTEAM_DATA_DIRZDISCZUSERZINPUTru   ri   ZVERSIONZ
RESOLUTIONZxZRESOLUTION_WIDTHZRESOLUTION_HEIGHTZRESOLUTION_WIDTH_HEXZRESOLUTION_HEIGHT_HEXZWINEBINr9   i)rS   rI   r4   Z	scriptdirrq   rl   rm   rn   r   Zsteam_data_dirrL   ZgetenvrP   r   rW   ZhexZintZ
ValueErrorZ	TypeErrorget_wine_pathr   rr   ZupdateZ	variablesrM   )r    Zcurrent_resZreplacementsrt   ru   Z
input_datar9   s   &      r"   _get_string_replacementsZ*ScriptInterpreter._get_string_replacements  s    -- t''11T__BGG&&s+ekkm::DNNBIIf%d6F6F6FT%%b)'2Bt~~--#((;/AQ
	36s;q>7J3KL/047KN8K4LL01	&*&8&8&:L# +7*<*<*>P*>JC%CC*>PC! Q 	DNN445**Jw'Eu&0&9# + 	DOO,- I& 		
 % 		 Qs0   <G; H (H#5H#;HHH H c                s    Vf   \         P                  ! R4       R# \        V4      P                  RR4      V P                  9   d   VP                  RR4      p\
        P                  ! WP                  4       4      # )z%Replace path aliases with real paths.zNo template string givenri   r   rU   )r   rd   Zstrr   rM   r   Z
substituter   )r    Ztemplate_stringr)   r"   rs   ZScriptInterpreter._substitute  sb    "NN56''S1T__D-55c3?O  2O2O2QRRr$   c                sf    V P                  4       p\        P                  ! WP                  4       R# )zOUse Wine to eject a CD, otherwise Wine can have problems detecting disc changesN)r   r   Z
eject_discrI   )r    Z	wine_pathr}   r"   eject_wine_discZ!ScriptInterpreter.eject_wine_disc  s"    &&(		#3#34r$   )rO   rN   rQ   rS   rK   rL   rM   r4   rJ   r3   rR   r   rI   rP   r&   r   r>   )TNN)+r?   r@   rA   rB   rC   r   ZSIGNAL_RUN_FIRSTZ__gsignals__r	   rG   r#   r_   ra   rb   rc   Zpropertyr   r[   rq   rw   Zstaticmethodr~   rX   rY   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rs   r   rD   rE   Z__classcell__)r\   rF   s   @@r"   r   r      s    / 	g66bALG G@ 9D9999 , ,b [ [ 
 
 	 	f$;<."2'2"-:^ 
, 
,;F$.
$:-^S5 5r$   r   ).rC   rl   r    rU   Zgi.repositoryr   Zlutrisr   Zlutris.configr   Zlutris.database.gamesr   Zlutris.exceptionsr   r   r   Zlutris.gui.dialogs.delegatesr	   Zlutris.installerr
   Zlutris.installer.commandsr   Zlutris.installer.errorsr   r   Zlutris.installer.installerr   Zlutris.runnersr   r   r   r   Zlutris.services.lutrisr   Zlutris.utilr   Zlutris.util.displayr   Zlutris.util.jobsr   Zlutris.util.logr   Zlutris.util.stringsr   ZObjectr   r&   r$   r"   <module>r      s[    5 	   !  & 3 ^ ^ 1 , 3 N 6 Z Z 8  / & " 3D5 D5r$   