î Í+eTÄã @s ddlmZmZddlmZmZddlmZddlmZm Z m Z ddl m Z ddl m Z ddlmZy$dd lmZdd lmZWn(ek rÖdd lmZmZYnXdd lZdd lZGd d„de ƒZd S)é)Úabsolute_importÚprint_function)ÚGtkÚGdké)ÚReleaseNotesViewer)ÚerrorÚ inhibit_sleepÚ allow_sleep)ÚDistUpgradeFetcherCore)ÚSimpleGtkbuilderApp)Úgettext)Úurlopen)Ú HTTPError)rrNc@sXeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd S)ÚDistUpgradeFetcherGtkcCsJtj|||ƒtjj|ddƒ}t|dƒ|_||_dS)NZ gtkbuilderzReleaseNotes.uizubuntu-release-upgrader)r Ú__init__ÚosÚpathÚjoinr ÚwidgetsÚ window_main)ÚselfÚnew_distZprogressÚparentZdatadirZuifile©rú@/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeFetcher.pyr+szDistUpgradeFetcherGtk.__init__cCst|j||ƒS)N)rr)rZsummaryÚmessagerrrr1szDistUpgradeFetcherGtk.errorcCsptƒtjƒdkrEtjddddd|jg|jƒn tj|j|jg|jƒtƒdS)Nrz /usr/bin/gksuZgksuz --desktopz./usr/share/applications/update-manager.desktopz--)r rÚgetuidÚexecvZscriptZ run_optionsr )rrrrÚrunDistUpgrader4s  z%DistUpgradeFetcherGtk.runDistUpgradercCs*|jƒ}|dk r|S|jƒSdS)N)Ú_try_show_release_notes_webkitÚ _try_show_release_notes_textview)rÚresrrrÚshowReleaseNotesDs  z&DistUpgradeFetcherGtk.showReleaseNotesc Cs­|jjdk r©yddlm}||jjƒ}|jƒ|jjj|ƒ|jjjƒ}|jjj ƒ|t j j krŒdSdSWq©t k r¥Yq©XndS)Nr)ÚReleaseNotesViewerWebkitTF)rZreleaseNotesHtmlUrir$ÚshowrÚscrolled_notesÚaddÚdialog_release_notesÚrunÚhiderÚ ResponseTypeÚOKÚ ImportError)rr$Zwebkit_release_notesr"rrrr Ns  z4DistUpgradeFetcherGtk._try_show_release_notes_webkitc CsÌ|jjdk rÈ|j|jjƒ}|jrk|jjdƒ|jjƒjtjj tj j ƒƒnxt j ƒr‡t jƒqnWt jj}tjƒ}yœtjdƒt|ƒ}|jƒjddƒ}t|ƒ}|jƒ|jjj|ƒ|jj}|j|jƒ|jjjƒ}|jjjƒWn1t k r×dt!dƒ}t!dƒ} t j"|jt j#j$t j%j&t j'j(dƒ} | j)dƒ| j*|ƒ| j+| ƒ| jƒ| j,ƒYn™t-k rodt!d ƒ}t!d ƒ} t j"|jt j#j$t j%j&t j'j(dƒ} | j)dƒ| j*|ƒ| j+| ƒ| jƒ| j,ƒYnXtj|ƒ|jr¯|jjd ƒ|jjƒjdƒn|t jj.krÈd SndS) NFézUTF-8Úreplacez+%sz Could not find the release noteszThe server may be overloaded. Úz$Could not download the release notesz&Please check your internet connection.T)/rZreleaseNotesURIZ _expandUrirZ set_sensitiveZ get_windowZ set_cursorrZCursorÚnewZ CursorTypeZWATCHrZevents_pendingZmain_iterationr+ZCANCELÚsocketZgetdefaulttimeoutZsetdefaulttimeoutrÚreadÚdecoderr%rr&r'r(Zset_transient_forr)r*rÚ_Z MessageDialogZ DialogFlagsZMODALZ MessageTypeZERRORZ ButtonsTypeZCLOSEZ set_titleZ set_markupZformat_secondary_textZdestroyÚIOErrorr,) rZurir"ZtimeoutZ release_notesZnotesZtextview_release_notesZrelease_widgetZprimaryZ secondaryZdialogrrrr!_sl                              z6DistUpgradeFetcherGtk._try_show_release_notes_textviewN) Ú__name__Ú __module__Ú __qualname__rrrr#r r!rrrrr)s     r)Z __future__rrZ gi.repositoryrrrZutilsrr r r ZSimpleGtk3builderAppr r r5Zurllib.requestrZ urllib.errorrr-Zurllib2rr2rrrrrÚs