Ë
    õIfl†  ã                   óà  — d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlmZ ddlmZ  ej                  ej                   d«        ej"                  ej$                  ej&                  «        ej(                  ej$                  «       ej                  Zdadad„ Zd„ Zd	„ Zd
„ Zd„ Zd„ Z G d„ d«      Z G d„ d«      Zd„ Z e!dk(  r e	jD                   e «       «       yy)é    N)ÚBaseDirectoryé   )ÚbuildconfigÚ Fc                 ó~   — t        | «       t        r,t        j                  dt	        j
                  | «      z  «       yy)zZOutput information messages for the user on stdout
    and if desired, by espeak synthesisz	espeak %sN)ÚprintÚuse_espeak_synthesisÚosÚsystemÚshlexÚquote)Úmsgs    ú7/usr/lib/python3/dist-packages/speechd_config/config.pyÚreportr   0   s-   € ô 
ˆ#„JÝÜ
�	‰	�+¤§¡¨CÓ 0Ñ0Õ1ð ó    c                  ó<   — t         rt        j                  d«       yy)zBProduce a sound for the event 'input requested' used in question()zespeak "Type in"N)r	   r
   r   © r   r   Úinput_audio_iconr   7   s   € åÜ
�	‰	Ð&Õ'ð r   c                 ó�  — 	 t        |t        «      r|rd}nd}nt        |«      }t        | dz   |z   dz   «       t	        «        t
        st        d«      }t
        st        «      dk(  r|S t        |t        «      r|dv ry|d	v ry
t        d«       Œ�t        |t        «      rt        |«      S t        |t        «      r|S t        d«      ‚)z3Ask a simple question and suggest the default valueÚyesÚnoz [z] :ú>r   )r   ÚyÚYÚtrueÚtÚ1T)r   ÚnÚNÚfalseÚfÚ0Fz#Unknown answer (type 'yes' or 'no')z"Invalid type for the default value)
Ú
isinstanceÚboolÚstrr   r   Údont_askÚinputÚlenÚintÚ	TypeError)ÚtextÚdefaultÚdefault_strÚstr_inps       r   Úquestionr/   <   sÁ   € ð Ü�gœtÔ$ÙØ#‘à"‘ä˜g›,ˆKÜˆt�d‰{˜;Ñ& uÑ,Ô-ÜÔåÜ˜C“jˆGõ œ˜G›¨Ò)ØˆNä˜¤Ô&ØÐ;Ñ;ØØÐ?Ñ?ØäÐ=Ô>ØÜ˜¤Ô%Ü�w“<ÐÜ˜¤Ô%ØˆNäÐ@ÓAÐAr   c                 óê   — t        | |«      }||vrbt        t        d|z  «      «       t        t        dt        |«      z   «      «       t        t        d«      d«      }|rt        | |«      }n|S ||vrŒb|S )z›Ask a question with suggested answers. If the answer typed is not
    in 'suggest', the user is notified and given an opportunity to correct
    his choicezRThe value you have chosen is not among the suggested values.
You have chosen '%s'.zThe suggested values are z#Do you want to correct your answer?T©r/   r   Ú_r%   )r+   r,   ÚsuggestÚreplyÚcorrects        r   Úquestion_with_suggested_answersr6   `   s‚   € ô
 �T˜7Ó#€EØ
�wÑ
ÜŒqð Ø ñ!ó "ô 	#äŒqÐ,¬s°7«|Ñ;Ó<Ô=Üœ1ÐBÓCÀTÓJˆÙÜ˜T 7Ó+‰EàˆLð �wÒ
ð €Lr   c           
      óŽ   — t        | |«      }||vr4t        t        d|›dt        |«      ›�«      «       t        | |«      }||vrŒ4|S )zGAsk a question and repeat it until the answer typed in is in 'required'zYou have chosen 'z'. Please choose one of r1   )r+   r,   Úrequiredr4   s       r   Úquestion_with_required_answersr9   q   sK   € ô �T˜7Ó#€EØ
�xÑ
Ü�qÂEÌ3ÈxÌ=ÐYÓZÔ[Ü˜˜wÓ'ˆð �xÒ
ð €Lr   c            
      ó€  — t        j                  t        d«      ¬«      } | j                  dddddt        d«      ¬	«       | j                  d
