Changeset 205
- Timestamp:
- 08/03/12 01:11:35 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
etherws/trunk/etherws.py
r204 r205 642 642 643 643 644 def print_error(error): 645 print(' %s (%s)' % (error['message'], error['code'])) 646 print(' %s' % error['data']) 647 648 644 649 def start_sw(args): 645 650 def daemonize(nochdir=False, noclose=False): … … 811 816 (r['port'], r['type'], shut, r['rx'], r['tx'], r['target'])) 812 817 813 def print_error(error):814 print(' %s (%s)' % (error['message'], error['code']))815 print(' %s' % error['data'])816 817 818 def handle_ctl_addport(args): 819 opts = { 820 'user': getattr(args, 'user', None), 821 'passwd': getattr(args, 'passwd', None), 822 'cacerts': getattr(args, 'cacerts', None), 823 'insecure': getattr(args, 'insecure', None), 824 } 825 if args.iftype == EtherWebSocketClient.IFTYPE: 826 if not args.target.startswith('ws://') and \ 827 not args.target.startswith('wss://'): 828 raise ValueError('Invalid target URL scheme: %s' % args.target) 829 if opts['user'] and not opts['passwd']: 830 raise ValueError('Authentication required but password empty') 831 if not opts['user'] and opts['passwd']: 832 raise ValueError('Authentication required but username empty') 818 833 result = request(args, 'addPort', { 819 834 'type': args.iftype, 820 835 'target': args.target, 821 'options': { 822 'user': getattr(args, 'user', None), 823 'passwd': getattr(args, 'passwd', None), 824 'cacerts': getattr(args, 'cacerts', None), 825 'insecure': getattr(args, 'insecure', None), 826 }, 836 'options': opts, 827 837 }) 828 838 if 'error' in result: … … 944 954 # -- go 945 955 args = parser.parse_args() 946 globals()['start_' + args.subcommand](args) 956 957 try: 958 globals()['start_' + args.subcommand](args) 959 except Exception as e: 960 print_error({ 961 'code': 0 - 32603, 962 'message': 'Internal error', 963 'data': '%s: %s' % (e.__class__.__name__, str(e)), 964 }) 947 965 948 966
Note: See TracChangeset
for help on using the changeset viewer.