Changeset 181 for etherws/trunk
- Timestamp:
- 07/27/12 01:08:30 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
etherws/trunk/etherws.py
r180 r181 349 349 350 350 class EtherWebSocketClient(DebugMixIn): 351 def __init__(self, ioloop, switch, url, cred=None, debug=False):351 def __init__(self, ioloop, switch, url, ssl_=None, cred=None, debug=False): 352 352 self._ioloop = ioloop 353 353 self._switch = switch 354 354 self._url = url 355 self._ssl = ssl_ 355 356 self._debug = debug 356 357 self._sock = None … … 367 368 368 369 def open(self): 370 sslwrap = websocket._SSLSocketWrapper 371 369 372 if not self.closed: 370 373 raise websocket.WebSocketException('already opened') 371 self._sock = websocket.WebSocket() 372 self._sock.connect(self._url, **self._options) 373 self._switch.register_port(self) 374 self._ioloop.add_handler(self.fileno(), self, self._ioloop.READ) 375 self.dprintf('connected: %s\n', lambda: self._url) 374 375 if self._ssl: 376 websocket._SSLSocketWrapper = self._ssl 377 378 try: 379 self._sock = websocket.WebSocket() 380 self._sock.connect(self._url, **self._options) 381 self._switch.register_port(self) 382 self._ioloop.add_handler(self.fileno(), self, self._ioloop.READ) 383 self.dprintf('connected: %s\n', lambda: self._url) 384 finally: 385 websocket._SSLSocketWrapper = sslwrap 376 386 377 387 def close(self): … … 474 484 ioloop = tornado.ioloop.IOLoop.instance() 475 485 fdb = FDB(ageout=args.ageout, debug=args.debug) 476 sw itch= SwitchingHub(fdb, debug=args.debug)477 478 harg = {'switch': sw itch, 'htpasswd': args.htpasswd, 'debug': args.debug}486 sw = SwitchingHub(fdb, debug=args.debug) 487 488 harg = {'switch': sw, 'htpasswd': args.htpasswd, 'debug': args.debug} 479 489 serv = (args.path, EtherWebSocketHandler, harg) 480 490 app = tornado.web.Application([serv]) … … 483 493 484 494 for dev in args.device: 485 tap = TapHandler(ioloop, sw itch, dev, debug=args.debug)495 tap = TapHandler(ioloop, sw, dev, debug=args.debug) 486 496 tap.open() 487 497 … … 504 514 args.passwd = getpass.getpass() 505 515 506 websocket._SSLSocketWrapper= ssl_wrapper(args.insecure, args.cacerts)516 ssl_ = ssl_wrapper(args.insecure, args.cacerts) 507 517 cred = {'user': args.user, 'passwd': args.passwd} 508 518 ioloop = tornado.ioloop.IOLoop.instance() 509 519 fdb = FDB(ageout=args.ageout, debug=args.debug) 510 sw itch= SwitchingHub(fdb, debug=args.debug)520 sw = SwitchingHub(fdb, debug=args.debug) 511 521 512 522 for uri in args.uri: 513 client = EtherWebSocketClient(ioloop, sw itch, uri, cred, args.debug)523 client = EtherWebSocketClient(ioloop, sw, uri, ssl_, cred, args.debug) 514 524 client.open() 515 525 516 526 for dev in args.device: 517 tap = TapHandler(ioloop, sw itch, dev, debug=args.debug)527 tap = TapHandler(ioloop, sw, dev, debug=args.debug) 518 528 tap.open() 519 529
Note: See TracChangeset
for help on using the changeset viewer.