MOON
Server: Apache
System: Linux server2.shieldcogroup.com 3.10.0-1160.119.1.el7.tuxcare.els12.x86_64 #1 SMP Fri Nov 8 05:49:38 UTC 2024 x86_64
User: jacom (1029)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.pyc
�
��ic@s�ddlZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZddlmZddlmZmZmZdd	lmZdd
lmZmZd�Zd�Zd
�Zdd�Zd�Z dd�Z!d�Z"d�Z#d�Z$d�Z%e&d�Z'd�Z(d�Z)d�Z*dd�Z+dS(i����N(tdatetime(t
command_utils(t
get_config(tCommandError(tfind_and_scan_repositories(taudit(tget_checkpointstget_connectiontget_messages(treport_unsupported(tfetch_upgrade_report_messagestgenerate_report_filecCs7d�}tjjdd�s3|tj�t_ndS(Ncs"tj���fd��}|S(Ncsatjjdd�}zdtjd<�||�SWdtjjd�|r\|tjd<nXdS(NtLEAPP_DEVEL_DATABASE_SYNC_OFFt1(tostenvirontgettNonetpop(targstkwargstsaved(tf(sC/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.pytwrappers
(t	functoolstwraps(RR((RsC/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.pytdisable_db_sync_decorators
tLEAPP_DATABASE_FORCE_SYNC_ON(RRRRRtcreate_connection(R((sC/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.pytdisable_database_syncs	
cCsytd
|�}tj|p!igdjdi�jdd��jdi�}x#|D]}|dtj|d<qVWd	S(sL
    Restores leapp environment variables from the `IPUConfig` message.
    t	IPUConfigitmessagetdatas{}tleapp_env_varstvaluetnameN(R(RtjsontloadsRRR(tcontexttmessagesR!tentry((sC/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.pytrestore_leapp_env_vars&s@
c
Cs9t�}tjj|jdd��sCtj|jdd��ng|jdd�jd�D]T}tjjtjj|jdd�|��r_tjj|jdd�|�^q_}tjj|jdd��s�tj|jdd��n|r5tjj|jdd��r3|j	|jdd��nt
j�jd�}tjj|jdd�dj
|��}tj|d	���}xh|D]`}|j|�tjj|�r�tj|d
t�nytj|�Wq�tk
r�q�Xq�Wtjj|jdd��r,|j|jdd��nWd
QXnd
S(s0 Archive log files from a previous run of Leapp tfiles_to_archivetdirtfilest,tarchivetdebugs%Y%m%d%H%M%Ssleapp-{}-logs.tar.gzsw:gzt
ignore_errorstdatabasetpathN(RRR2tisdirRtmakedirstsplittisfiletjointappendRtnowtstrftimetformatttarfiletopentaddtshutiltrmtreetTruetremovetOSError(tcfgRR*R9tarchive_filettartfile_to_add((sC/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.pytarchive_logfiles0s0	T*


cCs=t�jd|�r-t�jd|�}nt|d|�S(Ntrepositoriestmanager(Rt
has_optionRR(R#t	repo_pathRJ((sC/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.pytload_repositories_fromSscCs#tdddd�}|j�|S(NRLs/etc/leapp/repo.d/RJ(RMRtload(RJ((sC/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.pytload_repositoriesYs
cCsytd��a}|r-|jd|f�}n|jd�}|j�}|ri|dtj|d�fSWdQXdifS(s0
    :return: Context of the last execution
    sESELECT context, stamp, configuration FROM execution WHERE context = ?scSELECT context, stamp, configuration FROM execution WHERE kind = 'upgrade' ORDER BY id DESC LIMIT 1iiN(RRtexecutetfetchoneR$R%(tuse_contexttdbtcursortrow((sC/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.pytfetch_last_upgrade_context_s	!cCs>td��,}|jd�}|j�}|r4|SWdQXdS(s1
    :return: All upgrade execution contexts
    s[SELECT context, stamp, configuration FROM execution WHERE kind = 'upgrade' ORDER BY id DESCN(RRRPtfetchall(RSRTRU((sC/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.pytfetch_all_upgrade_contextsps	
cCs%td|�}|r!|ddSdS(NR&i����tphase(RR(R&tcheckpoints((sC/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.pytget_last_phase}scCs.tj|d�dkp-|j|d�dkS(sg
    Checks whether the given environment variable or the given configuration value are set to '1'
    t0R
(RtgetenvR(tenv_vartconf_vart
configuration((sC/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.pytcheck_env_and_conf�scCs�t�}gddgD]0}tjj|jdd�dj|��^q\}}t|�}t||||�t||||�dS(sQ
    Generates all report files for specific leapp run (txt and json format)
    ttxtR$treportR+sleapp-report.{}N(RRR2R7RR;R
R(R&t
report_schemaRDRt
report_txttreport_jsonR'((sC/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.pytgenerate_report_files�s	FcCs�g}xs|j|d�jd�D]V}tjj|j|d�|�}|sh|r"tjj|�r"|j|�q"q"W|S(s6
    Provide files from particular config section
    R,R-R+(RR5RR2R7R6R8(tsectionRDt
must_existR,tfile_t	file_path((sC/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.pyt
get_cfg_files�s"!csOtj��jdd�dkrK�fd��D�}t||d�ndS(NtLEAPP_UNSUPPORTEDR\R
cs,i|]"}|jd�r�||�qS(tLEAPP_DEVEL_(t
startswith(t.0tk(tenv(sC/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.pys
<dictcomp>�s	twhitelist_experimental(RRRR	(R`t
devel_vars((RrsC/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.pytwarn_if_unsupported�s	cCsq|jrdntjdd�tjd<tjddksD|jrTdtjd<ntjdd�tjd<dS(sE
    Set environment variables following command line arguments.
    R
tLEAPP_DEBUGR\t
LEAPP_VERBOSEN(R/RR]Rtverbose(R((sC/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.pythandle_output_level�s(cCs�|jrPttjg|jD]}|jd�^q��|_dtjd<n
dtjd<tjdd�dkr{dndtjd<|jr�dtjd<nStj	j
d�s�dtjd<n1tjd�dkr�tjdd�tjd<n|jr
dtjd	<n|jr2dj
|j�tjd
<ntjjdd�dksV|jrfdtjd<n|jr�|jtjd<ndtjkr�d
tjd<n|jr�|jtjd<ntjjd�}|r�tj	j|�tjd<n|jr
dtjd<ntj|�\}}|tjd<|tjd<tjd�}djdtj|�dtj|��tjd<itjdd�d6tjdd�d6|jp�dd6d�tjD�d6tjd6}|S( sQReturns a configuration dict object while setting a few env vars as a side-effectR-R
tLEAPP_EXPERIMENTALR\Rmt
LEAPP_NO_RHSMs/usr/sbin/subscription-managertLEAPP_DEVEL_SKIP_RHSMtLEAPP_NO_INSIGHTS_REGISTERtLEAPP_ENABLE_REPOStLEAPP_NO_RHSM_FACTStLEAPP_TARGET_PRODUCT_CHANNELtgatLEAPP_TARGET_ISOtLEAPP_NOGPGCHECKt!LEAPP_UPGRADE_PATH_TARGET_RELEASEtLEAPP_UPGRADE_PATH_FLAVOURs/etc/os-releases{source}to{target}tsourcettargettLEAPP_IPU_IN_PROGRESSRvR/RwRxRscSs1i|]'}|jd�rtj|�|�qS(tLEAPP_(RoRR](RpRr((sC/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.pys
<dictcomp>�s	tenvironmenttcmd((Rstlistt	itertoolstchainR5RRR]tno_rhsmR2texiststno_insights_registert
enablerepoR7Rt
no_rhsm_factstchanneltisotabspatht
nogpgcheckRtvet_upgrade_pathtget_os_release_version_idR;tget_major_versiontsystargv(Rtittarget_iso_pathttarget_versiontflavortcurrent_versionR`((sC/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.pytprepare_configuration�sT	7
+			$			

	
cCswxp|jdd�D]\}|j|�}|r>|j|�qdj|�}|rc|j|�nt|��qWdS(NRssNo such Actor: {}((Rtlookup_actortwhitelist_experimental_actorR;terrorR(RItworkflowR`tloggert
actor_nametactortmsg((sC/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.pytprocess_whitelist_experimental�s(,RR�R$RR?R�R<Rtleapp.cli.commandsRtleapp.cli.commands.configRtleapp.exceptionsRtleapp.repository.scanRtleapp.utilsRtleapp.utils.auditRRRtleapp.utils.outputR	tleapp.utils.reportR
RRR)RHRRMRORVRXR[RaRgRARlRuRyR�R�(((sC/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.pyt<module>s<		
	#		
			
			<