Re: [Tutor] an alternative to shutil.move()?
Chris Lasher escribió: How about os.rename http://docs.python.org/lib/os-file-dir.html On 10/15/06, Alfonso [EMAIL PROTECTED] wrote: Is there an alternative in python to use shutil.move()? That's exactly what I was looking for. Thank you very much. Don't know how I didn't find it before. I suppose that I was thinking that the name of the module would be other... __ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] executing with double click on linux
Thank you for your answer, Jonathon. I have found that the problem ocurs only with programs that make use of glade files for the interface. With pure pygtk programs without using glade files, making a launcher with a simple double click works perfectly. But if the program builds his interface basing in a glade file, that doesn't work. The mime type is ok, and I have tried your proposal, but it doesn't work with those programs. I'll keep trying to find the reason. I'll tell you if I find it. I have wroten to gnome-devel about this, and they have recommended me to have a look at the source from orca, a gnome application that makes use of glade files, so I'll have a look at it... __ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] an alternative to shutil.move()?
Is there an alternative in python to use shutil.move()? It copies the files and then removes the source file insted of just moving directly the file (don't know much about file systems, but I suppose that when you move using the shell, if both source and destination are in the same partition, it's just a matter of changing the entries in the file allocation table). Copying the entire file, specially with big files is very slow, and I think that it makes an unnecesary use of the hard drive and system resources, when both source file and destination are on the same partition... __ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] executing with double click on linux
Jonathon Sisson escribió: Alfonso wrote: Sorry for the too obvious question. I'm new to python and have no idea how can I make execute a compiled .pyc with a double click in linux, with gnome. Trying to double click in a .py gives allways the question wether I want to execute the text file, or read it. (This behaviour can be changed with gconf-editor, but as it is for security matters, I would prefer to execute the .pyc with a double click). I have tried to associate python to the .pyc (first time I executed it there was no programm associated), but it doesn't work. I don't know how much Linux experience you have (judging by the double-click concept, I'm assuming you're coming from a Windows background or are perhaps catering to users with only a Windows background) (correct me if I'm wrong)...so I'm going to break this down as much as I can. .pyc files are considered binary files by Linux. As such, bash attempts to execute them as binary (ELF, etc...), which obviously won't work. If you really need to have double-click/execute functionality, consider writing a small shell script to execute the .pyc file for you. For instance, let's say you have a python script foo.py and a compiled python script foo.pyc. If you attempt to run foo.py from the shell and you have a proper header (i.e. #!/usr/bin/python), then bash can execute the script. I'm assuming that GNOME has similar functionality (I prefer Fluxbox to either GNOME or KDE), which allows your .py files to execute directly. .pyc, however, even with a file association, fails to launch...on my system, I get this error: $ ./foo.pyc bash: ./foo.pyc: cannot execute binary file bash recognizes the file as binary, but it fails to launch as an ELF binary (or whatever you're set up to run). To fix it, simply write a shell script as such: code #!/bin/sh python /home/me/scripts/foo.pyc /code Name the script whatever you want (i.e. foo.sh) then run from the commandline: $ chmod 700 foo.sh This gives the script read/write/execute permissions for the owner of the script...if you require read/write/execute/etc...for group or all, change 700 to whatever you need. (i.e. 755 for rwxr-xr-x permissions) (Alternatively you can right click on the shell script and set permissions graphically...whichever you prefer) Now, you should be able to double-click the script (or preferably a shortcut to the script on your desktop), which will launch the compiled python module for you. If this seems like a lot of work, then perhaps you could write a shell script to automate the task of creating the shell script and setting permissions each time you create a new .pyc...doh? Hope this is a satisfactory answer...and if anyone knows something I have overlooked, please let Alfonso and I know. Jonathon Thank you for your answer. __ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Thank you very much for your answer. Both true, coming from windows, three years with linux. I don't have any fear to executing from the shell, but It's not the same thing with some of my friends, totally new to linux, and not very much friends of the console. I would like to distribute to them my python programms (when I have the knolowdge to writte something decent with python :) ). If I use a bash script I have the same problem that with executing the .py. Gnome asks wether you want to execute or read it, etc. This is due to security reasons, and can be disabled using the tool gconf-editor, you can change that behaviour so that the files are allways executed or opened with a text editor. But I didn't want to change that, and I thought this could be easily avoided just executing the .pyc files, because I have programmed with mono (.net) in linux and that works so. I mean, if I'm not mistaked .pyc are compiled in intermediate language files, just like .exe in .net/mono. With mono all I have to do was chmod at the .exe, then changing the programm with which the .exe is opened (to mono) and that works fine for me, it can be opened with a double click. But it's not an elf binary, I think... I think there must be a way to execute with a launcher the programm without being asked each time. As it is for example with bittornado or bittorrent, both written in python and both are executed from the applications menu or from a launcher at the desktop with no intermediate question about if you want to show or execute the file, or just to cancel the action. In fact, when I execute bittornado it's a file called btdownoladgui.bittornado which is executed. But it's python code. If I try to do something similar (executing a file
[Tutor] executing with double click on linux
Sorry for the too obvious question. I'm new to python and have no idea how can I make execute a compiled .pyc with a double click in linux, with gnome. Trying to double click in a .py gives allways the question wether I want to execute the text file, or read it. (This behaviour can be changed with gconf-editor, but as it is for security matters, I would prefer to execute the .pyc with a double click). I have tried to associate python to the .pyc (first time I executed it there was no programm associated), but it doesn't work. Thank you for your answer. __ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] not such file or directory exception
Trying to copy or move files -I do it with move or copyfile- between directories, with characters of the spanish language gives me this error: not such file or directory. I suppose this is related with unicode, any idea how can I handle it? Thank you very much, in advance. (My system is in spanish, I use linux). __ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] problems with python and glade
Hi, I'm trying to learn to use python with glade. As start I have tried to run a program from a tutorial, but when I run it I become this exception: class GladeXML(_gtk.GtkData): AttributeError: 'module' object has no attribute 'GtkData' This ist the program: import pygtk pygtk.require('2.0') import gtk import libglade import gtk.glade class HellowWorldGTK: This is an Hello World GTK application def __init__(self): #Set the Glade file self.gladefile = proyecto2.glade self.wTree = gtk.glade.XML(self.gladefile) #Get the Main Window, and connect the destroy event self.window = self.wTree.get_widget(MainWindow) if (self.window): self.window.connect(destroy, gtk.main_quit) Does anyone know what could be wrong? Thank you for your attention. __ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] web intefaces?
Chad Crabtree wrote: While everything that Alan Guald said is true, there are a couple of options for you. Provided you know HTML (you must), you could generate html pragmatically but, knowledge of html is still mandatory. Your options are, basically http://www.cherrypy.org Which is an app server that should be fairly easy to package up with, say py2exe. Another option, with CGI (pretty easy) is found in the standard library. http://docs.python.org/lib/module-CGIHTTPServer.html If you do this as a personal app I would make sure to use an alternate port number like 11224, or something. HTH Best of Luck. On 5/6/06, Alfonso [EMAIL PROTECTED] wrote: I would like to experiment with web interfaces and python. After some googling, I'm quite confused, does somebody know of a good link about this topic / what do you think that is the best software option to design web user intefaces with python? I mean web interfaces for common programms (so it's not important to me to have a very robust web server), the web server should run in the machine of the user of the programm.And it should be easy installed, as bundle, when I distribute the programm. Thank very much for your help. __ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Thank you very much for your answers __ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] web intefaces?
Ron Phillips wrote: I like Karrigell ...http://www.karrigell.com/ for being flexible, complete, lightweight, and easy to learn. I don't know how it scales, but that's not really a consideration for the applications you describe. Ron Chad Crabtree [EMAIL PROTECTED] 5/8/2006 6:29 PM While everything that Alan Guald said is true, there are a couple of options for you. Provided you know HTML (you must), you could generate html pragmatically but, knowledge of html is still mandatory. Your options are, basically _http://www.cherrypy.org http://www.cherrypy.org/_ Which is an app server that should be fairly easy to package up with, say py2exe. Another option, with CGI (pretty easy) is found in the standard library. _http://docs.python.org/lib/module-CGIHTTPServer.html_ If you do this as a personal app I would make sure to use an alternate port number like 11224, or something. HTH Best of Luck. On 5/6/06, Alfonso _ [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]_ wrote: I would like to experiment with web interfaces and python. After some googling, I'm quite confused, does somebody know of a good link about this topic / what do you think that is the best software option to design web user intefaces with python? I mean web interfaces for common programms (so it's not important to me to have a very robust web server), the web server should run in the machine of the user of the programm.And it should be easy installed, as bundle, when I distribute the programm. Thank very much for your help. __ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. _http://es.voice.yahoo.com http://es.voice.yahoo.com/_ ___ Tutor maillist - [EMAIL PROTECTED] mailto:Tutor@python.org_ _http://mail.python.org/mailman/listinfo/tutor_ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Thank you Ron, I will have a look at that too __ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] printing the links of a page (regular expressions)
I'm writing a script to retrieve and print some links of a page. These links begin wiht /dog/, so I use a regular expresion to try to find them. The problem is that the script only retrieves a link per line in the page. I mean, if the line hat several links, the script only reports the first. I can't find where is the mistake. Does anyone hat a idea, what I have false made? Thank you very much for your help. import re from urllib import urlopen fileObj = urlopen(http://name_of_the_page;) links = [] regex = re.compile ( ((/dog/)[^ \\';:,]+),re.I) for a in fileObj.readlines(): result = regex.search(a) if result: print result.group() __ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] printing the links of a page (regular expressions)
Kent Johnson wrote: Alfonso wrote: I'm writing a script to retrieve and print some links of a page. These links begin wiht /dog/, so I use a regular expresion to try to find them. The problem is that the script only retrieves a link per line in the page. I mean, if the line hat several links, the script only reports the first. I can't find where is the mistake. Does anyone hat a idea, what I have false made? You are reading the data by line using readlines(). You only search each line once. regex.findall() or regex.finditer() would be a better choice than regex.search(). You might also be interested in sgmllib-based solutions to this problem, which will generally be more robust than regex-based searching. For example, see http://diveintopython.org/html_processing/extracting_data.html http://www.w3journal.com/6/s3.vanrossum.html#MARKER-9-26 Kent Thank you very much for your help. import re from urllib import urlopen fileObj = urlopen(http://name_of_the_page;) links = [] regex = re.compile ( ((/dog/)[^ \\';:,]+),re.I) for a in fileObj.readlines(): result = regex.search(a) if result: print result.group() __ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Thank you very much, Kent, it works with findall(). I will also have a look at the links about sgmllib. __ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] web intefaces?
I would like to experiment with web interfaces and python. After some googling, I'm quite confused, does somebody know of a good link about this topic / what do you think that is the best software option to design web user intefaces with python? I mean web interfaces for common programms (so it's not important to me to have a very robust web server), the web server should run in the machine of the user of the programm.And it should be easy installed, as bundle, when I distribute the programm. Thank very much for your help. __ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] UI developing
Hi, I'm starting with python on linux. I would like to make gtk user interfaces. Wich is the best option to do that? gtk-bindings, glade? If I want to port a program with gtk interface to windows, what should I use? Thank you very much for your attention. __ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] copying files and regular expressions
I'm totally new to python. I would like to know, how can I copy files using regular expressions (the equivalent in python to unix cp /home/mycount/*partialname* /home/mycount/directory/). __ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor