{ "metadata": { "name": "", "signature": "sha256:67e9ee532e8913469d28896c3f7580744d14963fb076278e4793a3afec67256c" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "!pip install socketIO-client" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Downloading/unpacking socketIO-client\r\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ " Downloading socketIO-client-0.5.3.tar.gz\r\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ " Running setup.py (path:/private/var/folders/_4/zgq072js02l52sty2qmssbxm0000gn/T/pip_build_brian/socketIO-client/setup.py) egg_info for package socketIO-client\r\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ " \r\n", " warning: no previously-included files matching '*.pyc' found anywhere in distribution\r\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "Requirement already satisfied (use --upgrade to upgrade): requests in ./anaconda/lib/python2.7/site-packages (from socketIO-client)\r\n", "Requirement already satisfied (use --upgrade to upgrade): six in ./anaconda/lib/python2.7/site-packages (from socketIO-client)\r\n", "Downloading/unpacking websocket-client (from socketIO-client)\r\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ " Downloading websocket-client-0.14.1.tar.gz (189kB): \r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 2% 4.1kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 4% 8.2kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 6% 12kB " ] }, { "output_type": "stream", "stream": "stdout", "text": [ "\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 8% 16kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 10% 20kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 12% 24kB" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 15% 28kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 17% 32kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 19% 36kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 21% 40kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 23% 45kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 25% 49kB" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 28% 53kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 30% 57kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 32% 61kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 34% 65kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 36% 69kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 38% 73kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 41% 77kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 43% 81kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 45% 86kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 47% 90kB" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 49% 94kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 51% 98kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 53% 102kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 56% 106kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 58% 110kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 60% 114kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 62% 118kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 64% 122kB" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 66% 126kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 69% 131kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 71% 135kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 73% 139kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 75% 143kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 77% 147kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 79% 151kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 82% 155kB" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 84% 159kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 86% 163kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 88% 167kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 90% 172kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 92% 176kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 94% 180kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 97% 184kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 99% 188kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 100% 189kB\r", " Downloading websocket-client-0.14.1.tar.gz (189kB): \r", " Downloading websocket-client-0.14.1.tar.gz (189kB): 189kB downloaded\r\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ " Running setup.py (path:/private/var/folders/_4/zgq072js02l52sty2qmssbxm0000gn/T/pip_build_brian/websocket-client/setup.py) egg_info for package websocket-client\r\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ " \r\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "Requirement already satisfied (use --upgrade to upgrade): backports.ssl-match-hostname in ./anaconda/lib/python2.7/site-packages (from websocket-client->socketIO-client)\r\n", "Installing collected packages: socketIO-client, websocket-client\r\n", " Running setup.py install for socketIO-client\r\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ " \r\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ " warning: no previously-included files matching '*.pyc' found anywhere in distribution\r\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ " Running setup.py install for websocket-client\r\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ " changing mode of build/scripts-2.7/wsdump.py from 644 to 755\r\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ " \r\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ " changing mode of /Users/brian/anaconda/bin/wsdump.py to 755\r\n", "Successfully installed socketIO-client websocket-client\r\n", "Cleaning up...\r\n" ] } ], "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [ "#setup listeners\n", "from socketIO_client import SocketIO, BaseNamespace\n", " \n", "class Namespace(BaseNamespace):\n", " \n", " def on_connect(self):\n", " print '[Connected]'\n", " \n", "def on_data_response(*args):\n", " print 'navdata', args\n", " \n", "def on_status_response(*args):\n", " print 'status ', args\n", " \n", "socketIO = SocketIO('192.168.1.13', 8080, Namespace)\n", " \n", "# sent by OpenROVController.js\n", "# 'navdata' at 10 per sec\n", "#socketIO.on('navdata', on_data_response)\n", " \n", "# 'status' at 1 per second (includes navdata)\n", "socketIO.on('status', on_status_response)\n", "\n", "#socketIO.wait()" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 9 }, { "cell_type": "code", "collapsed": false, "input": [ "# Turn lights on\n", "socketIO.emit('brightness_update',1)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 11 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 8 }, { "cell_type": "code", "collapsed": false, "input": [ "# Turn lights off\n", "socketIO.emit('brightness_update',0)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 12 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }