o U7e@@sddlmZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z dZdZdZe dd d d ZGd d d ejZGdddejje ZdS))GLibN) SourceEntry) DBusGMainLoop)SoftwarePropertieszcom.ubuntu.SoftwareProperties/T)set_as_defaultcCstjdkr |dS|S)N3zutf-8)sysversionencode)stringr P/usr/lib/python3/dist-packages/softwareproperties/dbus/SoftwarePropertiesDBus.py _to_unicode(s  rc@seZdZdZdS)PermissionDeniedByPolicyz6com.ubuntu.SoftwareProperties.PermissionDeniedByPolicyN)__name__ __module__ __qualname___dbus_error_namer r r rr.srcseZdZdNddZfddZfddZejje d d d d Z ejje d d d dZ ejje d d ddZ ejje d d ddZ ejje d d ddZejje ddd d ddOddZejje ddd d ddOddZejje dddd ddOddZejje dddd ddOdd Zejje dddd ddOd!d"Zejje dddd ddOd#d$Zejje ddd d ddOd%d&Zejje ddd d ddOd'd(Zejje dddd ddOd)d*Zejje ddd+d,ddOd-d.Zejje ddd d ddOd/d0Zejje ddd d ddOd1d2Zd3d4Zd5d6Zejje ddd,d ddOd7d8Zejje ddd9d ddOd:d;Zejje ddd9d ddOdd?Z!ejje dddd ddOd@dAZ"ejje dddd ddOdBdCZ#ejje dddd,ddOdDdEZ$ejje dddd,ddOdFdGZ%ejje dddd,ddOdHdIZ&ejje ddd d,ddOdJdKZ'dLdMZ(Z)S)PSoftwarePropertiesDBusNrcCsTtj||||dd|_d|_tjjt|d}tjj||t d|_ t ddS)N)optionsdatadirrootdir)busTzwaiting for connections) r__init__ dbus_infopolkitdbusserviceBusNameDBUS_INTERFACE_NAMEObject DBUS_PATHenforce_polkitloggingdebug)selfrrrrbus_namer r rr3szSoftwarePropertiesDBus.__init__ctt||dSN)superrsave_sourceslistSourcesListModifiedr& __class__r rr+A z'SoftwarePropertiesDBus.save_sourceslistcr(r))r*r write_configConfigModifiedr-r.r rr1Dr0z#SoftwarePropertiesDBus.write_config)dbus_interface signaturecCtddS)0 emit signal when the sources.list got modified zSourcesListModified signalNr$r%r-r r rr,Iz*SoftwarePropertiesDBus.SourcesListModifiedcCr6)r7zConfigModified signalNr8r-r r rr2Nr9z%SoftwarePropertiesDBus.ConfigModifiedcCr6)z, emit signal when the apt keys got modified zKeysModified signalNr8r-r r r KeysModifiedSr9z#SoftwarePropertiesDBus.KeysModifiedcCr6)z6 emit signal when the policykit authentication failed z Auth signalNr8r-r r r AuthFailedXr9z!SoftwarePropertiesDBus.AuthFailedcCr6)z( emit signal when adding a cdrom failed zCdrom scan failed signalNr8r-r r rCdromScanFailed]r9z&SoftwarePropertiesDBus.CdromScanFailedsenderconn)sender_keywordconnection_keyword in_signature out_signaturecC|||d|dSNz*com.ubuntu.softwareproperties.applychanges)_check_policykit_privilegerevertr&r=r>r r rRevertd zSoftwarePropertiesDBus.RevertcCs |dSr))reload_sourceslistrGr r rReloadls zSoftwarePropertiesDBus.ReloadscC |||d|t|dSrD)rEenable_child_sourcerr&templater=r>r r rEnableChildSourcesz(SoftwarePropertiesDBus.EnableChildSourcecCrMrD)rEdisable_child_sourcerrOr r rDisableChildSource{rRz)SoftwarePropertiesDBus.DisableChildSourcecCrMrD)rEenable_componentrr& componentr=r>r r rEnableComponentrRz&SoftwarePropertiesDBus.EnableComponentcCrMrD)rEdisable_componentrrVr r rDisableComponentrRz'SoftwarePropertiesDBus.DisableComponentcCrCrD)rEenable_source_code_sourcesrGr r rEnableSourceCodeSourcesrIz.SoftwarePropertiesDBus.EnableSourceCodeSourcescCs"|||d||dSrD)rEdisable_source_code_sourcesr+rGr r rDisableSourceCodeSourcess  z/SoftwarePropertiesDBus.DisableSourceCodeSourcescCrMrD)rEtoggle_source_userr&sourcer=r>r r rToggleSourceUserRz&SoftwarePropertiesDBus.ToggleSourceUsessbcCs"|||d|t|t|SrD)rEreplace_source_entryr)r&oldnewr=r>r r rReplaceSourceEntrys  z)SoftwarePropertiesDBus.ReplaceSourceEntrycCrMrD)rEchange_main_download_serverr)r&serverr=r>r r rChangeMainDownloadServerrRz/SoftwarePropertiesDBus.ChangeMainDownloadServercCrCrD)rE_add_cdrom_sourcerGr r rAddCdromSourcerIz%SoftwarePropertiesDBus.AddCdromSourcec CsJt}dddddddddddd|jg }t|}td |j||d S) z add a (already inserted) cdrom z apt-cdromaddz-ozDebug::aptcdrom=1zDebug::identcdrom=1zacquire::cdrom::AutoDetect=1zacquire::cdrom::NoMount=1zDir::Etc::sourcelist=%siN)tempfileNamedTemporaryFilename subprocessPopenr timeout_add_wait_for_cdrom_scan_finish)r&tmpcmdpr r rrls  z(SoftwarePropertiesDBus._add_cdrom_sourcecCsl|durdS|}|dkr|dSd}t|jD]}|}q|dkr4|jjdt||dS)z= glib timeout helper to wait for the cdrom scanner to finish NTrFr3) pollr<openrq sourceslistlistinsertrset_modified_sourceslist)r&rxrvreslinexr r rrus z2SoftwarePropertiesDBus._wait_for_cdrom_scan_finishcC|||d||dSrD)rEset_popcon_pariticipation)r& participatesr=r>r r rSetPopconPariticipationz.SoftwarePropertiesDBus.SetPopconPariticipationicCrrD)rEset_update_automation_levelr&stater=r>r r rSetUpdateAutomationLevelrz/SoftwarePropertiesDBus.SetUpdateAutomationLevelcCrrD)rEset_release_upgrades_policyrr r rSetReleaseUpgradesPolicyrz/SoftwarePropertiesDBus.SetReleaseUpgradesPolicycCrMrD)rEset_update_intervalint)r&daysr=r>r r rSetUpdateIntervalrRz(SoftwarePropertiesDBus.SetUpdateIntervalcCs(|||d|t||dSrD)rEadd_source_from_linerr:)r& sourceLiner=r>r r rAddSourceFromLine s  z(SoftwarePropertiesDBus.AddSourceFromLinecCrMrD)rE remove_sourcerr`r r r RemoveSourcerRz#SoftwarePropertiesDBus.RemoveSourcecC(|||d||}|r||SrD)rEadd_keyr:)r&pathr=r>rr r rAddKey  zSoftwarePropertiesDBus.AddKeycCrrD)rEadd_key_from_datar:)r&keyDatar=r>rr r rAddKeyFromData+rz%SoftwarePropertiesDBus.AddKeyFromDatacCrrD)rE remove_keyr:)r&keyidr=r>rr r r RemoveKey6rz SoftwarePropertiesDBus.RemoveKeycCs&|||d|}|r||SrD)rE update_keysr:)r&r=r>rr r r UpdateKeysAsz!SoftwarePropertiesDBus.UpdateKeysc Cs,|dur |dur dS|jsdS|jdur t|dddd|_|j|}|jdur9ttdddd|_z|jjdd tj |d d if|d d it d d d d\}}}Wn#tj y{}z|j dkrvd|_| |||WYd}~Sd}~ww|std||||t|f|t|dS)aVerify that sender has a given PolicyKit privilege. sender is the sender's (private) D-BUS name, such as ":1:42" (sender_keyword in @dbus.service.methods). conn is the dbus.Connection object (connection_keyword in @dbus.service.methods). privilege is the PolicyKit privilege string. This method returns if the caller is privileged, and otherwise throws a PermissionDeniedByPolicy exception. Nzorg.freedesktop.DBusz/org/freedesktop/DBus/BusFzorg.freedesktop.PolicyKit1z%/org/freedesktop/PolicyKit1/Authorityz$org.freedesktop.PolicyKit1.Authorityzsystem-bus-namerq) variant_levelr3iX)timeoutz)org.freedesktop.DBus.Error.ServiceUnknownzW_check_polkit_privilege: sender %s on connection %s pid %i is not authorized for %s: %s)r#rr Interface get_objectGetConnectionUnixProcessIDr SystemBusCheckAuthorizationStringUInt32 DBusExceptionr_check_polkit_privileger$r%strr;r) r&r=r> privilegepidis_auth_detailser r rrEMsJ       z1SoftwarePropertiesDBus._check_policykit_privilege)NNr)NN)*rrrrr+r1rrsignalr r,r2r:r;r<methodrHrKrQrTrXrZr\r^rbrhrkrmrlrurrrrrrrrrrrE __classcell__r r r.rr1s                               r) gi.repositoryr dbus.servicerr$rrror aptsources.sourceslistrdbus.mainloop.glibr%softwareproperties.SoftwarePropertiesr DBUS_BUS_NAMEr"r rrrrr!rr r r rs