Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/landscape/manager/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/landscape/manager/aptsources.pyc


Tc@sddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
defdYZdefd	YZdS(
iN(tsucceed(t
spawn_process(t
ManagerPlugin(tfind_reporter_commandtProcessErrorcBseZdZRS(s.Exception raised when running a process fails.(t__name__t
__module__t__doc__(((s@/usr/lib/python2.7/dist-packages/landscape/manager/aptsources.pyRst
AptSourcescBsheZdZdZdZdZdddZdZdZ	dZ
dZd	Zd
Z
RS(s'A plugin managing sources.list content.s/etc/apt/sources.lists/etc/apt/sources.list.dcCs-tt|j||jd|jdS(Nsapt-sources-replace(tsuperRtregistertregister_messaget_handle_repositories(tselftregistry((s@/usr/lib/python2.7/dist-packages/landscape/manager/aptsources.pyR
s	cCst||d|d|S(sW
        Run the process in an asynchronous fashion, to be overriden in tests.
        tuidtgid(R(R
tcommandtargsRR((s@/usr/lib/python2.7/dist-packages/landscape/manager/aptsources.pyt_run_processscCs2|\}}}|r.td||fndS(sQ
        Turn a failed process command (code != 0) to a C{ProcessError}.
        s%s
%sN(R(R
tresulttoutterrtcode((s@/usr/lib/python2.7/dist-packages/landscape/manager/aptsources.pyt_handle_process_error%scCsB|jts:|j\}}}td||fn|SdS(sG
        Turn a signaled process command to a C{ProcessError}.
        s%s
%sN(tcheckRtvalue(R
tfailureRRtsignal((s@/usr/lib/python2.7/dist-packages/landscape/manager/aptsources.pyt_handle_process_failure-scCstj||S(sd
        Remove the temporary file created for the process, and forward the
        result.
        (tostunlink(R
tpassthroughtpath((s@/usr/lib/python2.7/dist-packages/landscape/manager/aptsources.pyt_remove_and_continue7s
cstdx|dD]}tj\}}tj|t|d}|j||jj|fdjj	j
j|qWjj
jj|dj|fdS(sE
        Handle a list of repositories to set on the machine.

        The format is the following:

        {"sources": [
          {"name": "repository-name",
           "content":
              "deb http://archive.ubuntu.com/ubuntu/ maverick main
              "deb-src http://archive.ubuntu.com/ubuntu/ maverick main"}
          {"name": "repository-name-dev",
           "content":
              "deb http://archive.ubuntu.com/ubuntu/ maverick universe
              "deb-src http://archive.ubuntu.com/ubuntu/ maverick universe"}],
         "gpg-keys": ["-----BEGIN PGP PUBLIC KEY BLOCK-----
                      XXXX
                      -----END PGP PUBLIC KEY BLOCK-----",
                      "-----BEGIN PGP PUBLIC KEY BLOCK-----
                      YYY
                      -----END PGP PUBLIC KEY BLOCK-----"]}
        sgpg-keystwcsjdd|gS(Ns/usr/bin/apt-keytadd(R(tignoreR!(R
(s@/usr/lib/python2.7/dist-packages/landscape/manager/aptsources.pyt<lambda>]stsourcescsS(N(((tdeferred(s@/usr/lib/python2.7/dist-packages/landscape/manager/aptsources.pyR&csN(RtNonettempfiletmkstempRtclosetfiletwritetaddCallbackRtaddBothR"t
addErrbackRt_handle_sourcestcall_with_operation_result(R
tmessagetkeytfdR!tkey_file((R
R(s@/usr/lib/python2.7/dist-packages/landscape/manager/aptsources.pyR?s


cCstj\}}tj|t|d}xZt|jD]I}|j}|sf|jdrv|j|q>|jd|q>W|jtj	|j}t
j||jtj|j|j
tj|j|j|jx=tjtjj|jdD]}	t
j|	d|	qWxh|D]`}
tjj|jd|
d}	t|	d}|j|
d|jtj|	d	q3W|jjd
S(sHandle sources repositories.R#t#s#%ss*.lists%s.saveslandscape-%s.listtnametcontenticSsdS(N(R)(tignored((s@/usr/lib/python2.7/dist-packages/landscape/manager/aptsources.pyR&s(R*R+RR,R-tSOURCES_LISTtstript
startswithR.tstattshutiltmovetchmodtst_modetchowntst_uidtst_gidtglobR!tjointSOURCES_LIST_Dt
_run_reporterR/(R
R;R'R6R!tnew_sourcestlinet
stripped_linet
original_stattfilenametsourcetsources_file((s@/usr/lib/python2.7/dist-packages/landscape/manager/aptsources.pyR2es.

(

cCst}dg}|jjjdk	rD|jd|jjjntjdkr}tjdj	}t
jdj}nd}d}|j
||d|d|S(s;Once the repositories are modified, trigger a reporter run.s--force-apt-updates--config=%sit	landscapeRRN(RRtconfigR)tappendRtgetuidtpwdtgetpwnamtpw_uidtgrptgetgrnamtgr_gidR(R
treporterRRR((s@/usr/lib/python2.7/dist-packages/landscape/manager/aptsources.pyRJs		N(RRRR<RIR
R)RRRR"RR2RJ(((s@/usr/lib/python2.7/dist-packages/landscape/manager/aptsources.pyRs			
		&	(RGRRVRYR@R*ttwisted.internet.deferRtlandscape.lib.twisted_utilRtlandscape.manager.pluginRtlandscape.package.reporterRt	ExceptionRR(((s@/usr/lib/python2.7/dist-packages/landscape/manager/aptsources.pyt<module>s