Re: Which version of python I should use if I just start programming in python?
On Sat, 12 Sep 2009 20:25:47 -0700, Kee Nethery wrote: > I would prefer to be in 3.x because all the inconsistencies of how you > do things in 2.x make it harder than it needs to be to learn the > language. > > People who have been coding in 2.x for along time don't notice how the > syntax is wonky in places. Their fingers type the right stuff. As a > newbie I assume that everything works the same way and I am frequently > surprised. What inconsistencies surprise you? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Python and 3d
Has anyone any exipience with python and 3d. I mean, is there a module to deal with popular 3d formats like 3ds, or vrml. is it possible to import into python opengl models and then use it in application for GUI purposes like through WX. I know that WX supports OpenGL but how to import models from file. -- http://mail.python.org/mailman/listinfo/python-list
PyQT child forms
Hi everybody, I'm building my GUI app with PyQT and i'm quite new with it. I looked for example for managing a form and a child form. My goal is to run the main form and a certain button will open a child form. Whenever the child form will be open the main form will be disabled until the child form is closed. Moreover I would like to know how to pass data from the child form to the main form. Thank you very much DaveD -- http://mail.python.org/mailman/listinfo/python-list
Re: run exe on different computer
On Sep 13, 2:17 pm, Dave Angel wrote: > daved170 wrote: > > Hi everybody, > > I'm building a small python program that run a service (exe file) on > > my servers. > > I don't want to use remote desktop and it's siblings. > > > I would like to have some information on how to run an exe on a > > different computer and if there a way to check if that exe is still > > alive. > > > Thanks > > Dave > > On a question like this, you really need to supply much more information > on your constraints. You could start by saying these servers are > running Windows Server 2003. And that they're on a domain (rather than > a workgroup). And that you're trying to access them from another > machine within the same local domain, not over the internet. And that > your local machine is on the same domain, and has an account with admin > privileges for all the desired servers. And that you are allowed to do > a one-time install (of something) on each server prior to this > particular need. And that each server already has Python version 2.5 > installed, and the IT department won't allow you to install any later > version. > > Then once you have an environment, you need to specify just what kind of > program you want to run on those servers. Is it an EXE program? Or is > it Python, with a particular script? Does it really need to be a > *service*, which has a particular set of constraints, and should be > installed, and started/stopped using the service manager. Do you want > this program to restart whenever the servers are restarted? > > One solution that should work for nearly every Windows topology might be > to go to each server, run the scheduler task, and specify a new batch > file to be run upon boot. This batch file can check a specified > (shared) directory for a python script, and if found, run it. If not > found, sleep for 60 seconds or so, then repeat. Note that it's a good > idea to put a five minute delay at the very beginning, in case the > script needs to be deleted at the next boot. Sometimes a bug requires > surgery, and it's good to have enough time to do it. > > Now, to control those servers from another machine, copy an appropriate > script into the prearranged directory. Within a minute, it'll be > running, and it can post whatever results it likes in another accessible > directory. > > Whether this is a "safe" thing to do is a separate question. Generally > an IT department likes to have some control over just what programs run > on their servers, and for good reason. > > DaveA Hi DaveA Thanks for your answer. I'll try to clearify myself. For now I'm trying to do that on client & server that are win XP. They both on the same domain (maybe in the future they'll be runinig on the web). I have admin user on both my computers. I have both an exe and a python app that I'd like to control from my client. Insted of logging to my Server I would like to write a python app at my client that allows me to control both that exe and my Server-python- app. I don't want to use the schedualer because I would like to control it from my client. I can install whatever I'll like on both of the computers. they are mine and I have full access for them. I hope I clearify myself and if there are more solutions I'll be happy to be noted. Thans DaveD :) -- http://mail.python.org/mailman/listinfo/python-list
Distributing Python environment
Hello, I have an app which I would like to extend with Python. I I saw how to embed the interpreter into C. If I bundle my app with the Python lib (say, python26.dll) I can PyRun_SimpleString() some code. My question is, how do I bundle the rest of the libraries (site, os, elementtree, random, ...)? Is it possible to make one huge (ok, not so huge) .zip blob containing all of the libraries? And what happens if some user has Python already installed? Which libraries get loaded first? Is it possible to alter this order? I mean, first check for local Python install and if the user doesn't have Python installation use the bundled one? -- http://mail.python.org/mailman/listinfo/python-list
Re: IDE for python similar to visual basic
On Fri, 11 Sep 2009 05:27:59 -0700, r wrote: >> I'm saying that the user understands their workflow and environment better >> than the application's programmers. The user should be able to decide >> which menu items are shown and where, which buttons are shown and where, >> etc. The code doesn't need to know this level of detail, let alone dictate >> it. > > I completely disagree with this idea of user "customization" of the > GUI. Sounds more like adolescent accessorizing to me. How is changing > the location of a button, or entry, or whatever, actually going to > make workflow more easier? For a start, removing any buttons which the user won't be needing eliminates the risk of them clicking on them by accident. Beyond that, there is an advantage to placing buttons (etc) in similar locations to other applications which the user uses (or was using prior to migrating). In some cases, the reduction in mouse motion which can be obtained by placing specific buttons close together can make significant difference. Sometimes those buttons aren't all part of the same application (I know of people who place the Windows taskbar at the top of the screen simply because it's closer to most applications' toolbar and menubar). If you have two windows side-by-side, there's a benefit to having the left-hand window's controls running down its right-hand edge and vice-versa, so both sets of controls are all in one cluster. For mouse-centric applications, keyboard shortcuts aren't always a solution; particularly for left-handed users, as shortcuts are normally optimised for right-handed users (i.e. common shortcuts use the LHS of the keyboard, on the assumption that the right hand is on the mouse). > Sounds like "somebody" failed to get input > from their users at design time. Or "somebody" has the inability to > relate to their end users. You're assuming that there is some "right" answer which is appropriate for all users. There isn't. > Would a mechanic give you a screw driver so you could adjust the fuel/ > air ratio yourself? If he did i would never take my car back again! > Just reeks of incompetence!! If the manufacturer took your approach, there wouldn't be any screw. Just a fixed setting for all climates and altitudes, urban and rural, flat and hilly. -- http://mail.python.org/mailman/listinfo/python-list
Re: run exe on different computer
daved170 wrote: Hi everybody, I'm building a small python program that run a service (exe file) on my servers. I don't want to use remote desktop and it's siblings. I would like to have some information on how to run an exe on a different computer and if there a way to check if that exe is still alive. Thanks Dave On a question like this, you really need to supply much more information on your constraints. You could start by saying these servers are running Windows Server 2003. And that they're on a domain (rather than a workgroup). And that you're trying to access them from another machine within the same local domain, not over the internet. And that your local machine is on the same domain, and has an account with admin privileges for all the desired servers. And that you are allowed to do a one-time install (of something) on each server prior to this particular need. And that each server already has Python version 2.5 installed, and the IT department won't allow you to install any later version. Then once you have an environment, you need to specify just what kind of program you want to run on those servers. Is it an EXE program? Or is it Python, with a particular script? Does it really need to be a *service*, which has a particular set of constraints, and should be installed, and started/stopped using the service manager. Do you want this program to restart whenever the servers are restarted? One solution that should work for nearly every Windows topology might be to go to each server, run the scheduler task, and specify a new batch file to be run upon boot. This batch file can check a specified (shared) directory for a python script, and if found, run it. If not found, sleep for 60 seconds or so, then repeat. Note that it's a good idea to put a five minute delay at the very beginning, in case the script needs to be deleted at the next boot. Sometimes a bug requires surgery, and it's good to have enough time to do it. Now, to control those servers from another machine, copy an appropriate script into the prearranged directory. Within a minute, it'll be running, and it can post whatever results it likes in another accessible directory. Whether this is a "safe" thing to do is a separate question. Generally an IT department likes to have some control over just what programs run on their servers, and for good reason. DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: How to define a function with an empty body?
On Sunday 13 September 2009 05:37:01 Peng Yu wrote: > Hi, > > I want to define a function without anything in it body. In C++, I can > do something like the following because I can use "{}" to denote an > empty function body. Since python use indentation, I am not sure how > to do it. Can somebody let me know how to do it in python? def rubbish_do_nothing(): pass - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: Finite state machine in python
On Saturday 12 September 2009 22:39:10 Peng Yu wrote: > Hi, > > I have see some discussion on the implementation of finite state > machine in python. Can somebody point to me the best way in implenting > an FSM in python? > > http://code.activestate.com/recipes/146262/ You can go a long way with a far simpler model than the one in that recipe: 1) Define a routine for every state. 2) Have every state do the following: (i) Run the code to make the side effects like outputs happen. (ii) Scan the conditions for the state transitions relevant to this state. (Only the arrows leaving this state on the state diagram.) (iii) Return the next state (either the same or a different state). 3) The main loop of a long running machine then looks like this: next_state = start_state() while True: next_state = next_state() time.sleep(step_time) # if needed This simple model is surprisingly powerful, and it can be expanded to run a bundle of such machines in parallel very easily, by keeping a list of next_states and continuously cycling through and updating the list. You do not even need a dispatch dictionary. This is about the simplest model for making FSMs that I know of. Not sure if it is the "best" - best for what?. - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: is there a "strawberry python"?
* Daniel Fetchinson (Sat, 12 Sep 2009 12:54:03 -0700) > > > the reason I like strawberry perl is that I don't need to have admin right > > to install it. i can just unzip it and start the game. > > i am wondering if there is something similar in python community. > > > > any insight will be appreciated! > > As far as I remember there are python installations on USB sticks > which you can run without any privileges. > > http://www.portablepython.com/ Any Python runs without privileges. For some actions (like installing new packages) you need to have the appropriate keys in HKCU. But this is not required to run Python. Thorsten -- http://mail.python.org/mailman/listinfo/python-list
Re: CPU usage while reading a named pipe
Miguel P wrote: > On Sep 12, 2:54 pm, Ned Deily wrote: > > In article > > , > > Miguel P wrote: > > > I've been working on parsing (tailing) a named pipe which is the > > > syslog output of the traffic for a rather busy haproxy instance. It's > > > a fair bit of traffic (upto 3k hits/s per server), but I am finding > > > that simply tailing the file in python, without any processing, is > > > taking up 15% of a CPU core. In contrast HAProxy takes 25% and syslogd > > > takes 5% with the same load. `cat < /named.pipe` takes 0-2% > > > > > Am I just doing things horribly wrong or is this normal? > > > > > Here is my code: > > > > > from collections import deque > > > import io, sys > > > > > WATCHED_PIPE = '/var/log/haproxy.pipe' > > > > > if __name__ == '__main__': > > > try: > > > log_pool = deque([],1) > > > fd = io.open(WATCHED_PIPE) > > > for line in fd: > > > log_pool.append(line) > > > except KeyboardInterrupt: > > > sys.exit() > > > > > Deque appends are O(1) so that's not it. And I am using 2.6's io > > > module because it's supposed to handle named pipes better. I have > > > commented the deque appending line and it still takes about the same > > > CPU. > > > > Be aware that the io module in Python 2.6 is written in Python and was > > viewed as a prototype. In the current svn trunk, what will be Python > > 2.7 has a much faster C implementation of the io module backported from > > Python 3.1. > > Aha, I will test with trunk and see if the performance is better, if > so I'll use 2.6 in production until 2.7 comes out. I will report back > when I have made the tests. Why don't you try just using the builtin open() with bufsize parameter set big? Something like this (tested with named pipes). Tweak BUFFERSIZE and SLEEP_INTERVAL for maximum performance! import time BUFFERSIZE = 1024*1024 SLEEP_INTERVAL = 0.1 def tail(path): fd = open(path) buf = "" while True: buf += fd.read(BUFFERSIZE) if buf: lines = buf.splitlines(True) for line in lines[:-1]: yield line buf = lines[-1] if buf.endswith("\n"): yield buf buf = "" else: time.sleep(SLEEP_INTERVAL) def main(path): for line in tail(path): print "%r:%r" % (len(line), line) if __name__ == "__main__": import sys main(sys.argv[1]) -- Nick Craig-Wood -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: Finite state machine in python
For simplistic FSMs, if you want to avoid hand-coding all the transitions, actions etc., you could consider something like Libero ( http://www.cs.vu.nl/~eliens/documents/libero/lrintr.htm), although the last I checked Libero didn't generate Python yet (but I believe there might be similar options available with Python, though haven't come accross anything). Machine generated FSMs can be suboptimal for many cases though. On Sun, Sep 13, 2009 at 10:28 AM, CTO wrote: > On Sep 12, 4:39 pm, Peng Yu wrote: > > Hi, > > > > I have see some discussion on the implementation of finite state > > machine in python. Can somebody point to me the best way in implenting > > an FSM in python? > > > > http://code.activestate.com/recipes/146262/ > > > > Regards, > > Peng > > I wrote an example of how to do it using Graphine a while back. > Probably not the most efficient in the world, but pretty easy > to read, and it allows you to add and remove states and transitions > easily. > > URL: http://gitorious.org/graphine/pages/GraphineForPythonistas > > Geremy Condra > -- > http://mail.python.org/mailman/listinfo/python-list > -- regards, Banibrata http://www.linkedin.com/in/bdutta -- http://mail.python.org/mailman/listinfo/python-list
Re: run exe on different computer
Il 13/09/09 09.43, daved170 ha scritto: Hi everybody, I'm building a small python program that run a service (exe file) on my servers. I don't want to use remote desktop and it's siblings. I would like to have some information on how to run an exe on a different computer and if there a way to check if that exe is still alive. assuming windows as your target, look at this: http://timgolden.me.uk/python/wmi.html -- http://mail.python.org/mailman/listinfo/python-list
run exe on different computer
Hi everybody, I'm building a small python program that run a service (exe file) on my servers. I don't want to use remote desktop and it's siblings. I would like to have some information on how to run an exe on a different computer and if there a way to check if that exe is still alive. Thanks Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: Which version of python I should use if I just start programming in python?
I have just started using 2.6 (upgrade from 2.5). All my web applications' code (using Django), work without any changes. -- http://mail.python.org/mailman/listinfo/python-list
Re: ImageFont family mojibake
Donn wrote: On Saturday 12 September 2009 17:30:19 garabik- news-2005...@kassiopeia.juls.savba.sk wrote: apt-get install unicode unicode 0100.. Nice tip, thanks. if you see a lot of accented letters (and not squares or question marks), you can be sure I see the accented chars -- so now I am more certain that the problem is in the font.family function. Something deep in the C code... \d Try testing with some of the supported encodings like: print f.font.family.decode('utf-8') try some of these encodings: http://docs.python.org/library/codecs.html#standard-encodings The brute force should work if the font's name is encoded in one of the supported codecs; and if wx does not do something like f.[en|de]code(errors='replace'). -- http://mail.python.org/mailman/listinfo/python-list