From 392441d3a21f89859c544086dbd854c401d4fd14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B0=D0=BC=D0=BE=D1=83=D0=BA=D0=B8=D0=BD=20=D0=90?= =?UTF-8?q?=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= Date: Fri, 16 Jul 2010 08:59:00 +0400 Subject: [PATCH] Bugfix --- pym/cl_utils.py | 34 ++++++++++++++++++++++++++++++++++ pym/server/share.py | 4 +++- pym/server/users.py | 29 ----------------------------- 3 files changed, 37 insertions(+), 30 deletions(-) diff --git a/pym/cl_utils.py b/pym/cl_utils.py index 0bf5c8e..8f1cd1a 100644 --- a/pym/cl_utils.py +++ b/pym/cl_utils.py @@ -25,6 +25,13 @@ from shutil import copytree, rmtree import ctypes import cl_overriding import re +import sys +import getpass + +import cl_lang +tr = cl_lang.lang() +tr.setLocalDomain('cl_lib') +tr.setLanguage(sys.modules[__name__]) class _error: # Здесь ошибки, если они есть @@ -413,3 +420,30 @@ def pathJoin(*paths): map(lambda x: x.startswith("/") and x[1:] or x, paths[1:]),'')) + +def getUserPassword(flag="dialog", pwDialog=False): + """Получить пароль у пользователя + + flag - опция "dalog" или "stdin" - откуда получаем пароль + pwDialog - структура для вывода приглашения в режиме диалога + """ + userPwd = "" + if flag == "dialog": + if not pwDialog: + pwDialog = [_("New password"), + _("Retype new password")] + pwdA = getpass.getpass(pwDialog[0]+":") + pwdB = getpass.getpass(pwDialog[1]+":") + elif flag == "stdin": + pwdA = sys.stdin.readline().rstrip() + pwdB = sys.stdin.readline().rstrip() + else: + cl_overriding.printERROR(_("ERROR in function getUserPassword, \ +incorrect option 'flag=%s'")%flag) + return False + if not pwdA or not (pwdA == pwdB): + cl_overriding.printERROR(_("ERROR") + ": " +\ + _("password incorrect")+ ": " + _("try again")) + return False + userPwd = pwdA + return userPwd \ No newline at end of file diff --git a/pym/server/share.py b/pym/server/share.py index b487c66..d116dab 100644 --- a/pym/server/share.py +++ b/pym/server/share.py @@ -14,7 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cl_data import DataVars +import sys + +from cl_datavars import DataVars from cl_print import color_print # Перевод модуля import cl_lang diff --git a/pym/server/users.py b/pym/server/users.py index 64cfbf1..2d3305e 100644 --- a/pym/server/users.py +++ b/pym/server/users.py @@ -328,32 +328,3 @@ in a sambaDomainName', if you want to continue to run the program again")) return False return isCorrectStringNet(strNet) - - def getUserPassword(self, options, optDialog, optStdIn, pwDialog=False): - """Получить пароль у пользователя - - options - полученные опции командной строки - optDialog - опция командной строки для вывода диалога для получения - пароля - optStdIn - опция командной строки для получения пароля из - стандартного ввода (stdin) - pwDialog - структура для вывода приглашения в режиме диалога - """ - userPwd = "" - if optStdIn and options.has_key(optStdIn): - pwdA = sys.stdin.readline().rstrip() - pwdB = sys.stdin.readline().rstrip() - elif optDialog and options.has_key(optDialog): - if not pwDialog: - pwDialog = [_("New password"), - _("Retype new password")] - pwdA = getpass.getpass(pwDialog[0]+":") - pwdB = getpass.getpass(pwDialog[1]+":") - if (optStdIn and options.has_key(optStdIn)) or\ - (optDialog and options.has_key(optDialog)): - if not pwdA or not (pwdA == pwdB): - self.printERROR (_("ERROR") + ": " +\ - _("password incorrect")+ ": " + _("try again")) - return False - userPwd = pwdA - return userPwd \ No newline at end of file