a "ežã@sÄddlZddlZddlmZddlmZddlmZddlm Z ddl m Z ddl m Z ddlmZdd lmZdd lmZdd lmZdd lmZzeZWney®Yn0Gd d„deƒZdS)éN)Ú HooksObserver)Ú DefaultView)ÚInteractiveView)ÚNoteForHiddenView)Ú_)ÚTracer)ÚSystem)Ú dump_memory)Ú Applications)ÚRules)ÚHelperControllerc@sXeZdZdZdZdZdd„Zdd„Zdd„Zdd „Z d d „Z d d „Z dd„Z dd„Z dS)ÚDefaultControllerNcCs†||_ttj|jdttttƒ|jd|_ |j |j _ |j d|j _ |rN||j _ |j   | |j¡¡|_|jjr‚|j tjdg¡|_dS)N)Úerased)ZmemoryZhooks_observerrrÚDAEMON)ÚargsrrZpackage_managerrr r r rÚtracerZnowZ timestampZspecified_packagesZtrace_affectedÚ_userÚuserÚ applicationsZ daemons_onlyZ filter_typesÚTYPES)ÚselfrZpackages©rú>/usr/lib/python3.9/site-packages/tracer/controllers/default.pyÚ__init__/s  ú zDefaultController.__init__cCsJ|jjs:tƒ}| d|j¡| d|j¡| ¡| ¡t| ¡ƒdS)Nrr) rZ hooks_onlyrÚassignrÚrenderÚcreate_reboot_required_fileÚexitÚ status_code)rÚviewrrrrBszDefaultController.rendercCsœt|jƒ}| |j|j¡D]}| ||j¡tdƒqtƒ}| d|j¡| dt|jƒ¡| d|j  t j d¡¡| d|j  t j d¡¡|  ¡dS)NÚrÚ total_countÚ session_countÚSESSIONÚ static_countÚSTATIC) r rÚ_restartable_applicationsrÚ print_helperÚprintrrÚlenÚ count_typer rr)rÚhelper_controllerZ applicationrrrrÚrender_helpersKs  z DefaultController.render_helpersc Cs`t|jƒ}| |j|j¡ d¡}tƒ}| d|¡| d|j¡| dt|jƒ¡| d|j t j d¡¡| d|j t j d¡¡|  ¡|  d¡|  d¡|  d¡kr°q\t d td ƒƒtd ƒ}zL|d krØWdSt|ƒd ksôt|ƒt|ƒkrøt‚| |t|ƒd|j¡Wn&tttfy:t tdƒƒYn0tj dtdƒd¡tƒq dS)NÚnamerrr!r"r#r$r%Ú z0Press application number for help or 'q' to quitz--> ÚqrézWrong application numberz -- z)Press to get list of applicationsz --)r rr&rÚsortedrrr)r*r rrÚgetr(rÚinputÚintÚ IndexErrorr'Ú SyntaxErrorÚ ValueErrorÚsysÚstdoutÚwrite)rr+ZfilteredrZanswerrrrÚrender_interactiveXs*   z$DefaultController.render_interactivecCs\d}t|jƒdkrd}|j tjd¡r,d}|j tjd¡rBd}|j tjd¡rXd}|S) z¦ 0 - No affected applications 101 - Found some affected applications 102 - Found some affected daemons 103 - Session restart needed 104 - Reboot needed réeréfr#égr%éh)r)rr*r r)rÚcoderrrrvszDefaultController.status_codecCsJ|j tjd¡rFtddƒ}| d¡Wdƒn1s<0YdS)zm If a reboot is needed, create a /run/reboot-required file. This is how Debian/Ubuntu distros does it. r%z/run/reboot-requiredÚwzTracer says reboot is required N)rr*r rÚopenr:)rÚfprrrrŒs z-DefaultController.create_reboot_required_filecCs$|js | tjdtjdg¡S|S)Nr%r#)ÚallZ exclude_typesr r)rrrrrrr&•sýþýz+DefaultController._restartable_applicationscCs:|dgks|dkrdS|dkr"|S|s.t ¡S|dSdS)NÚ*Úrootr)rr)rrrrrr›s  zDefaultController._user)Ú__name__Ú __module__Ú __qualname__rrZ processesrrr,r;rrr&rrrrrr )s   r )Úosr8Z tracer.hooksrZtracer.views.defaultrZtracer.views.interactiverZtracer.views.note_for_hiddenrZtracer.resources.langrZtracer.resources.tracerrZtracer.resources.systemrZtracer.resources.memoryr Ztracer.resources.applicationsr Ztracer.resources.rulesr Ztracer.controllers.helperr Z raw_inputr3Ú NameErrorÚobjectr rrrrÚs"