ddddt        d«      ¬	«       | j                  dddddt        d«      ¬	«       | j                  dddddt        d«      ¬	«       | j                  dddddt        d«      ¬	«       | j                  ddddt        d«      ¬	«       | j                  ddddt        d«      ¬	«       | j                  d d!ddt        d"«      ¬	«       | j                  d#d$ddt        d%«      ¬	«       | j                  d&d'd(dt        t        d)«      ¬	«       | j                  d*d+d,ddt        d-«      ¬	«       | j                  d.d/d0ddt        d1«      ¬	«       | j                  d2d3dt        d4«      ¬5«       | S )6z;Set up an argparser instance with all the options accepted.zRA simple tool for basic configuration of Speech Dispatcher and problem diagnostics)Údescriptionz-uz--create-user-confÚcreate_user_configurationÚ
store_trueFz9Create Speech Dispatcher configuration for the given user)ÚdestÚactionr,   Úhelpz-cz--config-basic-settings-userÚconfig_basic_settings_userz.Configure basic settings in user configurationz-Cz--config-basic-settings-systemÚconfig_basic_settings_systemz5Configure basic settings in system-wide configurationz-dz--diagnosticsÚdiagnosticsz(Diagnose problems with the current setupz-sz--test-spd-sayÚtest_spd_sayz2Test connection to Speech Dispatcher using spd-sayz--test-festivalÚtest_festivalú'Test whether Festival works as a serverz--test-espeakÚtest_espeakz0Test whether Espeak works as a standalone binaryz--test-alsaÚ	test_alsazTest ALSA audio outputz--test-pulseÚ
test_pulsezTest Pulse Audio outputz-ez--espeakr	   z!Use espeak to synthesize messagesz-nz
--dont-askr&   z3Do not ask any questions, always use default valuesz-Dz--debugÚdebugz%Debug a problem and generate a reportz	--versionÚversionú Print version and copyright info)r>   r?   r@   )ÚargparseÚArgumentParserr2   Úadd_argumentr	   )Úparsers    r   Úsetup_argparserQ   z   s.  € ä×$Ñ$ÜÐjÓkôm€Fà
×Ñ˜Ð2Ø(°ÀuÜÐJÓKð ô Mð ×Ñ˜Ð<Ø)°,ÈÜÐ?Ó@ð ô Bð ×Ñ˜Ð>Ø+°LÈ%ÜÐFÓGð ô Ið ×Ñ˜˜o°MØ UÜÐ9Ó:ð ô <ð ×Ñ˜Ð.°^Ø UÜÐCÓDð ô Fð ×ÑÐ)°Ø UÜÐ8Ó9ð ô ;ð ×Ñ˜¨mÀLØœAÐPÓQð ô Sà
×Ñ˜¨KÀØœAÐ6Ó7ð ô 9à
×Ñ˜¨\À,Ø¤Ð";Ó <ð ô >à
×Ñ˜˜jÐ/EØÔ)=ÜÐ6Ó7ð ô 9ð ×Ñ˜˜l°Ø¨ÜÐHÓIð ô Kð ×Ñ˜˜i¨gØ¨ÜÐ:Ó;ð ô =ð ×Ñ˜¨)ØÜÐ5Ó6ð ô 8ð €Mr   c                   ó†   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zdd„Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	 	 dd„Zd„ Zd„ Zdd„Zy)ÚTestszrTests of functionality of Speech Dispatcher and its dependencies
    and methods for determination of proper pathsc                 ó   — d | _         y ©N)Úfestival_socket©Úselfs    r   Ú__init__zTests.__init__¨   s
   € Ø#ˆÕr   c                 ól   — t        dt        j                  › d�«       t        t        d«      dz  «       y)rL   z	spd-conf ú
a$  Copyright (C) %d-%d Brailcom, o.p.s.
This is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version. Please see COPYING for more details.

)iÒ  iÜ  N)r   r   ÚVERSIONr2   rW   s    r   rK   zTests.version«   s9   € ä�œ;×.Ñ.Ð/¨rÐ2Ô3ÜŒqð ?ó @ð
 ñõ 	r   c                 ó^   — t         j                  j                  t        j                  d«      S )z#Return user configuration directoryúspeech-dispatcher)r
   ÚpathÚjoinr   Úxdg_config_homerW   s    r   Úuser_conf_dirzTests.user_conf_dirµ   s   € ä�w‰w�|‰|œM×9Ñ9Ð;NÓOÐOr   c                 ó"   — t         j                  S )z(Determine system configuration directory)r   ÚSPD_CONF_PATHrW   s    r   Úsystem_conf_dirzTests.system_conf_dir¹   s   € ä×(Ñ(Ð(r   c                 ó\   — t         j                  j                  | j                  «       «      S )z5Determine whether user configuration directory exists)r
   r_   Úexistsrb   rW   s    r   Úuser_conf_dir_existszTests.user_conf_dir_exists½   s   € ä�w‰w�~‰~˜d×0Ñ0Ó2Ó3Ð3r   c                 ó’  — t        j                   t         j                  t         j                  «      | _        	 | j                  j	                  t        j
                  |«      |f«       y# t         j                  $ rI}|j                  \  }}t        t        d||fz  «      «       t        t        d|z  «      «       Y d}~yd}~ww xY w)z¡
        Try to connect to festival and determine whether it is possible.
        On success self.festival_socket is initialized with the opened socket.
        ztERROR: It was not possible to connect to Festival on the
given host and port. Connection failed with error %d : %s .z«Hint: Most likely, your Festival server is not running now
or not at the default port %d.

