Search Results

Search found 14486 results on 580 pages for 'python idle'.

Page 52/580 | < Previous Page | 48 49 50 51 52 53 54 55 56 57 58 59  | Next Page >

  • python Socket.IO client for sending broadcast messages to TornadIO2 server

    - by Alp
    I am building a realtime web application. I want to be able to send broadcast messages from the server-side implementation of my python application. Here is the setup: socketio.js on the client-side TornadIO2 server as Socket.IO server python on the server-side (Django framework) I can succesfully send socket.io messages from the client to the server. The server handles these and can send a response. In the following i will describe how i did that. Current Setup and Code First, we need to define a Connection which handles socket.io events: class BaseConnection(tornadio2.SocketConnection): def on_message(self, message): pass # will be run if client uses socket.emit('connect', username) @event def connect(self, username): # send answer to client which will be handled by socket.on('log', function) self.emit('log', 'hello ' + username) Starting the server is done by a Django management custom method: class Command(BaseCommand): args = '' help = 'Starts the TornadIO2 server for handling socket.io connections' def handle(self, *args, **kwargs): autoreload.main(self.run, args, kwargs) def run(self, *args, **kwargs): port = settings.SOCKETIO_PORT router = tornadio2.TornadioRouter(BaseConnection) application = tornado.web.Application( router.urls, socket_io_port = port ) print 'Starting socket.io server on port %s' % port server = SocketServer(application) Very well, the server runs now. Let's add the client code: <script type="text/javascript"> var sio = io.connect('localhost:9000'); sio.on('connect', function(data) { console.log('connected'); sio.emit('connect', '{{ user.username }}'); }); sio.on('log', function(data) { console.log("log: " + data); }); </script> Obviously, {{ user.username }} will be replaced by the username of the currently logged in user, in this example the username is "alp". Now, every time the page gets refreshed, the console output is: connected log: hello alp Therefore, invoking messages and sending responses works. But now comes the tricky part. Problems The response "hello alp" is sent only to the invoker of the socket.io message. I want to broadcast a message to all connected clients, so that they can be informed in realtime if a new user joins the party (for example in a chat application). So, here are my questions: How can i send a broadcast message to all connected clients? How can i send a broadcast message to multiple connected clients that are subscribed on a specific channel? How can i send a broadcast message anywhere in my python code (outside of the BaseConnection class)? Would this require some sort of Socket.IO client for python or is this builtin with TornadIO2? All these broadcasts should be done in a reliable way, so i guess websockets are the best choice. But i am open to all good solutions.

    Read the article

  • Call macro from Python script?

    - by Eric
    One of our page templates is made up of a bunch of macros. These items are a bunch of html tables. Now, I want a couple of these tables in a Python script to create a PDF. Is there a way call a macro from a Python script and get back the HTML that is produced? If so, can you explain? Thanks Eric

    Read the article

  • svg diagrams using python

    - by Zitrax
    I am looking for a library to generate svg diagrams in python (I fetch data from a sql database). I have found python-gd, but it has not much documentation and last update was in 2005 so I wonder if there are any other libraries that are good for this purpose. I am mostly thinking about simple line graphs, something like this:

    Read the article

  • Python invalid syntax with "with" statement

    - by mrlanrat
    Hello all, I am working on writing a simple python application for linux (maemo). However I am getting SyntaxError: invalid syntax on line 23: with open(file,'w') as fileh: The code can be seen here: http://pastebin.com/MPxfrsAp I can not figure out what is wrong with my code, I am new to python and the "with" statement. So, what is causing this code to error, and how can I fix it? Is it something wrong with the "with" statement? Thanks!

    Read the article

  • Python Mindstorms RCX

    - by Kyle Schmidt
    I've got 30 unopened Lego Mindstorms kits that I'd love to use in my intro programming class to do some simple robotics stuff at the end of the year. We're using Python in the class, so I'd prefer there to be a way for the kids to write the programs in Python. Unfortunately, these are old kits with RCX bricks - not the newer NXT ones, so most of the projects like NXT_Python can't help me. Is there any way to make that happen?

    Read the article

  • midi input in python

    - by Nicola Montecchio
    Hello I'm coding a demo in python and I need to read a MIDI file in python (no real-time stuff is needed). In particular, I'm looking for a library which preserves channel information. The most promising libraries I found are: http://code.google.com/p/midiutil/ http://www.mxm.dk/products/public/pythonmidi Any experience with those? Thanks a lot Nicola Montecchio

    Read the article

  • Python code translation to JVM

    - by jldupont
    Is there such a thing as a "translator" (for lack of a better word in my mind now) that translates Python code directly to JVM / Dalvik bytecode? Would be great for writing Android applications in Python! NOTE: I know about the scripting capabilities of the Android platform but I am looking for something that would generate a '.apk' without having to install the 'scripting' package... annoying for end-users.

    Read the article

  • Python editor with automatic code completion?

    - by netvope
    I have seen various articles about good Python editors/IDEs, like this. However, none of them points out whether the editors support automatic code completion. I tried notepad++, PyScript and Komodo Edit, but all of these requires a hotkey to invoke the code completion dialog. Do you know any Python editors with automatic code completion?

    Read the article

  • Run python file -- what function is main?

    - by Jasie
    I have simple python script, 'first.py': #first.py def firstFunctionEver() : print "hello" firstFunctionEver() I want to call this script using : python first.py and have it call the firstFunctionEver(). But, the script is ugly -- what function can I put the call to firstFunctionEver() in and have it run when the script is loaded?

    Read the article

  • Python - drag file into .exe to run script

    - by PPTim
    Hi, I have a Python script that takes the directory path of a text file and converts it into an excel file. Currently I have it running as a console application (compiled with py2exe) and prompts the user for the directory path through raw_input(). How do i make it such that I can drag & drop my text file directly into the .exe of the python script? Thanks,

    Read the article

  • Exit to command line in Python

    - by fuenfundachtzig
    I have a script that I want to exit early under some condition: if not "id" in dir(): print "id not set, cannot continue" # exit here! # otherwise continue with the rest of the script... print "alright..." [ more code ] I run this script using execfile("foo.py") from the Python interactive prompt and I would like the script to exit going back to the command line. How do I do this? If I use sys.exit(), the Python interpreter exits completely.

    Read the article

  • python: simple example for a python egg with a one-file source file?

    - by Jason S
    I'm not quite sure how to build a really simple one-file source module. Is there a sample module out there one the web somewhere which can be built as a python .egg? From the setuptools page it looks pretty simple, you just have your setup.py file and then at least one other .py file somewhere, and I can build an .egg file OK, and even install it using easy_install, but I can't seem to import the file from within python. (note: using 2.6.4)

    Read the article

  • pdftotext can't find any of the files to convert when called within a python script

    - by hatorade
    i have a python script which keeps crashing on: subprocess.call(["pdftotext", pdf_filename]) the error being: OSError: [Errno 2] No such file or directory the absolute path to the filename (which i am storing in a log file as i debug) is fine; on the command line, if i type pdftotext <pdf_filename_goes_here> it works for any of the alledgedly bad file names. but when called using subprocess in python i keep getting that error. what is going on???

    Read the article

  • Alternative to zc.buildout that runs on Python3

    - by srid
    My project uses buildout to do primarily two things: automatically fetch dependencies and create scripts; and setup cron jobs (on deployment machines) using the usercrontab buildout recipe. But buildout is not yet available for Python 3. So I would like to consider alternatives for buildout. I know that both virtualenv and pip work on Python 3 - but what is the preferred tool to automate the build toolchain (of creating virtualenv, and automatically installing/upgrading deps)? There is fabric, paver, and so on. What is your preferred tool of choice in this case? It must work seamlessly on both Windows and *nix.

    Read the article

  • Official multiple python versions on the same machine?

    - by drozzy
    Is there an official documentation on python website somewhere, on how to install and run multiple versions of python on the same machine? On linux? I can find gazillions of blog posts and answers - but I want to know if there is a "standard" official way of doing this? Or is this all dependent on OS?

    Read the article

  • Idiomatic Python: 'times' loop

    - by perimosocordiae
    Say I have a function foo that I want to call n times. In Ruby, I would write: n.times { foo } In Python, I could write: for _ in xrange(n): foo() But that seems like a hacky way of doing things. My question: Is there an idiomatic way of doing this in Python?

    Read the article

< Previous Page | 48 49 50 51 52 53 54 55 56 57 58 59  | Next Page >