add collect password in table

develop
Спиридонов Денис 12 years ago
parent 85ecd871bb
commit 239263d6ed

@ -99,13 +99,17 @@ def delete_old_cert(client):
os.unlink(client.PKEY_FILE)
os.unlink(client.PubKEY_FILE)
def get_password():
def get_password(text1 = None, text2 = None):
if not text1:
text1 = _('Password: ')
if not text2:
text2 = _('Repeat: ')
try:
pass1 = 'password'
pass2 = 'repeat'
while pass1 != pass2:
pass1 = getpass.getpass(_('Password: '))
pass2 = getpass.getpass(_('Repeat: '))
pass1 = getpass.getpass(text1)
pass2 = getpass.getpass(text2)
if pass1 != pass2:
print _('Passwords do not match')
except KeyboardInterrupt:

@ -20,6 +20,7 @@ from function import listToArray, listToArrayArray, _create_obj, \
from calculate.lib.cl_lang import setLocalTranslate
setLocalTranslate('calculate_console',sys.modules[__name__])
import urllib2
from cert_func import get_password
def get_view(client, method, sid, view_params):
try:
@ -105,7 +106,6 @@ def call_method(client, args):
method_result = client.service[0][method](client.sid, param_object)
if method_result.ReturnedMessage[0].type and \
method_result.ReturnedMessage[0].type != "pid":
print method_result
for error in method_result.ReturnedMessage:
red = '\033[31m * \033[0m'
print red + error.message
@ -126,7 +126,7 @@ def call_method(client, args):
return None
if ask.lower() in ['y', 'yes']:
break
param_object['CheckOnly'] = False
method_result = client.service[0][method](client.sid, param_object)
@ -153,7 +153,7 @@ def collect_object(client, param_object, view, args):
param_object[field.name] = val
elif field.element in ['input', 'combo', 'comboEdit', 'openfile',\
'file', 'password', 'radio']:
'file', 'password', 'radio']:
param_object[field.name] = _getattr(args, field.name)
elif field.element in ['multichoice', 'multichoice_add', \
'selecttable', 'selecttable_add']:
@ -191,13 +191,15 @@ def collect_table(field, val_list, client):
column = len(field.tablevalue.head.string)
ChoiceValue = field.tablevalue.values.ChoiceValue
# result_table = []
type_list = map(lambda x: x.typefield, ChoiceValue)
for i in range(len(val_table)):
if 'password' in type_list:
if len(val_table[i]) != 2 or val_table[i][1].lower() != '':
password=get_password(_('Password for %s: ')%val_table[i][0],\
_('Repeat password for %s: ') %val_table[i][0])
password = password if password else ''
temp_row = []
# print 'val_table[i] = ',val_table[i]
empty_row_flag = True if len (val_table[i]) == 1 else False
# print 'empty_row_flag = ',empty_row_flag
for j in range(column):
# not adding if readonly
if j > (len(ChoiceValue) + 1):
@ -219,11 +221,20 @@ def collect_table(field, val_list, client):
temp_row.append(val_table[i][j])
elif typefield in ['input', 'combo', 'comboEdit', 'openfile', \
'file', 'password', 'radio']:
'file', 'radio']:
if len (val_table[i]) < j + 1:
temp_row.append('')
else:
temp_row.append(val_table[i][j])
elif typefield == 'password':
if 'password' in locals():
temp_row.append(password)
del password
else:
if len (val_table[i]) < j + 1:
temp_row.append('')
else:
temp_row.append(val_table[i][j])
elif typefield in ['multichoice', 'multichoice_add']:
if len (val_table[i]) < j + 1:
temp_row.append('')

Loading…
Cancel
Save