Try /etc/init.d/festival start or run 'festival --server' from the command line.NFT)
ÚsocketÚAF_INETÚSOCK_STREAMrV   ÚconnectÚgethostbynameÚerrorÚargsr   r2   )rX   ÚhostÚportÚeÚnumÚreasons         r   Úfestival_connectzTests.festival_connectÁ   s¾   € ô
  &Ÿ}™}¬V¯^©^¼V×=OÑ=OÓPˆÔð
	Ø× Ñ ×(Ñ(¬&×*>Ñ*>¸tÓ*DÀdÐ)KÔLð øô �|‰|ò 	ØŸF™F‰MˆS�&Ü”1ð ?ØBEÀvÀñOó Pô Qä”1ð Tð W[ñ[ó \ô ]ô ûð	ús   ¹0A* Á*CÁ=?CÃCc                 ó*  — | j                   s| j                  «       sy| j                   j                  t        dd«      «       t	        | j                   j                  d«      «      }d|v rt        t        d«      «       yt        t        d«      «       y)	zSTest whether festival works and contains working festival-freebsoft-utils.
        Fz(require 'speech-dispatcher)
Úasciii   ÚLPz"Festival contains freebsoft-utils.Tz¼ERROR: Your Festival server is working but it doesn't seem
to load festival-freebsoft-utils. You need to install festival-freebsoft-utils
to be able to use Festival with Speech Dispatcher.)rV   rv   ÚsendÚbytesr%   Úrecvr   r2   )rX   r4   s     r   Úfestival_with_freebsoft_utilsz#Tests.festival_with_freebsoft_utilsÔ   s„   € ð ×#Ò#Ø×(Ñ(Ô*ØØ×Ñ×!Ñ!¤%Ð(HÈ'Ó"RÔSÜ�D×(Ñ(×-Ñ-¨dÓ3Ó4ˆØ�5‰=Ü”1Ð9Ó:Ô;Øä”1ð 6ó 7ô 8ð r   c                 óv   — ddl }	 |j                  d«       y# t        $ r t        t	        d«      «       Y yw xY w)z0Try whether python speechd library is installed.r   NÚspeechdzíPython can't find the Speech Dispatcher library.
Is it installed? This won't prevent Speech Dispatcher to work, but no
Python applications like Orca will be able to use it.
Search for package like python-speechd, download and install it.FT)Ú	importlibÚimport_moduleÚImportErrorr   r2   )rX   r€   s     r   Úpython_speechd_in_pathzTests.python_speechd_in_pathå   sJ   € ãð	Ø×#Ñ# IÔ.ð øô ò 	Ü”1ð Dó Eô Fñ ð	ús   † ˜8·8c                 óB  — t         j                  j                  t        j                  d«      }d}|dk(  rd}n|dk(  rd}nt        d«      ‚t        j                  |«      s4t        t        |›d|›d	�«      «       t        t        d
|z  «      d«      }|S |›d|›�}t        j                  |«      r,t        t        d|z  «      «       t        t        d«      «       yt        t        d«      d«      }|st        t        d«      «       yt        t        d|z  «      «       y)z]Try to play a sound through the standard playback utility for the
        given audio method.ztest.wavNÚalsaÚaplayÚpulseÚpaplayz-Test for this audio system is not implementedz selected, but zT not installed. This might be a false
warning, but most likely sound is not working.z&Are you sure that %s audio is working?Fú zCan't play audio via
     %szUYour audio doesn't seem to work, please fix audio first or choose
