Re: [Tutor] pyhook for Linux
Hi, You could also use the evdev driver: http://groups.google.com/group/comp.lang.python/browse_thread/thread/2d7e3791381bdeb5/a03d438f64ec5ac8?lnk=gst&q=francois+schnell&rnum=2#a03d438f64ec5ac8 If you successfully use another way I'm interested by your feedback. Thanks. On 6/23/07, Flaper87 <[EMAIL PROTECTED]> wrote: > Hi! > > Does anyone knows an equivalence of pyhook for linux? > > I need to catch the events of the mose (even the simple movement, or when it > focus an icon on Desktop), and the events of the keyboard. > > Thank's > > -- > Flavio Percoco Premoli, A.K.A. [Flaper87] > http://www.flaper87.com > Usuario Linux registrado #436538 > Geek by nature, Linux by choice, Debian of course. > Key Fingerprint: CFC0 C67D FF73 463B 7E55 CF43 25D1 E75B E2DB 15C7 > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > -- Francois Schnell ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] [Linux] open a file in any home "~" ?
Hello, I want to read a configuration file from a small python app (user preferences). The ".myapp.conf" is in the home folder of the user. if I do: f=open("/home/user1/.myapp.conf","r") #it works obviously I won't know the home user folder name then I wanted to use: f=open("~/.myapp.conf","r") # but it returns a IOError: [Errno 2] No such file or directory: How can I do to access this file whatever the user is ? Thanks for your help. --- ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [Linux] open a file in any home "~" ?
It works great, thanks very much to the three of you for these light-speed answers ... I love this list ! Wesley, I've just pre-order your new edition "Core Python programming" on amazon France, it looks great. :) Thanks On 19/04/06, w chun <[EMAIL PROTECTED]> wrote: > f=open("~/.myapp.conf","r") # but it returns a IOError: [Errno 2] No such> file or directory:>> How can I do to access this file whatever the user is ?use os.path.expanduser (path)http://www.python.org/doc/2.4.3/lib/module-os.path.htmlhope this helps!-- wesley- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall, (c)2007,2001http://corepython.comwesley.j.chun :: wescpy-at-gmail.com python training and technical consultingcyberweb.consulting : silicon valley, cahttp://cyberwebconsulting.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] WinXP IDLE -> open file : how-to change default directory ?
Hello,On WinXP IDLE will always 'open' in Python24 folder at startup.A beginner friend of mine hate that (personally I use SPE) and I tried 'quickly' to find a way to configure that for him.I found all the .cfg files in idlelib and also the .idlerc folder in the "Documents and settings" but I don't see how to give IDLE a default directory at startup (or kipping in memory the last one opened). How to do that or is it just not possible ?Thanks learner404 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] WinXP IDLE -> open file : how-to change default directory ?
On 15/06/06, Matthew Webber <[EMAIL PROTECTED]> wrote: Try right-clicking on the shortcut, select properties, and change the "startin" value.MatthewScary, I didn't know that windows had that ...Thanks very much Matthew ! P.S. When posting to the list, please use plain text format. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] OnBehalf Of learner404Sent: 15 June 2006 20:09 To: tutor@python.orgSubject: [Tutor] WinXP IDLE -> open file : how-to change defaultdirectory ?Hello,On WinXP IDLE will always 'open' in Python24 folder at startup. A beginner friend of mine hate that (personally I use SPE) and Itried 'quickly' to find a way to configure that for him.I found all the .cfg files in idlelib and also the .idlerc folder in the "Documents and settings" but I don't see how to give IDLE a defaultdirectory at startup (or kipping in memory the last one opened).How to do that or is it just not possible ?Thanks learner404 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] I Give Up.
On 18/06/06, Brian Gustin <[EMAIL PROTECTED]> wrote: The one amazing thing I found ridiculously funny:Python "official" forums- and they actually run phpBB forums? You meanto tell me no one has written a solid, stable forum software in Python? OK.. maybe another project to tackle.. I guess I just need to startbuilding the python documentation the way I think it outta be done...and see how it goes over..I also was very surprised with that and I'd really love to see a "pynBB" :) The only things I saw for "forums" in Python are:pyBB but it seems dead and my south-korean sucks :http://bbs.pythonworld.net:9080/pybbs.py Zyons which look promising on a Django base but which still is in an alpha state:http://zyons.com/forum/Concerning basic Perl/Python I also found that (but not complete) : http://pleac.sourceforge.net/pleac_python/index.html"In this document, you'll find an implementation of the Solutions of the Perl Cookbook in the Python language." Ooops and I also found that on perl ;)http://mirror5.escomposlinux.org/comic/ecol-13-e.png learner404 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Tkinter: 'explanation text' when the mouse is over an image button ?
Hello,With a Tkinter app I have buttons with an image filling each button like this,bu10=Button(frame2, image=picPlay, bg="white", command=play)I want to give a small explanation of each button when the user puts the mouse over the picture (something like the title tag in a hyperlink). I thougth I saw this in Tkinter but can't find it here:http://effbot.org/tkinterbook/button.htmThanks for any suggestions to achieve this.learner404 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Get keyboard input while other program is in focus?
On 16/10/06, Jack <[EMAIL PROTECTED]> wrote: What commands can I use to have the program know a certain key has been pressed while another program is in focus?Hello,On windows I use the pyHook module (simple to use and works fine) :http://www.cs.unc.edu/~parente/tech/tr08.shtml On Linux its more tricky but you can find some informations here:http://groups.google.com/group/comp.lang.python/browse_thread/thread/2d7e3791381bdeb5/a03d438f64ec5ac8#a03d438f64ec5ac8 cheers thanks, Jack ___Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Hiding/Killing a DOS window (from a previous os.system call)
Hello, I'm launching an external app through an os.system() or os.popen() but I don't want the resulting DOS window to hang-on there forever (my python script is launched with pythonw): I use a sys.exit() to kill the script who launched the external app.Thepython script is killed, the app is launched, but the resulting DOS window is still there (I have the same result if I use the DOS tskill or taskkill command to kill the script with his PID). How could I hide/kill the resulting DOS window from an os.sytem / os.popenwith Python ? Also is there a way to launch an external app. but without os.system and os.popen to wait there but immediately continue to the next python line (to avoid this I'm using a thread for now). As an example I'm using this so far. If I use pythonw to launch the script, notepad is launched, the script is killed but the DOS window stay there. import os,sys,time from thread import start_new_thread def launchApp(): os.system("notepad.exe") try: start_new_thread(launchApp,()) except: print "Something went wrong => do somenthing" time.sleep(2) print "And now going out" sys.exit() Thanks ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Hiding/Killing a DOS window (from a previous os.system call)
Thanks a lot Alan ! both solutions work like a charm :) On 3/5/07, Alan Gauld <[EMAIL PROTECTED]> wrote: "learner404" <[EMAIL PROTECTED]> wrote > I'm launching an external app through an os.system() or os.popen() > but I > don't want the resulting DOS window to hang-on there forever Try using os.spawnl() instead: >>> pid = os.spawnl(os.P_NOWAIT,r'C:\Windows\System32\notepad.exe') >>> print pid 2834 The P_NOWAIT makes it return immediately, and no DOS box is created. Note that the spawn family of processes are deprecated and the subprocess module provides equivalent functionality. Using subprocess it looks like: >>> pid = Popen([r'C:\Windows\System32\notepad.exe', ""]).pid HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tutor Digest, Vol 37, Issue 15
On 3/5/07, Tony Cappellini <[EMAIL PROTECTED]> wrote: Rename your file from .py to .pyw. This will prevent the DOS window from appearing It's not the DOS window from the Python script I was talking about (in my mail I said "my python script is launched with pythonw") but the one resulting from the os.systemor os.popen commands. The two solutions that Alan gave are perfect for these :) Message: 6 Date: Mon, 5 Mar 2007 16:51:42 +0100 From: learner404 <[EMAIL PROTECTED]> Subject: [Tutor] Hiding/Killing a DOS window (from a previous os.system call) To: "Tutor Python" Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset="iso-8859-1" Hello, I'm launching an external app through an os.system() or os.popen() but I don't want the resulting DOS window to hang-on there forever (my python script is launched with pythonw): I use a sys.exit() to kill the script who launched the external app.Thepython script is killed, the app is launched, but the resulting DOS window is still there (I have the same result if I use the DOS tskill or taskkill command to kill the script with his PID). How could I hide/kill the resulting DOS window from an os.sytem / os.popenwith Python ? Also is there a way to launch an external app. but without os.system and os.popen to wait there but immediately continue to the next python line (to avoid this I'm using a thread for now). As an example I'm using this so far. If I use pythonw to launch the script, notepad is launched, the script is killed but the DOS window stay there. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] White spaces in a path (from a string variable) and os.popen on Windows
Hello, I'm getting crazy with white spaces on Windows. :( I'm aware of the three paths gotchas on Windows well explained here: http://www.freenetpages.co.uk/hp/alan.gauld/tutfiles.htm But my problem is with white spaces in windows paths (very common with "program files", "documents and settings",etc). I precise I use os.popen because I need to read the answer from an external command-line app that I feed with a file or folder path. When I know exactly the path in advance I use a raw string r' ' and I add double quotes where necessary to avoid the white spaces syndrome. But I don't see how to do this "easily" when my path is a string variable given by my GUI (like C:\Documents and Settings\name\Mes documents) I've googled this problem but wasn't successful so far. I just seem to find people who have problems with whitespaces and Python like here: http://e-scribe.com/news/324 Can you help me to understand how to deal with white spaces in Pyhton (or SVP point me to any URL or relevant book). :) For now I'm trying to make work a minimal "hello world" example here : The little script below shows a button (wx) to select a directory. I print in the console the selected directory (string) and I try to recover the result of a DOS dir command thought an os.popen. If I select a folder without a whitespace(s) it works well. If the path has a whitespace it doesn't (not apparent result). Can you make this script work in all situation on Windows ? (ie whatever the folder I select with the GUI) ? Many, many thanks in advance. :) # Test with popen and paths containing white spaces import wx,os,sys app=wx.App(redirect=False) class GUI(wx.Frame): def __init__(self,parent,title): wx.Frame.__init__(self, parent, -1, title,size=(400,100)) bkg=wx.Panel(self) dirButton=wx.Button(bkg,label="Select a directory") self.Bind(wx.EVT_BUTTON, self.goPath, dirButton) def goPath(self,evt): myDir=wx.DirDialog(self) myDir.ShowModal() dirPath=myDir.GetPath() print "GetPath result is",dirPath result=os.popen("dir "+dirPath).read() print "os.popen result is ",result win=GUI(None,title="Test") win.Show() app.MainLoop() ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] White spaces in a path (from a string variable) and os.popen on Windows
On 3/8/07, Jerry Hill <[EMAIL PROTECTED]> wrote: > result=os.popen("dir "+dirPath).read() to this: result=os.popen('dir "%s"' % dirPath).read() That worked fine with all the directories I threw at it. Thanks a lot Jerry ! :) I didn't think of doing it this way. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)
Hello list! - myapp.py is in a "myfolder" folder that the "users" will be able to download and put anywhere on their Mac. - users don't have any Python knowledge and I have no idea if there's a python launcher on their mac => trying to make an applescript file in the folder right next to myapp.py I tried and failed at : *tell* *application* "Terminal" *do script* "python myapp.py"# tried also with ./myapp.py *end* *tell* or do shell script "python myapp.py" # tried also with ./myapp.py In both cases OSX complains it can't find the file. It works though if I give the full path but I can't do that since I have no idea where the folder will be on their macs. With Applescript how would write it so that Python starts in the application folder? (myapp.py & "myfolder") Any other way to do it maybe knowing my constraints above? (I tried py2app but it failed on wxpython on my Lion with Apple Python that I need to use) Thanks! francois ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)
On Thu, Nov 10, 2011 at 2:14 PM, Steven D'Aprano wrote: > learner404 wrote: > >> Hello list! >> >> - myapp.py is in a "myfolder" folder that the "users" will be able to >> download and put anywhere on their Mac. >> > [...] > > In both cases OSX complains it can't find the file. >> > > Do you mean that AppleScript can't find the file, or that Python can't > find the file? > When I double click on the AppleScript the terminal opens with $ python myapp.py $ python: can't open file 'avcOsxLinux.py': [Errno 2] No such file or directory myapp.py and the AppleScript are both in the same directory. If I open manually a shell in this directory "python myapp.py" works. It all seems like the Python invoked in the AppleScript have his current directory in root (and not the folder where i'm executing the AppleScript). I don't see how I can change this from the AppleScript or simply find a general solution to execute a .py script on Mac within the constrains I mentioned above. > Please don't summarize or paraphrase errors. Please copy and paste the > EXACT error message that is shown. > > If this is a problem with AppleScript being unable to find the file, you > will be better off asking on an AppleScript mailing list. > > In general, on Unix-like systems (and that includes Mac OS X), you can't > expect a command like: > > python myapp.py > > to work unless myapp.py is in the current directory. > > > > -- > Steven > __**_ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor> > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)
On Thu, Nov 10, 2011 at 4:33 PM, Rich Lovely wrote: > > It looks like your script is being found fine, meaning the problem lies > elsewhere - unless your actual app is called "avcOsxLinux.py, and you > missed renaming it in the error message. Try adding a print statement as > the very first line - before any imports - to test this. > Sorry I missed replacing this one when I copy/pasted on the list; avcOsxLinux.py is "myapp.py" (I renamed it for clarity). Unfortunately the problem is still the same. $ python myapp.py $ python: can't open file 'myapp.py': [Errno 2] No such file or directory > The only reference to that filename is a french audio-visual library, > which might not be installed on your target system. > > Rich "RoadieRich" Lovely > > There are 10 types of people in the world: > Those who know binary, > Those who do not, > And those who are off by one. > > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)
On Fri, Nov 11, 2011 at 12:02 AM, Prasad, Ramit wrote: It is probably easiest to keep myapp.py in the home directory (or > subdirectory of it) and say "python ~/myapp.py" (or "python > ~/.roadierich/myapp.py) from the applescript > > I will go with that for now. My python script is using a bunch of relative paths so I added this before the script: if sys.platform=="darwin": os.chdir(os.path.expanduser("~/myfolder/")) I will try to see if there's something like "inno setup" to make an installer. If anyone have something to recommend for this i'm interested. Thanks Ramit and all. > > > Ramit > > > Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology > 712 Main Street | Houston, TX 77002 > work phone: 713 - 216 - 5423 > > -- > This email is confidential and subject to important disclaimers and > conditions including on offers for the purchase or sale of > securities, accuracy and completeness of information, viruses, > confidentiality, legal privilege, and legal entity disclaimers, > available at http://www.jpmorgan.com/pages/disclosures/email. > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Pydev + Remote System Explorer (RSE) : problems with local imports when working localy
Hello List, I'm very happy with PyDev plugin for Eclipse as a Python IDE (I'm on Eclipse 3.7, WinXP with latest Pydev). Recently I've installed the Remote System Explorer plugin for Eclipse which adds the ability to edit remote files on a server when I need it (awesome). Unfortunately it's messing my ability to work on some Python files locally on my PC (those with local imports): File "C:\Documents and Settings\myaccount\workspace\RemoteSystemsTempFiles\LOCALHOST\c\Documents and Settings\myaccount\workspace\myprojet\myfile.py", line 50, in ? ImportError: No module named mymodule (it works only if I "python myfile.py" in the command shell) I know some people of the list are using Eclipse and maybe they use RSE too. Do you know if I can easily deactivate RSE so I can run a python script normally (without the *localhost* inserting in the path) ? Is there a configuration to do to keep both ? I've tried to switch form perspective "remote systems" to perspective "pydev" but I have the same problem. Thanks. francois ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Pydev + Remote System Explorer (RSE) : problems with local imports when working localy
hmmm ... menu "window">"Reset perspective" and "close all perspectives" seems to have fix the problem. Sorry for unnecessary mail. On Tue, Jul 31, 2012 at 2:02 PM, learner404 wrote: > Hello List, > > I'm very happy with PyDev plugin for Eclipse as a Python IDE (I'm on > Eclipse 3.7, WinXP with latest Pydev). > Recently I've installed the Remote System Explorer plugin for Eclipse > which adds the ability to edit remote files on a server when I need it > (awesome). > > Unfortunately it's messing my ability to work on some Python > files locally on my PC (those with local imports): > File "C:\Documents and > Settings\myaccount\workspace\RemoteSystemsTempFiles\LOCALHOST\c\Documents > and Settings\myaccount\workspace\myprojet\myfile.py", line 50, in ? > ImportError: No module named mymodule > (it works only if I "python myfile.py" in the command shell) > > I know some people of the list are using Eclipse and maybe they use RSE > too. > > Do you know if I can easily deactivate RSE so I can run a python script > normally (without the *localhost* inserting in the path) ? > Is there a configuration to do to keep both ? > > I've tried to switch form perspective "remote systems" to perspective > "pydev" but I have the same problem. > > Thanks. > > francois > > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] os.system vs subprocess.Popen args problems
Hello, I can't understand why the command below works with os.system but not with subprocess.Popen (on windows, recording video with FFMPEG.exe) cmd=('ffmpeg -f dshow -i video="%s" -f dshow -i audio="%s" -q 5 "%s"')%(videoinputName, audioinputName, videoFileOutput) os.system(cmd) *works* subprocess.Popen(["ffmpeg","-f","dshow","-i",'video="%s"'%videoinputName,"-f","dshow","-i",'audio="%s"'%audioinputName,"-q","5","%s"%videoFileOutput]) *don't work* >> [dshow @ 025984a0] Could not find video device. >> video="QuickCam Orbit/Sphere AF": Input/output error The reason I'm going with subprocess is to avoid to have the DOS window coming in the forefront. Any idea of what I'm doing wrong? Or any other way to hide or minimize the DOS window? Thanks. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] os.system vs subprocess.Popen args problems
Thanks a lot Oscar and Eryksun for all the explanations and answers, I really appreciate. "So the extra quotes used for the video and audio arguments do actually get passed through to ffmpeg causing confusion." Yes, this worked :) subprocess.Popen(["ffmpeg","-f","dshow","-i","video="+videoinputName,"-f","dshow","-i","audio="+audioinputName,"-q","5","%s"%videoFileOutput],shell=True) On Tue, Sep 3, 2013 at 5:42 PM, Oscar Benjamin wrote: > On 3 September 2013 14:48, eryksun wrote: > >> It occurs to me that another possibility is if ffmpeg isn't really an > >> .exe on PATH but rather a .bat file or something. In that case > >> os.system or subprocess shell=True would pick it up but subprocess > >> shell=False might not. I say "might" because at least on some version > >> of Windows CreateProcess can run .bat files directly but I've never > >> seen this documented anywhere. > > > > cmd tries each PATHEXT extension, but CreateProcess only tries .exe, > > and finds ffmpeg.exe. > > > > As to batch files, "Windows Internals" (Microsoft Press) documents > > that CreateProcess starts cmd.exe to run .bat and .cmd files. > > Okay, I see. So it can run a .bat if you give the extension but not > implicitly via PATHEXT. In which case anything without an extension > would have to be an .exe file. And of course this wouldn't explain the > OP's problem anyway since they're getting output from ffmpeg. > > Testing the OP's actual commands out with ffmpeg I see that the > problem is with the quotes. But, as you pointed out in your first > post, it is the unnecessary additional quotes that are the problem > rather than any missing ones. i.e. when I test it I get: > > # os.system output > [dshow @ 02548460] Could not enumerate video devices. > video=video: Input/output error > > # subprocess.Popen output > [dshow @ 02548460] Could not enumerate video devices. > video="video": Input/output error > > So the extra quotes used for the video and audio arguments do actually > get passed through to ffmpeg causing confusion. (I don't have any > video devices here so it's an error either way on this machine). > > > Oscar > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor