diff --git a/console/application/cert_func.py b/console/application/cert_func.py index 616a417..84334a1 100644 --- a/console/application/cert_func.py +++ b/console/application/cert_func.py @@ -434,7 +434,7 @@ def socket_connect(s, file_path): time.sleep(0.3) return s, hash_val -def get_password_from_daemon(server_host, server_port): +def get_password_from_daemon(server_host, server_port, wait_thread): size = 1024 # размер данных username = pwd.getpwuid(os.getuid()).pw_name @@ -451,6 +451,7 @@ def get_password_from_daemon(server_host, server_port): if resp.startswith('Error'): if 'timeout' in resp: continue + wait_thread.stop() password = set_password(s, req, size) else: password = resp if resp else None diff --git a/console/application/cl_client.py b/console/application/cl_client.py index 49674cc..efb84a4 100644 --- a/console/application/cl_client.py +++ b/console/application/cl_client.py @@ -35,8 +35,8 @@ from calculate.core.datavars import DataVarsCore from client_class import HTTPSClientCertTransport from methods_func import call_method, get_method_argparser, parse -from calculate.lib.cl_lang import setLocalTranslate from calculate.lib.utils.files import makeDirectory +from calculate.lib.cl_lang import setLocalTranslate setLocalTranslate('calculate_console',sys.modules[__name__]) def client_signal(client): @@ -189,7 +189,7 @@ def main(): parser = parse() args, unknown_args = parser.parse_known_args() wait_thread = StoppableThread() -# wait_thread.start() + wait_thread.start() if not args.method and args.help: wait_thread.stop() @@ -303,7 +303,10 @@ def main(): bio = M2Crypto.BIO.openfile(CERT_KEY) rsa = M2Crypto.m2.rsa_read_key(bio._ptr(),lambda *unused: None) if not rsa: - store_passwd = get_password_from_daemon(host, port) + store_passwd = get_password_from_daemon(host,port,wait_thread) + if not wait_thread.isAlive(): + wait_thread = StoppableThread() + wait_thread.start() # if not rsa and not 'store_passwd' in locals(): # store_passwd = getpass.getpass(_('Password: ')) # if not store_passwd: @@ -313,9 +316,12 @@ def main(): else: key_passwd = None try: - client = Client_suds(url,\ - transport = HTTPSClientCertTransport(CERT_KEY, CERT_FILE,\ - path_to_cert, password=key_passwd)) + client = Client_suds(url, transport=HTTPSClientCertTransport \ + (CERT_KEY, CERT_FILE, path_to_cert, password=key_passwd, + wait_thread = wait_thread)) + if not wait_thread.isAlive(): + wait_thread = StoppableThread() + wait_thread.start() client.wsdl.services[0].setlocation(url) client.set_parameters (path_to_cert, CERT_FILE, CERT_KEY) client_post_cert(client, clVarsCore) diff --git a/console/application/client_class.py b/console/application/client_class.py index 9a964bf..74fb164 100644 --- a/console/application/client_class.py +++ b/console/application/client_class.py @@ -30,6 +30,8 @@ from sudsds.properties import Unskin from cookielib import CookieJar, DefaultCookiePolicy from logging import getLogger from calculate.console.datavars import DataVarsConsole +from calculate.lib.cl_lang import setLocalTranslate +setLocalTranslate('calculate_console',sys.modules[__name__]) #import cert_func.verify log = getLogger(__name__) flag = 0 @@ -51,8 +53,8 @@ class CheckingClientHTTPSConnection(CheckingHTTPSConnection): """based on httplib.HTTPSConnection code - extended to support server certificate verification and client certificate authorization""" - def __init__(self, cert_path, host, ca_certs=None, - cert_verifier=None, keyobj=None, certobj=None, **kw): + def __init__(self, cert_path, host, ca_certs=None, cert_verifier=None, + keyobj=None, certobj=None, wait_thread=None, **kw): """cert_verifier is a function returning either True or False based on whether the certificate was found to be OK, keyobj and certobj represent internal PyOpenSSL structures holding @@ -63,6 +65,7 @@ class CheckingClientHTTPSConnection(CheckingHTTPSConnection): # self.ClientObj = ClientObj self.cert_path = cert_path self.CRL_PATH = os.path.join(cert_path, 'ca/crl/') + self.wait_thread = wait_thread # get filename store cert server def cert_list (self, host, ca_certs, server_cert): @@ -218,6 +221,7 @@ class CheckingClientHTTPSConnection(CheckingHTTPSConnection): # add certificate server in trusted def add_server_cert(self, cert): + self.wait_thread.stop() print _("Untrusted Server Certificate!") certobj = OpenSSL.crypto.load_certificate \ (OpenSSL.SSL.FILETYPE_PEM, cert) @@ -417,7 +421,7 @@ class CheckingClientHTTPSConnection(CheckingHTTPSConnection): class CheckingClientHTTPSHandler(CheckingHTTPSHandler): def __init__(self, cert_path, ca_certs=None, cert_verifier=None, client_certfile=None, client_keyfile=None, - client_keyobj=None, client_certobj=None, + client_keyobj=None, client_certobj=None, wait_thread=None, *args, **kw): """cert_verifier is a function returning either True or False based on whether the certificate was found to be OK""" @@ -426,6 +430,7 @@ class CheckingClientHTTPSHandler(CheckingHTTPSHandler): client_keyobj, client_certobj) # self.ClientObj = ClientObj self.cert_path = cert_path + self.wait_thread = wait_thread def https_open(self, req): def open(*args, **kw): @@ -433,10 +438,10 @@ class CheckingClientHTTPSHandler(CheckingHTTPSHandler): cert_verifier=self.cert_verifier, cert_file=self.client_certfile, key_file=self.client_keyfile, - keyobj=self.keyobj, - certobj=self.certobj) + keyobj=self.keyobj, certobj=self.certobj, + wait_thread=self.wait_thread) new_kw.update(kw) - return CheckingClientHTTPSConnection(self.cert_path, + return CheckingClientHTTPSConnection(self.cert_path, *args, **new_kw) return self.do_open(open, req) @@ -448,7 +453,7 @@ class HTTPSClientCertTransport(HttpTransport): client_keyfile=None, client_certfile=None, client_keyobj=None, client_certobj=None, cookie_callback=None, user_agent_string=None, - **kwargs): + wait_thread=None, **kwargs): Transport.__init__(self) # self.ClientObj = parent self.key = key @@ -484,7 +489,8 @@ class HTTPSClientCertTransport(HttpTransport): ca_certs=ca_certs, cert_verifier=cert_verifier, client_keyfile=client_keyfile, client_certfile = \ client_certfile, client_keyobj=client_keyobj, - client_certobj=client_certobj) + client_certobj=client_certobj, + wait_thread=wait_thread) else: https_handler = u2.HTTPSHandler() self.urlopener = u2.build_opener(SUDSHTTPRedirectHandler(), diff --git a/ru/calculate_console.po b/ru/calculate_console.po index b17d691..b85248f 100755 --- a/ru/calculate_console.po +++ b/ru/calculate_console.po @@ -2,8 +2,8 @@ msgid "" msgstr "" "Project-Id-Version: console_gui_translate\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-06-13 12:57+0300\n" -"PO-Revision-Date: 2012-06-13 12:57+0300\n" +"POT-Creation-Date: 2012-06-14 10:03+0300\n" +"PO-Revision-Date: 2012-06-14 10:03+0300\n" "Last-Translator: Denis \n" "Language-Team: \n" "Language: \n" @@ -15,8 +15,9 @@ msgstr "" "X-Poedit-SourceCharset: utf-8\n" "X-Poedit-SearchPath-0: /var/calculate/mydir/git/calculate-console/console/application\n" -#: /var/calculate/mydir/git/calculate-console/console/application/progressbar.py:36 -#: /var/calculate/mydir/git/calculate-console/console/application/progressbar.py:42 +#: /var/calculate/mydir/git/calculate-console/console/application/progressbar.py:25 +#: /var/calculate/mydir/git/calculate-console/console/application/progressbar.py:27 +#: /var/calculate/mydir/git/calculate-console/console/application/progressbar.py:30 msgid "Time" msgstr "Время" @@ -125,20 +126,20 @@ msgstr "Дата отзыва" #: /var/calculate/mydir/git/calculate-console/console/application/cert_verify.py:98 #: /var/calculate/mydir/git/calculate-console/console/application/cert_verify.py:103 -#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:281 +#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:282 #, python-format msgid "error creating directory %s" msgstr "Ошибка при создании директории %s" -#: /var/calculate/mydir/git/calculate-console/console/application/cert_verify.py:181 +#: /var/calculate/mydir/git/calculate-console/console/application/cert_verify.py:182 msgid "CRL add" msgstr "CRL добавлен" -#: /var/calculate/mydir/git/calculate-console/console/application/cert_verify.py:273 +#: /var/calculate/mydir/git/calculate-console/console/application/cert_verify.py:274 msgid "CA certificate delete from user trusted certificate" msgstr "Сертификат Центра Авторизации удалён из пользовательского списка доверенных сертификатов" -#: /var/calculate/mydir/git/calculate-console/console/application/cert_verify.py:292 +#: /var/calculate/mydir/git/calculate-console/console/application/cert_verify.py:293 msgid "CA certificate delete from system trusted certificate" msgstr "Сертификат Центра Авторизации удалён из системного списка доверенных сертификатов" @@ -174,50 +175,50 @@ msgstr "Город: " msgid "Country (2 words): [%s]" msgstr "Страна (2 символа): [%s]" -#: /var/calculate/mydir/git/calculate-console/console/application/function.py:55 +#: /var/calculate/mydir/git/calculate-console/console/application/function.py:59 msgid "Clear Cache error! " msgstr "Ошибка очистки кэша!" -#: /var/calculate/mydir/git/calculate-console/console/application/function.py:135 -#: /var/calculate/mydir/git/calculate-console/console/application/function.py:169 +#: /var/calculate/mydir/git/calculate-console/console/application/function.py:139 +#: /var/calculate/mydir/git/calculate-console/console/application/function.py:173 msgid "yes" msgstr "да" -#: /var/calculate/mydir/git/calculate-console/console/application/function.py:137 -#: /var/calculate/mydir/git/calculate-console/console/application/function.py:171 +#: /var/calculate/mydir/git/calculate-console/console/application/function.py:141 +#: /var/calculate/mydir/git/calculate-console/console/application/function.py:175 msgid "no" msgstr "нет" -#: /var/calculate/mydir/git/calculate-console/console/application/function.py:139 -#: /var/calculate/mydir/git/calculate-console/console/application/function.py:173 +#: /var/calculate/mydir/git/calculate-console/console/application/function.py:143 +#: /var/calculate/mydir/git/calculate-console/console/application/function.py:177 msgid "auto" msgstr "авто" -#: /var/calculate/mydir/git/calculate-console/console/application/function.py:192 +#: /var/calculate/mydir/git/calculate-console/console/application/function.py:196 msgid "Not used" msgstr "Не используется" -#: /var/calculate/mydir/git/calculate-console/console/application/function.py:291 +#: /var/calculate/mydir/git/calculate-console/console/application/function.py:295 msgid "Error" msgstr "Ошибка" -#: /var/calculate/mydir/git/calculate-console/console/application/function.py:297 +#: /var/calculate/mydir/git/calculate-console/console/application/function.py:301 msgid "Warning" msgstr "Предепреждение" -#: /var/calculate/mydir/git/calculate-console/console/application/function.py:334 +#: /var/calculate/mydir/git/calculate-console/console/application/function.py:338 msgid "Method not found: " msgstr "Метод не найден: " -#: /var/calculate/mydir/git/calculate-console/console/application/function.py:366 +#: /var/calculate/mydir/git/calculate-console/console/application/function.py:370 msgid "server send pid = " msgstr "сервер послал идентификатор процесса = " -#: /var/calculate/mydir/git/calculate-console/console/application/function.py:456 +#: /var/calculate/mydir/git/calculate-console/console/application/function.py:460 msgid "Process not exist or not belong to your session" msgstr "Процесс не существует или принадлежит не вашей сессии" -#: /var/calculate/mydir/git/calculate-console/console/application/function.py:500 +#: /var/calculate/mydir/git/calculate-console/console/application/function.py:533 #, python-format msgid "Error task by %s" msgstr "Ошибка задачи на %s" @@ -235,23 +236,23 @@ msgstr "Процесс завершён" msgid "cannot create directory %s" msgstr "Не удалось создать директорию %s" -#: /var/calculate/mydir/git/calculate-console/console/application/cl_client.py:278 +#: /var/calculate/mydir/git/calculate-console/console/application/cl_client.py:279 #: /var/calculate/mydir/git/calculate-console/console/application/methods_func.py:88 msgid "Failed to connect" msgstr "Не удалось подключиться" -#: /var/calculate/mydir/git/calculate-console/console/application/cl_client.py:339 +#: /var/calculate/mydir/git/calculate-console/console/application/cl_client.py:341 msgid "Password is invalid" msgstr "Неверный пароль" -#: /var/calculate/mydir/git/calculate-console/console/application/cl_client.py:345 -#: /var/calculate/mydir/git/calculate-console/console/application/cl_client.py:362 +#: /var/calculate/mydir/git/calculate-console/console/application/cl_client.py:347 +#: /var/calculate/mydir/git/calculate-console/console/application/cl_client.py:365 msgid "Error: " msgstr "Ошибка: " -#: /var/calculate/mydir/git/calculate-console/console/application/cl_client.py:377 #: /var/calculate/mydir/git/calculate-console/console/application/cl_client.py:380 -#: /var/calculate/mydir/git/calculate-console/console/application/cl_client.py:382 +#: /var/calculate/mydir/git/calculate-console/console/application/cl_client.py:383 +#: /var/calculate/mydir/git/calculate-console/console/application/cl_client.py:385 #, python-format msgid "Exception: %s" msgstr "Исключение: %s" @@ -492,12 +493,12 @@ msgid "Send new request? y/[n]: " msgstr "Отправить навый запрос на подпись сертификата? y/[n]: " #: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:132 -#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:181 +#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:182 msgid "connect..." msgstr "подключение..." #: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:138 -#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:188 +#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:189 msgid "Close. Connecting Error." msgstr "Ошибка соединения. Закрываюсь." @@ -506,71 +507,71 @@ msgstr "Ошибка соединения. Закрываюсь." msgid "Error: %s" msgstr "Ошибка: %s" -#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:147 +#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:148 msgid "secret key and request exists" msgstr "секретный ключ и запрос на подпись сертификата созданы" -#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:148 +#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:149 msgid "Create new secret key and request? y/[n]: " msgstr "Создать новые Секретный Ключ и Запрос на подпись сертификата? y/[n]: " -#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:163 +#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:164 msgid "This server can not sign certificate!" msgstr "Сервер не подписал сертификат!" -#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:168 -#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:209 +#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:169 +#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:211 #, python-format msgid "Your request id = %s" msgstr "Номер Вашего запроса = %s" -#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:173 +#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:174 #, python-format msgid "request was not sent or deleted file %s" msgstr "Запрос не был послан или удалён файл %s" -#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:193 +#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:195 #, python-format msgid "Request %s not found on client side" msgstr "Запрос %s не найден на стороне клиента" -#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:205 +#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:207 msgid "Request to sign is rejected!" msgstr "Запрос на подпись сертификата отвергнут!" -#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:208 +#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:210 msgid "Request for the signing has not yet reviewed." msgstr "Запрос на подписание сертификата ещё не рассмотрен." -#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:212 +#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:214 msgid "Request on signature does not match sent earlier." msgstr "Запрос или подпись не соответствуют отправленным ранее." -#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:215 +#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:217 msgid "Request was sent from another ip." msgstr "Запрос был послан с другого адреса." -#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:282 +#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:284 #: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:166 msgid "Not found field \"CN\" in certificate!" msgstr "Не найдено поле \"CN\" в сертификате!" -#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:295 +#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:297 #: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:176 msgid "filename = " msgstr "Имя файла =" -#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:296 +#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:298 #: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:177 msgid "CERTIFICATE ADD" msgstr "Сертификат добавлен" -#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:298 +#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:300 #: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:179 msgid "file with ca certificates exists" msgstr "Файл с сертификатом удостоверяющего центра создан" -#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:310 +#: /var/calculate/mydir/git/calculate-console/console/application/cert_func.py:312 msgid "You do not have a certificate. Use key --gen-cert-by HOST for generate new request or key --get-cert-from HOST for get new certificate from server." msgstr "У Вас нет сертификата. Используйте ключ --gen-cert-by HOST для генерации запроса на сертитфикат или ключ --get-cert-from HOST чтобы забрать сертификат с сервера." @@ -582,68 +583,68 @@ msgstr "Сертификат не найден на стороне клиент msgid "Error open file" msgstr "Ошибка при открытии файла" -#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:188 +#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:189 msgid "Server certificate is not valid" msgstr "Сертификат сервера недействителен!" -#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:192 +#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:193 msgid "CA not found on server" msgstr "Сертификат Центра Авторизации не найден на сервере" -#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:199 +#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:200 msgid "Error. Certificate not added to trusted" msgstr "Ошибка! Сертификат не добавлен в доверенные" -#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:201 -#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:223 +#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:202 +#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:224 #, python-format msgid "Fingerprint = %s" msgstr "Отпечаток = %s" -#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:202 -#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:224 +#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:203 +#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:225 msgid "Serial Number = " msgstr "Серийный номер = " -#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:204 -#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:226 +#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:205 +#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:227 msgid "Issuer" msgstr "Подписчик" -#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:208 -#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:230 +#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:209 +#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:231 msgid "Subject" msgstr "Субъект" -#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:211 +#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:212 msgid "Add CA certificates to trusted? y/[n]:" msgstr "Добавить сертификат Центра Авторизации в доверенные? y/[n]:" -#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:216 +#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:217 msgid "Certificate not added to trusted" msgstr "Сертификат не добавлен в доверенные" -#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:220 +#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:221 msgid "Untrusted Server Certificate!" msgstr "Недоверенный сертификат сервера!" -#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:234 +#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:235 msgid "Add this Servers certificate to trusted (s) or" msgstr "Добавить сертификат этого сервера в доверенные (s) или" -#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:235 +#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:236 msgid "Try add CA and ROOT certificates to trusted (c) or" msgstr "Попытаться добавить сертификат ЦА и корневой в доверенные (c) или" -#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:236 +#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:237 msgid "Quit (q)? s/c/[q]: " msgstr "Выйти (q)? s/c/[q]: " -#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:284 +#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:285 msgid "Try add CA and ROOT certificates" msgstr "Добавить Корневой и сертификат ЦА" -#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:409 +#: /var/calculate/mydir/git/calculate-console/console/application/client_class.py:410 msgid "This server is not trusted" msgstr "Сервер не является доверенным"