a different method.zDid you hear the sound?TzýPlease examine the above output from the sound playback
utility. If everything seems right, are you sure your audio is loud enough and
not muted in the mixer? Please fix your audio system first or choose a different
audio output method in configuration.zAudio output '%s' works)r
   r_   r`   r   ÚSPD_SOUND_DATA_PATHÚNotImplementedErrorÚshutilÚwhichr   r2   r/   r   )rX   ÚtypeÚwavfileÚbinaryr4   Úcmds         r   Úaudio_try_playzTests.audio_try_playò   s  € ô —'‘'—,‘,œ{×>Ñ>¸zÓJˆàˆà�6Š>Ø‰FØ�WŠ_Ø‰Fä%Ð&UÓVÐVä�|‰|˜FÔ#Ü”1Ú59º6ðCó Dô EäœQÐGÈ$ÑNÓOÐQVÓWˆEØˆLâ¡Ð)ˆÜ�9‰9�SŒ>Ü”1Ð4°sÑ:Ó;Ô<Ü”1ð ó ô àô œÐ4Ó5°tÓ<ˆáÜ”1ð )ó *ô +ð ä”1Ð.°Ñ5Ó6Ô7Ør   c                 ó  — t        t        d«      «       	 t        j                  d«      rt        t        d«      «       yt	        t        d«      d«      }|rt        t        d«      «       yt        t        d«      «       y)	z$Test Speech Dispatcher using spd_sayz'Testing Speech Dispatcher using spd_sayTz.spd-say -P important "Speech Dispatcher works"z\Can't execute the spd-say binary,
it is very likely that Speech Dispatcher is not installed.Fz9Did you hear the message about Speech Dispatcher working?z+Speech Dispatcher is installed and working!z8Speech Dispatcher is installed but there is some problem©r   r2   r
   r   r/   )rX   Úhearing_tests     r   rD   zTests.test_spd_say  sr   € ô 	ŒqÐ:Ó;Ô<àÜ�y‰yÐKÔLÜ”qð >ó ?ô @àÜ#¤AÐ&aÓ$bÐdhÓiˆLÙÜ”qÐFÓGÔHØä”qÐSÓTÔUØr   c                 ó¢   — t        t        d«      «       | j                  «       }|st        t        d«      «       yt        t        d«      «       y)rF   z*Testing whether Festival works as a serverzFestival server is not working.Fz'Festival server seems to work correctlyT)r   r2   r}   )rX   Úrets     r   rE   zTests.test_festival,  sC   € äŒqÐ=Ó>Ô?à×0Ñ0Ó2ˆÙÜ”1Ð6Ó7Ô8Øä”1Ð>Ó?Ô@Ør   c                 ó¨   — t        t        d«      «       t        j                  d«      rt        t        d«      «       yt        t        d«      «       y)zTest the espeak utilityzTesting whether Espeak worksÚespeakzEspeak is installedTzKCan't execute the espeak binary, it is likely that espeak
is not installed.F)r   r2   rŒ   r�   rW   s    r   rG   zTests.test_espeak8  sF   € ô 	ŒqÐ/Ó0Ô1Ü�<‰<˜Ô!Ü”1Ð*Ó+Ô,Øä”1ð ó ô àr   c                 óN   — t        t        d«      «       | j                  d¬«      S )zTest ALSA sound outputzTesting ALSA sound outputr…   ©rŽ   ©r   r2   r’   rW   s    r   rH   zTests.test_alsaD  s$   € äŒqÐ,Ó-Ô.Ø×"Ñ"¨Ð"Ó/Ð/r   c                 óN   — t        t        d«      «       | j                  d¬«      S )zTest Pulse Audio sound outputzTesting PULSE sound outputr‡   r›   rœ   rW   s    r   rI   zTests.test_pulseI  s$   € äŒqÐ-Ó.Ô/Ø×"Ñ"¨Ð"Ó0Ð0r   Nc                 ó  — g }g }|r0| j                  «       rd}t        t        d«      d«      }|r	ddiS d}nd}|st        t        d«      d«      sddiS d„ } |dd|«      r| j                  «       r|dgz  } |d	d
|«      r| j	                  «       r|d	gz  } |dd|«      r| j                  «       r|dgz  } |dd|«      r| j                  «       r|dgz  }t        t        d«      «       | j                  «       }	||||	dœS )zPerform a complete diagnosticsTz9Speech Dispatcher works. Do you want to skip other tests?Úspd_say_workingFz›
Speech Dispatcher isn't running or we can't connect to it (see above),
do you want to proceed with other tests? (They can help to determine
what is wrong)c                 óD   — |sy| |v rt        t        d|z  «      d«      ryy)z3Ask the user whether to test a specific capability.FzDo you want to test the %s now?T)r/   r2   )Ú
identifierÚnameÚlistings      r   Údecide_to_testz)Tests.diagnostics.<locals>.decide_to_testh  s+   € áØØ˜wÑ&ÜœQÐ@À4ÑGÓHÈ$ÔOØàr   ÚfestivalzFestival synthesizerr™   zEspeak synthesizerr…   zALSA sound systemr‡   zPulse Audio sound systemzJTesting whether Python Speech Dispatcher library is in path and importable)rŸ   ÚaudioÚsynthesizersÚpython_speechd)	rD   r/   r2   rE   rG   rH   rI   r   rƒ   )
rX   Úspeechd_runningÚoutput_modulesÚaudio_outputÚworking_modulesÚworking_audiorŸ   Úskipr¤   Úpython_speechd_workings
             r   rC   zTests.diagnosticsN  sB  € ð ˆØˆáà× Ñ Ô"Ø"&�Ü¤Ð"]Ó ^Ø $ó&�áØ-¨tÐ4Ð4à"'‘à#ˆOáÜœAð ó ð ôð *¨5Ð1Ð1ò	ñ ˜*Ð&<¸nÔMØ×!Ñ!Ô#Ø J <Ñ/�á˜(Ð$8¸.ÔIØ×ÑÔ!Ø H :Ñ-�á˜&Ð"5°|ÔDØ�~‰~ÔØ & Ñ)�á˜'Ð#=¸|ÔLØ�‰Ô Ø ' Ñ*�äŒqÐ]Ó^Ô_Ø!%×!<Ñ!<Ó!>Ðà$3Ø'Ø!0Ø$:ñ<ð 	<r   c                 ó¸  — t        t        d«      «       d|v r.|d   rt        t        d«      «       nt        t        d«      «       d|v r#t        t        d«      t        |d   «      z  «       d|v r#t        t        d«      t        |d   «      z  «       d	|v r.|d	   rt        t        d
«      «       nt        t        d«      «       t        t        d«      «       y)z,Write out diagnostics results using report()z

Diagnostics results:rŸ   zSpeech Dispatcher is workingz-Speech Dispatcher not working through spd-sayr§   z2Synthesizers that were tested and seem to work: %sr¦   z3Audio systems that were tested and seem to work: %sr¨   z-Python Speech Dispatcher module is importablezTPython Speech Dispatcher module not importable.
Either not installed or not in path.zEnd of diagnostics resultsN)r   r2   r%   )rX   Úresultss     r   Úwrite_diagnostics_resultszTests.write_diagnostics_resultsŠ  sÜ   € ô 	Œqð ó ô 	ð  Ñ'ØÐ(Ò)Ü”qÐ7Ó8Õ9ä”qÐHÓIÔJØ˜WÑ$Ü”1ÐIÓJÜ�w˜~Ñ.Ó/ñ0ô 1à�gÑÜ”1ÐJÓKÜ�w˜wÑ'Ó(ñ)ô *à˜wÑ&ØÐ'Ò(Ü”qÐHÓIÕJä”qð (ó )ô *äŒqÐ-Ó.Õ/r   c                 ó,  — t         j                  j                  t         j                  j                  | j	                  «       d«      «      syt        t        j                  | j	                  «       «      «      dkD  syt         j                  j                  t         j                  j                  | j	                  «       d«      «      syt         j                  j                  t         j                  j                  | j	                  «       d«      «      syy)z:Decide if the user configuration seems reasonably completeúspeechd.confFé   ÚmodulesÚclientsT)r
   r_   rg   r`   rb   r(   ÚlistdirrW   s    r   Ú!user_configuration_seems_completez'Tests.user_configuration_seems_complete£  s¨   € ä�w‰w�~‰~œbŸg™gŸl™l¨4×+=Ñ+=Ó+?ÀÓPÔQØä”2—:‘:˜d×0Ñ0Ó2Ó3Ó4°qÒ8Øä�w‰w�~‰~œbŸg™gŸl™l¨4×+=Ñ+=Ó+?ÀÓKÔLØä�w‰w�~‰~œbŸg™gŸl™l¨4×+=Ñ+=Ó+?ÀÓKÔLØàr   c                 óê  — t        t        d«      «       |st        t        d«      dddg«      }t        t        d«      d«      }|r+t	        j
                  d«       t	        j
                  d«       n?t        t        d	«      «       t        t        d
«      d«      }|st        t        d«      «       t        j                  d«       dt        j                  v rt        j                  d   }nd}t        j                  j                  |d«      }t        j                  j                  «       }t        j                  j                  |d|j                  |j                  |j                   fz  «      }|dk(  r;t        t        d«      «       t	        j
                  d«       }| j#                  «       }nft        t        d«      «       t        t        d«      «       t        t        d«      d«      }|rd}nt        t        d«      «       | j%                  «       }t        j                  d«       st        t        d«      d«      }t        t        d«      «       t	        j
                  d«      }	|	s+t	        j
                  d«       t	        j
                  d«       nt        t        d«      «       t        t        d«      «       t        j                  d«       t        t        d «      «       t	        j
                  d!«       t	        j
                  d"|›d#|›d$|›�«       t	        j
                  d«       t	        j
                  d«       t	        j
                  d%|z  «       t        t        d&|z  «      «       y')(zvStart Speech Dispatcher in debugging mode, collect the debugging output
        and offer to send it to the developersz@Starting collecting debugging output, configuration and logfilesz<
Do you want to debug 'system' or  'user' Speech Dispatcher?Úuserr   zdIt is necessary to kill the currently running Speech Dispatcher
processes. Do you want to do it now?Túkillall speech-dispatcherúkillall speech-dispatchzy
You decided not to kill running Speech Dispatcher processes.
Please make sure your Speech Dispatcher is not running now.z*Is your Speech Dispatcher not running now?z@Can't continue, please stop your Speech Dispatcher and try againrµ   ÚTMPDIRz/tmp/zspeechd-debugzspeechd-debug-%d-%d-%d.tar.gzz7Speech Dispatcher will be started now in debugging modezspeech-dispatcher -Dú3Warning: You must be root or under sudo to do this.zC
Please start your system Speech Dispatcher now with parameter '-D'z&Is your Speech Dispatcher running now?úCan't continuez5Speech Dispatcher failed to start, continuing anyway?FzTrying to speak some messagesz'spd-say "Speech Dispatcher debugging 1"z'spd-say "Speech Dispatcher debugging 2"z'spd-say "Speech Dispatcher debugging 3"z6Can't test Speech Dispatcher connection, can't connectzPlease wait (about 5 seconds)é   z>Collecting debugging output and your configuration informationz	umask 077ztar -cz r‰   z > z	rm -rf %sz’
Please send %s to speechd-discuss@nongnu.org with
a short description of what you did. We will get in touch with you soon
and suggest a solution.N)r   r2   r9   r/   r
   r   ÚtimeÚsleepÚenvironr_   r`   ÚdatetimeÚdateÚtodayÚdayÚmonthÚyearrb   re   )
rX   rŽ   r4   ÚtmpdirÚdebugdir_pathrÆ   Údebugarchive_pathÚspeechd_startedÚconfigure_directoryr—   s
             r   Údebug_and_reportzTests.debug_and_report³  sÊ  € ô 	ŒqÐSÓTÔUáÜ1´!ð 5?ó 3@à28¸6À8Ð:LóNˆDô
 œð (ó )Ø*.ó0ˆáÜ�I‰IÐ1Ô2ä�I‰IÐ/Õ0ä”1ð ?ó @ô Aô œQÐKÓLÈdÓSˆEÙÜ”qÐ[Ó\Ô]ä�
‰
�1Œð ”r—z‘zÑ!Ü—Z‘Z Ñ)‰FàˆFÜŸ™Ÿ™ V¨_Ó=ˆÜ�}‰}×"Ñ"Ó$ˆÜŸG™GŸL™L¨Ð1PØ*.¯(©(°D·J±JÀÇ	Á	Ð)Jñ2Kó LÐð �6Š>Ü”1ÐNÓOÔPÜ"$§)¡)Ð,BÓ"CÐCˆOØ"&×"4Ñ"4Ó"6Ñä”1ÐJÓKÔTÜ”1ð Fó Gô HäœQÐGÓHÈ$ÓOˆEÙØ"&‘ä”qÐ)Ó*Ô+Ø"&×"6Ñ"6Ó"8ÐÜ�
‰
�1ŒáÜœQÐVÓWØóˆEô 	ŒqÐ0Ó1Ô2Ü�i‰iÐCÓDˆÙÜ�I‰IÐAÔBÜ�I‰IÐAÕBä”1ÐMÓNÔOäŒqÐ0Ó1Ô2Ü�
‰
�1ŒäŒqÐQÓRÔTä
�	‰	�+ÔÜ
�	Š	Ú Ò"5Ñ7HðJô 	Kä
�	‰	Ð-Ô.ä
�	‰	Ð+Ô,Ü
�	‰	�+ Ñ-Ô.äŒqð ð /ñ/ó 0õ 	1r   )Ú	localhosti"  )TNNrU   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rY   rK   rb   re   rh   rv   r}   rƒ   r’   rD   rE   rG   rH   rI   rC   r²   r¹   rÐ   r   r   r   rS   rS   ¤   so   „ ñ5ò$òòPò)ò4óò&ò"ò&òPò$
ò
ò0ò
1ð
 BFØó:<òx0ò2ô S1r   rS   c                   óN   — e Zd ZdZdZdZdZd„ Zd„ Zd„ Z	d„ Z
dd„Zd„ Zd	„ Zd
„ Zy)Ú	ConfigurezNSetup user configuration and/or set basic options in user/system configurationNc                 ó   — || _         y rU   )Útest)rX   rÙ   s     r   rY   zConfigure.__init__  s	   € Øˆ�	r   c                 ó^   — t        j                  | j                  j                  «       «       y)zRemove user configuration treeN)rŒ   ÚrmtreerÙ   rb   rW   s    r   Úremove_user_configurationz#Configure.remove_user_configuration  s   € ä�‰�d—i‘i×-Ñ-Ó/Õ0r   c                 ó°  — t        j                  |dd¬«      D ]»  }|j                  «       D ]™  \  }}||v sŒd}|j                  «       D ]!  }|dk(  s|dk(  rŒ||k(  r
|dk7  sŒd} n|dz  }Œ# |dk(  sŒGt	        |t
        «      r
|rd	}n,|s*d
}n't	        |t        «      rt        |«      }nt        |«      }t        |dz   z   «        Œ® t        |d¬«       Œ½ y)zÆSubstitute the given options with given values.

        Arguments:
        configfile -- the file path of the configuration file as a string
        options -- a list of tuples (option_name, value)Tz.bak)ÚinplaceÚbackupr   ú#ú	rµ   r   r   Ú2z   r‰   )ÚendN)	Ú	fileinputr'   ÚitemsÚsplitr#   r$   r)   r%   r   )	rX   Ú
configfileÚoptionsÚlineÚoptÚvalueÚunknownÚwordÚspd_vals	            r   Úoptions_substitutezConfigure.options_substitute  sï   € ô —O‘O J¸ÀVÔLò &	%ˆDà%Ÿm™m›oò $%‘
��UØ˜$’;ð  �GØ $§
¡
£ò 
)˜Ø #š:¨°ªØ$Ø! Sš[ð  '¨!›|Ø*+ Ù %à# q™L™Gð
)ð  !“|ä% e¬TÔ2Ù$Ø*-¡Ù%*Ø*-¡Ü'¨¬sÔ3Ü&)¨%£j™Gä&)¨%£j˜Gä˜c E™k¨GÑ3Ô4ÙðC$%ôH �d Ö$ñM&	%r   c                 óZ  — | j                   j                  «       r”| j                   j                  «       r=t        t	        d«      d«      }|st        t	        d«      «       y| j                  «        n=t        t	        d«      d«      }|s| j                  «        nt        t	        d«      «       y| j                   j                  «       }t        j                  t        j                  |«       t        j                  d«      }t        j                  |«       t        j                  | j                   j                  «       d| z  «       t        j                  | j                   j                  «       «      D ]„  \  }}}|D ]:  }t        j                  t        j                   j#                  ||«      d| z  «       Œ< |D ]:  }t        j                  t        j                   j#                  ||«      d	| z  «       Œ< Œ† t        t	        d
| j                   j                  «       z  «      «       y)z2Create user configuration in the standard locationzLUser configuration already exists.
Do you want to rewrite it with a new one?Fz:Keeping configuration intact and continuing with settings.NzYUser configuration already exists, but it seems to be incomplete.
Do you want to keep it?z*Keeping configuration intact and aborting.r   ií  i¤  z User configuration created in %s)rÙ   rh   r¹   r/   r2   r   rÜ   rb   rŒ   Úcopytreer   ÚSPD_CONF_ORIG_PATHr
   ÚumaskÚchmodÚwalkr_   r`   )	rX   r4   Úconfig_rootró   ÚrootÚdirsÚfilesÚdr!   s	            r   r<   z#Configure.create_user_configurationF  s¯  € ð �9‰9×)Ñ)Ô+Ø�y‰y×:Ñ:Ô<Ü ¤ð $-ó ".Ø/4ó6�áÜœ1ÐYÓZÔ[Øà×2Ñ2Õ4ä ¤ð $ó "Ø"ó$�áØ×2Ñ2Õ4äœ1ÐIÓJÔKØð —i‘i×-Ñ-Ó/ˆÜ�‰œ×6Ñ6¸ÔDä—‘˜“ˆÜ
�‰�ŒÜ
�‰�—‘×(Ñ(Ó*¨U°e°V©^Ô<Ü!#§¡¨¯©×)@Ñ)@Ó)BÓ!Cò 	@ÑˆD�$˜Øò @�Ü—‘œŸ™Ÿ™ d¨AÓ.°¸¸±Õ?ð@àò @�Ü—‘œŸ™Ÿ™ d¨AÓ.°¸¸±Õ?ñ@ð	@ô 	ŒqÐ3°d·i±i×6MÑ6MÓ6OÑOÓPÕQr   c           
      óD  — |dk(  rt        t        d«      «       n9|dk(  r)t        t        d«      «       t        t        d«      «       nt        d«      ‚t        ddg d	¢«      | _        t        d
d«      | _        t        ddg d¢«      | _        t        t        d«      d«      }t        t        d«      d«      }t        t        d«      d«      }|dk(  r9t        j                  j                  | j                  j                  «       d«      }n=|dk(  r8t        j                  j                  | j                  j                  «       d«      }| j                  | j                  | j                  | j                  |||dœ«       |dk(  ržt        t        d«      d«      }|r†t        j                   t        j                  j                  t"        j$                  d«      t        j                  j                  t&        j(                  d«      «       t        t        d|z  «      «       yyy)zAAsk for basic settings and rewrite them in the configuration filer»   z/Configuring user settings for Speech Dispatcherr   r¿   z1Configuring system settings for Speech DispatcherúInvalid configuration typezDefault output moduleú	espeak-ng)rý   r™   r¥   ÚfliteÚivonaÚpicozespeak-ng-mbrola-genericzespeak-mbrola-genericzswift-genericzepos-genericzdtk-genericÚibmttsÚciceroÚkalizmary-genericÚ	baratinooznDefault language (two/three-letter iso language code like "en" or "cs", possibly with a region qualification.)zen-USzDefault audio output methodr‡   )r‡   Úlibaor…   Úossz
pulse,alsazZDefault speech rate (on the scale of -100..100, 0 is default, 50 is faster, -50 is slower)r"   zZDefault speech pitch (on the scale of -100..100, 0 is default, 50 is higher, -50 is lower)z`Default speech pitch range (on the scale of -100..100, 0 is default, 50 is higher, -50 is lower)r´   )ÚDefaultModuleÚDefaultLanguageÚAudioOutputMethodÚDefaultRateÚDefaultPitchÚDefaultPitchRangez³Do you want to have Speech Dispatcher automatically started from ~/.config/autostart ?
This is usually not necessary, most applications will start Speech Dispatcher automatically.Fzspeechd.desktopz
autostart/zï
Configuration written to %s
Basic configuration now complete. You might still need to fine tune it by
manually editing the configuration file above. Especially if you need to
use special audio settings, non-standard synthesizer ports etc.N)r   r2   Ú
ValueErrorr6   Údefault_output_moduler/   Údefault_languageÚdefault_audio_methodr
   r_   r`   rÙ   rb   re   rï   rŒ   Úcopyr   ÚSPD_DESKTOP_CONF_PATHr   ra   )rX   rŽ   Údefault_speech_rateÚdefault_speech_pitchÚdefault_speech_pitch_rangerç   Úsetup_autostarts          r   Úconfigure_basic_settingsz"Configure.configure_basic_settingsk  s  € ð �6Š>Ü”1ÐFÓGÕHØ�XÒÜ”1ÐJÓKÔLÜ”1ÐHÓIÕJäÐ9Ó:Ð:ô &EØ#Øò*ó&+ˆÔ"ô !)ð AØó!ˆÔô %DØ)ØÚ;ó%=ˆÔ!ô
 'ÜÐjÓkØóÐô  (ÜÐjÓkØó Ðô &.ÜÐpÓqØó&Ð"ð
 �6Š>ÜŸ™Ÿ™ d§i¡i×&=Ñ&=Ó&?ÀÓP‰JØ�XÒÜŸ™Ÿ™ d§i¡i×&?Ñ&?Ó&AÀ>ÓRˆJà×Ñ 
Ø26×2LÑ2LØ48×4IÑ4IØ6:×6OÑ6OØ0CØ1EØ6Pñ!#ô	$ð �6Š>Ü&Üð `ó aàóˆOñ Ü—‘Ü—G‘G—L‘L¤×!BÑ!BÐDUÓVÜ—G‘G—L‘L¤×!>Ñ!>ÀÓMôô
 ”qð Cð FPñ	Pó Qõ Rð ð r   c                 óf  — t        t        d«      «       t        j                  d«      }|r†t        t        d|z  «      «       t	        t        d«      d«      }|rWt        j                  d«       t        j                  d«       t        j                  d«      }|rt        t        d«      «       y	yy	y)
z$Start Speech Dispatcher in user-modez'Starting Speech Dispatcher in user-moder^   ú4Can't start Speech Dispatcher. Exited with status %dz„Perhaps this is because your Speech Dispatcher is already running.
Do you want to kill all running Speech Dispatchers and try again?Tr¼   r½   zCan't start Speech DispatcherFr”   )rX   Úerrr4   s      r   Úspeechd_start_userzConfigure.speechd_start_user³  s    € ô 	ŒqÐ:Ó;Ô<ä�i‰iÐ+Ó,ˆÙÜ”1ÐKÈcÑQÓRÔSÜœQð  Eó FØGKóMˆEáÜ—	‘	Ð5Ô6ä—	‘	Ð3Ô4Ü—i‘iÐ 3Ó4�ÙÜœ1Ð<Ó=Ô>Ø ð ð Ør   c                 óÜ  — t        t        d«      «       t        t        d«      «       t        t        d«      d«      }|rmt        t        d«      «       t        j                  d«       t        t        d«      «       t        j                  d«      }|rt        t        d	|z  «      «       y
yt        t        d«      «       t        t        d«      d«      }|st        t        d«      «       y
y)z&Start Speech Dispatcher in system-moder¿   z)Starting Speech Dispatcher in system-modez=Is your system using an /etc/init.d/speech-dispatcher script?Tz9Stopping Speech Dispatcher in case any is running alreadyz"/etc/init.d/speech-dispatcher stopz<Starting Speech Dispatcher via /etc/init.d/speech-dispatcherz#/etc/init.d/speech-dispatcher startr  Fz]Do not know how to start system Speech Dispatcher,
you have to start it manually to continue.z'Have you started Speech Dispatcher now?rÀ   )r   r2   r/   r
   r   )rX   r4   r—   s      r   Úspeechd_start_systemzConfigure.speechd_start_systemÉ  sÎ   € ô 	ŒqÐFÓGÔPÜŒqÐ<Ó=Ô>äœÐZÓ[ØóˆáÜ”1ÐPÓQÔRÜ�I‰IÐ:Ô;Ü”1ÐSÓTÔUÜ—)‘)ÐAÓBˆCÙÜ”qÐOÐRUÑUÓVÔWØð ô ”1ð .ó /ô 0äœQÐHÓIÈ4ÓPˆEÙÜ”qÐ)Ó*Ô+ØØr   c                 ó°  — t        t        d«      dddg«      }|dk(  r#| j                  «        | j                  d¬«       n#|dk(  r| j                  d¬«       nt	        d«      ‚t        t        d«      d«      }|st        t        d«      «       y	|dk(  r| j                  «       }n|dk(  r| j                  «       }st        t        d
«      «       | j                  j                  || j                  g| j                  g¬«      }| j                  j                  |«       |s5t        t        d«      d«      }|r| j                  j                  |¬«       y	y	y	)zJCreate a complete configuration, run diagnosis and if necessary, debuggingz?Do you want to create/setup a 'user' or 'system' configuration?r»   r   r›   rü   zFDo you want to start/restart Speech Dispatcher now and run some tests?Tz-Your configuration is now done but not testedNz%Your Speech Dispatcher is not running)r©   r«   rª   zODo you want to run debugging now and send a request for help to the developers?F)r9   r2   r<   r  r  r/   r   r  r  rÙ   rC   r  r  r²   rÐ   )rX   Úspeechd_typer4   ÚstartedÚresults        r   Úcomplete_configzConfigure.complete_configâ  sS  € ô 6ÜÐOÓPØ�V˜XÐ&ó(ˆð ˜6Ò!Ø×*Ñ*Ô,Ø×)Ñ)¨vÐ)Õ6Ø˜XÒ%Ø×)Ñ)¨xÐ)Õ8äÐ9Ó:Ð:äœÐcÓdÐfjÓkˆÙÜ”1ÐDÓEÔFØà˜vÒ%Ø×1Ñ1Ó3‘Ø Ò)Ø×3Ñ3Ó5�áÜ”1Ð<Ó=Ô>à—‘×&Ñ&¸Ø04×0IÑ0IÐ/JØ26×2LÑ2LÐ1Mð 'ó Oˆð 	�	‰	×+Ñ+¨FÔ3áÜœQÐpÓqØ"ó$ˆEáØ—	‘	×*Ñ*°Ð*Õ=ð ð r   )r»   )rÒ   rÓ   rÔ   rÕ   r  r  r  rY   rÜ   rï   r<   r  r  r  r"  r   r   r   r×   r×     sE   „ áXà ÐØÐØÐòò1ò.%ò`#RóJFRòPò,ó2%>r   r×   c                  óÀ  — t        «       } | j                  «       } | j                  a| j                  at	        «       }t        |«      }| j                  st        t        d«      «       | j                  r;|j                  «        t        t        d«      d«      }|r|j                  d¬«       y y | j                  r|j                  d¬«       y | j                  r|j                  d¬«       y | j                  r|j                  «        y | j                  r|j                  «        y | j                   r|j!                  «        y | j"                  r|j%                  d¬«       y | j&                  r|j%                  d¬«       y | j(                  r"|j)                  «       }|j+                  |«       y | j,                  r|j/                  «        y | j                  r|j                  «        y t        t        d	«      d«      }|r|j1                  «        y t        t        d
«      d«      }|r"|j)                  «       }|j+                  |«       y t        t        d«      «       y )Nz&
Speech Dispatcher configuration tool
z,Do you want to continue with basic settings?Tr»   r›   r   r…   r‡   z4Do you want to setup a completely new configuration?z)Do you want to run diagnosis of problems?zwPlease run this command again and select what you want to do
or read the quick help available through '-h' or '--help'.)rQ   Ú
parse_argsr&   r	   rS   r×   rK   r   r2   r<   r/   r  rA   rB   rE   rD   rG   rH   r’   rI   rC   r²   rJ   rÐ   r"  )rè   rÙ   Ú	configurer4   r—   s        r   Úmainr&    sñ  € ô Ó€GØ× Ñ Ó"€GØ×Ñ€HØ"×7Ñ7ÐÜ‹7€DÜ˜$“€Ið �?Š?ÜŒqÐ;Ó<Ô=à×(Ò(à×+Ñ+Ô-ÜœÐIÓJÈDÓQˆÙØ×.Ñ.°FÐ.Õ;ð à	×	+Ò	+Ø×*Ñ*°Ð*Õ7à	×	-Ò	-Ø×*Ñ*°Ð*Õ9à	×	Ò	Ø×ÑÕà	×	Ò	Ø×ÑÕà	×	Ò	Ø×ÑÕà	×	Ò	Ø×Ñ ÐÕ(à	×	Ò	Ø×Ñ ÐÕ)à	×	Ò	Ø×ÑÓ ˆØ×&Ñ& sÕ+à	�ŠØ×ÑÕà	�ŠØ�‰�ô œÐQÓRÐTXÓYˆÙØ×%Ñ%Õ'äœQÐJÓKÈTÓRˆEÙØ×$Ñ$Ó&�Ø×.Ñ.¨sÕ3ä”qð >ó ?õ @r   Ú__main__)#rM   rÅ   rä   ÚgettextÚlocaler
   rŒ   r   rj   ÚsysrÂ   Úxdgr   r   r   Ú	setlocaleÚLC_ALLÚbindtextdomainÚGETTEXT_PACKAGEÚ	LOCALEDIRÚ
textdomainr2   r	   r&   r   r   r/   r6   r9   rQ   rS   r×   r&  rÒ   Úexitr   r   r   ú<module>r3     só   ðó( Û Û Û Û Û 	Û Û Û Û 
Û å õ ð €× Ñ �—‘ Ô #Ø €× Ñ ˜×3Ñ3°[×5JÑ5JÔ KØ €× Ñ �;×.Ñ.Ô /Ø‡O�O€ð Ð Ø€ò2ò(ò
"BòHò"ò(÷Tb1ñ b1÷H>ñ >òH>@ð@ ˆzÒØ€C‡H�H‰T‹VÕð r   