HEX
Server: Apache
System: Linux eisbus 6.8.12-9-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.12-9 (2025-03-16T19:18Z) x86_64
User: www-data (33)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //lib/tklbam/registry.pyc
�
+��dc@s7ddlZddlZddlTddlmZddlZddlmZddlZddl	m
Z
ddlZddlm
Z
mZddlZddd��YZd	efd
��YZd�Zdefd
��YZde
fd��YZe�adejjfd��YZded�Zd�ZdS(i����N(t*(tPaths(tdatetime(tAttrDict(tTurnKeyVersiontdetect_profile_idt	UNDEFINEDcBseZRS((t__name__t
__module__(((s/usr/lib/tklbam/registry.pyRst	_RegistrycBs�eZdefd��YZdefd��YZdZejjed�Z	dZ
dZdefd	��YZ
dd
�Zeed��Zeed��Zeed
��Zed�Zeee�Zed�Zeee�Zed�Zeee�Zed�Zeee�Zed�Zeee�Zed��Zed�Zeee�Zed�Zeee�Zdd�Zdd�Z RS(t
CachedProfilecBseZRS((RR(((s/usr/lib/tklbam/registry.pyR
"stProfileNotFoundcBseZdZRS(s�Without a profile TKLBAM can't auto-configure the backup process for your
system. Sorry about that! However even without a profile you can still:

- Restore existing backups
- Backup raw directories with the --raw-upload option

You can use the --force-profile option to fix or workaround a missing profile
in several ways:

- Use an empty profile with --force-profile=empty
- Use a custom profile with --force-profile=path/to/custom/profile/

    tklbam-internal create-profile --help

Also, if TKLBAM is linked to the Hub you can:

- Download a profile for another TurnKey system with --force-profile=codename (e.g., "core")
- Download the all-purpose generic profile with --force-profile=generic

Run "tklbam-init --help" for further details.
(RRt__doc__(((s/usr/lib/tklbam/registry.pyR%stTKLBAM_REGISTRYs/var/lib/tklbamtemptytcustomRcBs2eZdddddddddd	d
dgZRS(srestore.logs
backup.logs
backup.pids
backup-resumet
sub_apikeytsecrettkeytcredentialsthbrtprofiles
profile/stampsprofile/profile_id(RRtfiles(((s/usr/lib/tklbam/registry.pyRCs	cCsl|dkr*tjj|j|j�}nt|�sVtj|�tj|d�n|j	|�|_
dS(Ni�(tNonetostenvirontgettENV_VARNAMEtDEFAULT_PATHtexiststmakedirstchmodRtpath(tselfR ((s/usr/lib/tklbam/registry.pyt__init__Hs
cCs�|tkr2t|�sdSt|�j�j�S|dkr]t|�r�tj|�q�n3t|d�}tj|d�||IJ|j	�dS(Ntwi�(
RRRtfiletreadtrstripRtremoveRtclose(R tstfh((s/usr/lib/tklbam/registry.pyt	_file_strRs
cCsl|r=|tk	r=djg|D]}t|�^q�}n|j||�}|rht|jd��SdS(Ns
(RtjointstrR+ttupletsplit(tclsR tttvtretval((s/usr/lib/tklbam/registry.pyt_file_tupleds
+cCs�|rM|tk	rMdjg|j�D]\}}d||f^q%�}n|j||�}|r�tg|jd�D]}|jdd�^qx�SdS(Ns
s%s=%st=i(RR,titemsR+RR/(R0R tdtkR2R3((s/usr/lib/tklbam/registry.pyt
_file_dictms
;cCs|j|jj|�S(N(R+R R(R!tval((s/usr/lib/tklbam/registry.pyRvscCs|j|jj|�S(N(R+R R(R!R:((s/usr/lib/tklbam/registry.pyRzscCs|j|jj|�S(N(R+R R(R!R:((s/usr/lib/tklbam/registry.pyR~scCs2|j|jj|�}|r.tjj|�SdS(N(R9R RthubtCredentialst	from_dict(R!R:R3((s/usr/lib/tklbam/registry.pyR�scCs�d}|rQ|tk	rQti|jd6|jd6tj�j|�d6�}n|j|jj	|�}|r�d|kr�d|_ntj|j|�|_|SdS(Ns%Y-%m-%d %H:%M:%Staddresst	backup_idtupdated(
RRR>R?RtnowtstrftimeR9R RRR@tstrptime(R!R:tformatR3((s/usr/lib/tklbam/registry.pyR�s
cCs#tt|��}d|j|fS(Ns%s:%s(tbasenametabspathtCUSTOM_PROFILE(R0R tname((s/usr/lib/tklbam/registry.pyt_custom_profile_id�scCs�|dkr%tj|jjdt�S|tkr�t|jjj�sJdSt	t
j|jjj�j�}|j
|jjj�}|dkr�t�}nt|jj||�S|}d|_t
j|jj�||jkr|j
|jjj|�t|jjjd�j�n�tt|��r�d|_tj||jj�|j
|jjj|j|��t|jjjd�j�nm|j|jj�t|jjjd�j�t
j|jjjd|jf�|j
|jjj|j�dS(Nt
ignore_errorsR#i(RtshutiltrmtreeR RtTrueRRtstamptintRtstattst_mtimeR+t
profile_idRtProfileRt
EMPTY_PROFILER$R(tisdirR-tcopytreeRItextracttutimet	timestamp(R!R:RYRRtprofile_archive((s/usr/lib/tklbam/registry.pyR�s2!		""cCs�|dkr8t|jj�r4tj|jj�ndS|tkr�|j|jj�}|dkridSytt	j
|��SWq�dSXn%t	j|�}|j|jj|�dS(N(RRR t
backup_resumeRR'RR+tBackupSessionConft
simplejsontloadstdumps(R!R:R)((s/usr/lib/tklbam/registry.pytbackup_resume_conf�sc	Csc|s*|jr|jj}q*t�}n||jksEt|�rR||_dStj|j�}|jr�|jj|kr�|jj}nd}y7|j
||�}|r�||_d|jjGHnWn�tjk
r��n{|jk
r^}|j
\}}}|dkr&|j|��n|jsB|jj|krH�n|jd|��nXdS(s�Get a new profile if we don't have a profile in the registry or the Hub
        has a newer profile for this appliance. If we can't contact the Hub raise
        an error if we don't already have profile.NsDownloaded %s profilesBackupArchive.NotFounds-using cached profile because of a Hub error: (RRRRRTRUR;tBackupsRRYRtget_new_profilet
NotSubscribedtErrortargsRR
(	R!RRthub_backupstprofile_timestamptnew_profileteterrnoterrnametdesc((s/usr/lib/tklbam/registry.pyt_update_profile�s2			cCs�|dkrM|jrM|jjtjksF|jjjtjd�rMdSny|j|�Wn�|jk
r�}|r�t	j
d|�s�d|}ntj|�j
�s�t|�}|r�y|j|�dSWq�q�Xq�q�n|�nXdS(Nt:s	^turnkey-sturnkey-(RRRRtregistryRTt
startswithRGRmRtretmatchRtfrom_stringtis_completet_complete_profile_id(R!RRtfirst_exceptiontcompleted_profile_id((s/usr/lib/tklbam/registry.pytupdate_profiles(	


N(!RRt	ExceptionR
RRRRRRRTRGt_PathsRRR"tstaticmethodRR+tclassmethodR4R9RtpropertyRRRRRIRR`RmRx(((s/usr/lib/tklbam/registry.pyR	!s>
#)cCs�tj|�}tj�}|s%dS|jdkrC|j|_n|jdksg|jj|j�rv|j|_nt|�S(N(RRstfrom_systemtarchRtreleaseRpR-(tpartialtsystem((s/usr/lib/tklbam/registry.pyRus$RScBseZd�Zd�ZRS(cCstj||�S(N(R-t__new__(R0R RRRY((s/usr/lib/tklbam/registry.pyR�,scCs,tj|�||_||_||_dS(N(R-R"R RYRR(R!R RRRY((s/usr/lib/tklbam/registry.pyR"/s
		(RRR�R"(((s/usr/lib/tklbam/registry.pyRS+s	R\cBseZid�ZRS(cCs)tj||�tj|j�|_dS(N(RR"tconftLimitst	overrides(R!R7((s/usr/lib/tklbam/registry.pyR"6s(RRR"(((s/usr/lib/tklbam/registry.pyR\5stNotInitializedcBseZd�ZRS(cCsRd}tjtjkr4dtjtj|f}ntjjj|d|�dS(Nstklbam-inits%s=%s %ss!Hub link required, run "%s" first(RoR RRR;RaR�R"(R!tcommand((s/usr/lib/tklbam/registry.pyR"=s(RRR"(((s/usr/lib/tklbam/registry.pyR�<scCsJddl}|tjkr#dGHn|sHytj|�Wq3dSXn�ytj|�Wn�tjjk
r{t��n�tjk
r�}|jt	|�IJ|j
d�n�tjk
r�}|jdt	|�IJnWtjk
r2}|jdt	|�IJ|s"|jd|j
IJn|j
d�nXtjjtjd<dS(Ni����sA
Creating an empty profile, which means:

- We only backup files as included or excluded in the override paths specified
  on the command line or configured in /etc/tklbam/overrides

- We can't detect which files have changed since installation so we will
  indiscriminately backup all files in the included directories.
is	warning: sTurnKey Hub Error: %ss
tTKLBAM_PROFILE_ID(tsysRoRTRxR;RaR�RctstderrR-texitR
RRRRRRR(RRtstrictR�Ri((s/usr/lib/tklbam/registry.pyRxDs.	cCsIddl}ytjtj�}Wn tjjk
rDt��nX|S(Ni����(R�R;RaRoRR�(R�thb((s/usr/lib/tklbam/registry.pyRfns
((RRqtos.pathtpathsRRzR]RRKtutilsRR;tversionRRR�RtobjectR	RuR-RSR\RoRaR�RRMRxRf(((s/usr/lib/tklbam/registry.pyt<module>s&
�	
	*