modified error handling

develop
Спиридонов Денис 12 years ago
parent c44ea9b949
commit ebb93a6fe9

@ -376,9 +376,9 @@ def get_message(client, item, sid, pid):
if case('normal'):
# sys.stdout.flush()
# sys.stdout.write('\x1b[1;33m' + item.message + '\033[0m')
p = re.compile(r'<b>|</b>')
print p.sub('', item.message)
if item.message:
p = re.compile(r'<b>|</b>')
print p.sub('', item.message)
# print item.message
return 1
if case('progress'):

@ -94,7 +94,6 @@ def get_method_argparser(client, args):
def call_method(client, args):
method = args.method
method_parser, view = get_method_argparser(client, args)
param_object = _create_obj(client, method)
args = method_parser.parse_known_args()[0]
@ -104,6 +103,9 @@ def call_method(client, args):
param_object['CheckOnly'] = True
# print param_object
method_result = client.service[0][method](client.sid, param_object)
if not method_result:
print _('method is not available')
return None
if method_result.ReturnedMessage[0].type and \
method_result.ReturnedMessage[0].type != "pid":
for error in method_result.ReturnedMessage:
@ -130,6 +132,16 @@ def call_method(client, args):
param_object['CheckOnly'] = False
method_result = client.service[0][method](client.sid, param_object)
if not method_result:
print _('method is not available')
return None
if method_result.ReturnedMessage[0].type and \
method_result.ReturnedMessage[0].type != "pid":
for error in method_result.ReturnedMessage:
red = '\033[91m * \033[0m'
print red + error.message
return None
return method_result
def _getattr(obj, attr):
@ -141,6 +153,8 @@ def collect_object(client, param_object, view, args):
if not Group.fields:
continue
for field in Group.fields.Field:
if field.uncompatible:
continue
if field.element in ['check', 'check_tristate'] or \
field.element == 'radio' and field.type == 'bool':
param_object[field.name] = _getattr(args, field.name)

Loading…
Cancel
Save