|
|
|
@ -89,15 +89,9 @@ def get_method_argparser(client, args):
|
|
|
|
|
return parser, view
|
|
|
|
|
|
|
|
|
|
def call_method(client, args):
|
|
|
|
|
print 'call_method'
|
|
|
|
|
method = args.method
|
|
|
|
|
# view_params = get_view_params(client, method + '_view', step = None, \
|
|
|
|
|
# expert = True)
|
|
|
|
|
#
|
|
|
|
|
# view = get_view(client, method, client.sid, view_params)
|
|
|
|
|
|
|
|
|
|
method_parser, view = get_method_argparser(client, args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
param_object = _create_obj(client, method)
|
|
|
|
|
args = method_parser.parse_known_args()[0]
|
|
|
|
|
|
|
|
|
@ -105,14 +99,25 @@ def call_method(client, args):
|
|
|
|
|
|
|
|
|
|
if steps.label and hasattr (param_object, 'CheckOnly'):
|
|
|
|
|
param_object['CheckOnly'] = True
|
|
|
|
|
# print param_object
|
|
|
|
|
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
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
view_params = get_view_params(client, method + '_view', step = None, \
|
|
|
|
|
expert = True, brief = True)
|
|
|
|
|
view = get_view(client, method, client.sid, view_params)
|
|
|
|
|
print_brief(view, steps.label)
|
|
|
|
|
while True:
|
|
|
|
|
ask = raw_input('\n'+_('Run process? (yes/no): '))
|
|
|
|
|
try:
|
|
|
|
|
ask = raw_input('\n'+_('Run process? (yes/no): '))
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
ask = 'no'
|
|
|
|
|
if ask.lower() in ['n', 'no']:
|
|
|
|
|
red = '\033[31m * \033[0m'
|
|
|
|
|
print red + _('Interrupted by user')
|
|
|
|
@ -169,13 +174,27 @@ def collect_table(field, val_list, client):
|
|
|
|
|
if not val_list:
|
|
|
|
|
return None
|
|
|
|
|
val_table = map(lambda x: x.split(':'), val_list)
|
|
|
|
|
|
|
|
|
|
obj_body = []
|
|
|
|
|
key_list = []
|
|
|
|
|
if hasattr (field.tablevalue.body, 'stringArray'):
|
|
|
|
|
for obj_row in field.tablevalue.body.stringArray:
|
|
|
|
|
if hasattr(obj_row, 'string'):
|
|
|
|
|
key_list.append(obj_row.string[0])
|
|
|
|
|
obj_body.append(obj_row.string)
|
|
|
|
|
|
|
|
|
|
obj_body = collect_obj_body(obj_body, field)
|
|
|
|
|
|
|
|
|
|
column = len(field.tablevalue.head.string)
|
|
|
|
|
|
|
|
|
|
ChoiceValue = field.tablevalue.values.ChoiceValue
|
|
|
|
|
result_table = []
|
|
|
|
|
# result_table = []
|
|
|
|
|
|
|
|
|
|
for i in range(len(val_table)):
|
|
|
|
|
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):
|
|
|
|
@ -207,6 +226,71 @@ def collect_table(field, val_list, client):
|
|
|
|
|
temp_row.append('')
|
|
|
|
|
else:
|
|
|
|
|
temp_row.append(val_table[i][j])
|
|
|
|
|
result_table.append(temp_row)
|
|
|
|
|
|
|
|
|
|
return listToArrayArray(client, result_table)
|
|
|
|
|
if temp_row[0] in key_list:
|
|
|
|
|
ind = key_list.index(temp_row[0])
|
|
|
|
|
|
|
|
|
|
count_val = filter (None, temp_row)
|
|
|
|
|
if (len(count_val) == 1 and not empty_row_flag) or \
|
|
|
|
|
(len(count_val) == 2 and temp_row[1].lower() == 'none'):
|
|
|
|
|
obj_body.pop(ind)
|
|
|
|
|
key_list.pop(ind)
|
|
|
|
|
else:
|
|
|
|
|
obj_body.pop(ind)
|
|
|
|
|
obj_body.insert(ind, temp_row)
|
|
|
|
|
else:
|
|
|
|
|
count_val = filter (None, temp_row)
|
|
|
|
|
if (len(count_val) == 1 and not empty_row_flag) or \
|
|
|
|
|
(len(count_val) == 2 and temp_row[1].lower() == 'none'):
|
|
|
|
|
continue
|
|
|
|
|
obj_body.append(temp_row)
|
|
|
|
|
key_list.append(temp_row[0])
|
|
|
|
|
|
|
|
|
|
return listToArrayArray(client, obj_body)
|
|
|
|
|
|
|
|
|
|
def collect_obj_body(body, field):
|
|
|
|
|
column = len(field.tablevalue.head.string)
|
|
|
|
|
ChoiceValue = field.tablevalue.values.ChoiceValue
|
|
|
|
|
result_table = []
|
|
|
|
|
for i in range(len(body)):
|
|
|
|
|
temp_row = []
|
|
|
|
|
for j in range(column):
|
|
|
|
|
# not adding if readonly
|
|
|
|
|
if j > (len(ChoiceValue) + 1):
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
choice_value = ChoiceValue[j]
|
|
|
|
|
typefield = choice_value.typefield
|
|
|
|
|
if typefield == 'readonly':
|
|
|
|
|
continue
|
|
|
|
|
elif typefield in ['check', 'check_tristate']:
|
|
|
|
|
if len (body[i]) < j + 1:
|
|
|
|
|
temp_row.append('')
|
|
|
|
|
continue
|
|
|
|
|
if not body[i][j]:
|
|
|
|
|
temp_row.append('')
|
|
|
|
|
elif body[i][j].lower() in ['on', 'yes']:
|
|
|
|
|
temp_row.append('on')
|
|
|
|
|
elif body[i][j].lower() in ['off', 'no']:
|
|
|
|
|
temp_row.append('off')
|
|
|
|
|
else:
|
|
|
|
|
temp_row.append(body[i][j])
|
|
|
|
|
|
|
|
|
|
elif typefield in ['input', 'combo', 'comboEdit', 'openfile', \
|
|
|
|
|
'file', 'password', 'radio']:
|
|
|
|
|
if len (body[i]) < j + 1:
|
|
|
|
|
temp_row.append('')
|
|
|
|
|
elif not body[i][j]:
|
|
|
|
|
temp_row.append('')
|
|
|
|
|
else:
|
|
|
|
|
temp_row.append(body[i][j])
|
|
|
|
|
elif typefield in ['multichoice', 'multichoice_add']:
|
|
|
|
|
if len (body[i]) < j + 1:
|
|
|
|
|
temp_row.append('')
|
|
|
|
|
elif not body[i][j]:
|
|
|
|
|
temp_row.append('')
|
|
|
|
|
else:
|
|
|
|
|
temp_row.append(body[i][j])
|
|
|
|
|
|
|
|
|
|
result_table.append(temp_row)
|
|
|
|
|
return result_table
|