ó JĄVc@sÓddlZddlZddlmZmZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZddlZddlZddlmZddlTddlTddlmZmZddlmZejdejjejjƒZ e j!d ƒd „Z"d „Z#d „Z$dd „Z&d„Z'd„Z(d„Z)d„Z*d„Z+d„Z,dS(i˙˙˙˙N(tPopentPIPEi(t html_entities(t*(tutilsttui(tloggerttinfocCstjƒdkS(Ni(tostgeteuid(((s]/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/services.pytrunning_as_root<scCs4tjjdƒrdStjjdƒr,dSdSdS(Ns/etc/init.d/cupss/etc/init.d/cups restarts/etc/init.d/cupsyss/etc/init.d/cupsys restartskillall -HUP cupsd(R tpathtexists(((s]/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/services.pyt restart_cups?s cCsxt}tjdƒ}|rt|rtdtjj|dƒ}|jƒ|}tj||dƒ\}}|dk}n|S(Ntshutdowns %s -r nows%Need authentication to restart systemi(tFalseRtwhichR R tjoint getAuthCmdtrun(t passwordObjtokRtcmdtstatustoutput((s]/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/services.pytrestartIs cCsĚ|jdƒ}tj|ƒ|rČ|rČd}x—|D]Œ}|jƒ|}tj||d|ƒ\}}|dkr—tjd|ƒtj|ƒn|dk rˇ||d|ƒn|d7}q5WndS(Ntopen_mdns_portis*Need authentication to open mdns port [%s]isAn error occurred running '%s'sOpen mDNS/Bonjour step %d(tget_distro_ver_datatlogtdebugRRRtwarntNone(tcoreRtcallbacktopen_mdns_port_cmdtxRRR((s]/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/services.pytrun_open_mdns_portUs     cCsn|dk rYtj|tƒ}|s-|}ntj|ƒtj|ƒ\}}|dkStjdƒtSdS(NisCommand not found( R RRtTrueRRRterrorR(Rt hpCommandRR((s]/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/services.pyt run_hp_toolshs     cCs”|dk r|dk rtj|tƒ}|s9|}n|jƒ|}tj|ƒtj||d|ƒ\}}|dkStjdƒt SdS(Ns%Need authentication to run %s commandis1Command not found or password object is not valid( R RRR&RRRRR'R(RRR(RR((s]/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/services.pytrun_hp_tools_with_authws    cCs’t}| s| r|Stjdƒr |jƒd|}tj|ƒtj||d|ƒ\}}|dkrđd|ks‹d|krç|jƒd|}tjd|ƒtj||d |ƒ\}}|dkrít}qíqt}qŽtjd ||fƒn„tjd ƒr|jƒd |}tj|ƒtj||d|ƒ\}}|dkrd|ks}d|krŮ|jƒd |}tjd|ƒtj||d |ƒ\}}|dkr˙t}q˙qd|krůtjd|ƒqt}qŽtjd ||fƒnrt j j d|ƒr|jƒd|}tj|ƒtj||d|ƒ\}}|dkrűd|ks–d|krň|jƒd|}tjd|ƒtj||d |ƒ\}}|dkrřt}qřqt}qŽtjd ||fƒny|dkrwd}tj||d|ƒ\}}|dkrgd|krgt}qŽtjdƒntjd ||fƒ|S(Nt systemctlssystemctl status %s.services,Need authentication to get %s service statusitstoptinactivessystemctl start %s.services cmd_start=%ss/Need authentication to start/restart %s services;Fail to start %s service, please start %s service manually.tservicesservice %s statussservice %s startsunrecognized services0Failed to Start since %s is unrecognized services/etc/init.d/%ss/etc/init.d/%s statuss/etc/init.d/%s starttcupss lpstat -rs is runnings>service command not found, please start cups service manually.( RRRRRRRR&R'R R R (t service_nameRtret_Valt cmd_statustststoutt cmd_startR((s]/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/services.pyt start_servicesh                  cCs˛tjdƒ}|r-tjj|dƒ}ntjjtjdƒ}tjj|ƒsgtj dƒntj d|ƒtj tj |dddƒtj dƒt jdƒdS( Ns hp-systrays systray.pysUnable to start hp-systrays&Running hp-systray: %s --force-startups--force-startups--ignore-update-firsttimes"Waiting for hp-systray to start...i(RRR R Rtpropthome_dirR RRRtspawnlptP_NOWAITttimetsleep(R ((s]/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/services.pyt run_systrayÓs cCsŰtjdtƒ}|rZd}d||f}t|ƒrJtjdƒq×tjdƒn}y\ddlm}t }t }|j |t k|ƒ\}}| sĽ| rľtjdƒnWnt k rÖtj d ƒnXdS( Ns hp-SIDisablet-s%s %ssSmart Install is disabled s$Smart Install could not be disabled i(tpkitsFailed to install plug-in.s Import error (RRR&R)RRR'RR?tPLUGIN_REQUIREDtPLUGIN_REASON_NONEtrun_plugin_commandt ImportErrorR(R tparamtsicmdR?tplugint plugin_reasonRtsudo_ok((s]/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/services.pytdisable_SmartInstallâs   c Csetjdƒ\}}|tkr/tjdddgdƒ\}}| sU|dkrftjdƒtSyddlm }m }Wnt k r tj dƒq/Xytd d t tjd d d g}|jd d d ƒ}|jdd|Œtjdƒ|ƒj|ƒtjdƒWq/tj dƒq/Xntjdƒ\}}|tkratj dƒtStS(Ns hp-systraysq Some HPLIP applications are running. Press 'y' to close applications or press 'n' to quit upgrade(y=yes*, n=no):tytns;Manually close HPLIP applications and run hp-upgrade again.i˙˙˙˙(t SystemBustlowlevelsUnable to load DBus.Rit/scom.hplip.StatusServicetEventt signaturetssisisss'Sending close message to hp-systray ...gŕ?s5Failed to send DBus message to hp-systray/hp-toolbox.s hp-toolboxsVFailed to close either HP-Toolbox/HP-Systray. Manually close and run hp-upgrade again.(RtIs_Process_RunningR&Rt enter_choiceRRRtdbusRLRMRCR'tEVENT_SYSTEMTRAY_EXITR7tusernamet SignalMessagetappendRt send_messageR;R<( RRRtchoiceRLRMtargstmsgttoolbox_status((s]/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/services.pytclose_running_hp_processes÷s4 !       (-tsysR t subprocessRRtgrptfnmatchttempfiletsockettstructtselectR;tfcntlterrnotstattstringtglobtiotretgetpasstlocalet sixext.movesRtgtcodesRRRRtLoggertLOG_LEVEL_INFOtLOG_TO_CONSOLERt set_levelR RRR R%R)R*R6R=RIR^(((s]/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/services.pytsH                     !      D