Changeset 192 for etherws/trunk
- Timestamp:
- 07/31/12 00:21:01 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
etherws/trunk/etherws.py
r191 r192 521 521 except Exception as e: 522 522 traceback.print_exc() 523 self.finish({'result': None, 'error': {'msg': str(e)}, 'id': id_}) 523 msg = '%s: %s' % (e.__class__.__name__, str(e)) 524 self.finish({'result': None, 'error': {'message': msg}, 'id': id_}) 524 525 525 526 def handle_listPort(self, params): … … 738 739 } 739 740 }] 740 res = request(args, 'addPort', params) 741 print(yaml.safe_dump(res)) 741 return request(args, 'addPort', params) 742 742 743 743 def handle_ctl_shutport(args): 744 744 if args.port <= 0: 745 745 raise ValueError('invalid port: %d' % args.port) 746 res = request(args, 'shutPort', [{'port': args.port, 'shut': args.no}])747 print(yaml.safe_dump(res))746 params = [{'port': args.port, 'shut': args.no}] 747 return request(args, 'shutPort', params) 748 748 749 749 def handle_ctl_delport(args): 750 750 if args.port <= 0: 751 751 raise ValueError('invalid port: %d' % args.port) 752 res = request(args, 'delPort', [{'port': args.port}])753 print(yaml.safe_dump(res))752 params = [{'port': args.port}] 753 return request(args, 'delPort', params) 754 754 755 755 def handle_ctl_listport(args): 756 res = request(args, 'listPort', []) 757 print(yaml.safe_dump(res)) 758 759 locals()['handle_ctl_' + args.control_method](args) 756 return request(args, 'listPort', []) 757 758 res = locals()['handle_ctl_' + args.control_method](args) 759 760 if res['error']: 761 print(res['error']['message']) 762 else: 763 print(yaml.safe_dump(res['result']['portlist']).strip()) 760 764 761 765
Note: See TracChangeset
for help on using the changeset viewer.