weird error messages on application exit
Running FC5 with Gnome (rather minimal install), using latest wxPython version installed from wxPython.org RPMs since I needed unicode and FC5 only has ansi available in the package manager. Anyway the errors occur every time i close out of my wxPython application, and sometimes... maybe every 10 - 15 times... i need to kill the app. I have no idea what all this means, could someone please point me in the right direction? Thanks! (python:5584): Gdk-CRITICAL **: gdk_drawable_get_depth: assertion `GDK_IS_DRAWABLE (drawable)' failed (python:5584): Gtk-CRITICAL **: gtk_pixmap_set: assertion `gdk_colormap_get_visual (gtk_widget_get_colormap (GTK_WIDGET (pixmap)))->depth == gdk_drawable_get_depth (GDK_DRAWABLE (val))' failed (python:5584): Gdk-CRITICAL **: gdk_drawable_get_depth: assertion `GDK_IS_DRAWABLE (drawable)' failed (python:5584): Gtk-CRITICAL **: gtk_pixmap_set: assertion `gdk_colormap_get_visual (gtk_widget_get_colormap (GTK_WIDGET (pixmap)))->depth == gdk_drawable_get_depth (GDK_DRAWABLE (val))' failed (python:5584): Gdk-CRITICAL **: gdk_drawable_get_depth: assertion `GDK_IS_DRAWABLE (drawable)' failed (python:5584): Gtk-CRITICAL **: gtk_pixmap_set: assertion `gdk_colormap_get_visual (gtk_widget_get_colormap (GTK_WIDGET (pixmap)))->depth == gdk_drawable_get_depth (GDK_DRAWABLE (val))' failed (python:5584): Gdk-CRITICAL **: gdk_drawable_get_depth: assertion `GDK_IS_DRAWABLE (drawable)' failed (python:5584): Gtk-CRITICAL **: gtk_pixmap_set: assertion `gdk_colormap_get_visual (gtk_widget_get_colormap (GTK_WIDGET (pixmap)))->depth == gdk_drawable_get_depth (GDK_DRAWABLE (val))' failed (python:5584): Gdk-CRITICAL **: gdk_drawable_get_depth: assertion `GDK_IS_DRAWABLE (drawable)' failed (python:5584): Gtk-CRITICAL **: gtk_pixmap_set: assertion `gdk_colormap_get_visual (gtk_widget_get_colormap (GTK_WIDGET (pixmap)))->depth == gdk_drawable_get_depth (GDK_DRAWABLE (val))' failed -- http://mail.python.org/mailman/listinfo/python-list
Re: weird error messages on application exit
I tried downloading and installing from the fedora site and got this: gtk2-2.8.19-2.i386.rpm is already installed However, the problem seems to have gone away. Not sure what happened there. Thank you for the reply. gtk2-2.8.19-2.i386.rpm is already installed Frank Millman wrote: > ianaré wrote: > > Running FC5 with Gnome (rather minimal install), using latest wxPython > > version installed from wxPython.org RPMs since I needed unicode and FC5 > > only has ansi available in the package manager. Anyway the errors occur > > every time i close out of my wxPython application, and sometimes... > > maybe every 10 - 15 times... i need to kill the app. > > I have no idea what all this means, could someone please point me in > > the right direction? Thanks! > > > > > > > > (python:5584): Gdk-CRITICAL **: gdk_drawable_get_depth: assertion > > `GDK_IS_DRAWABLE (drawable)' failed > > > > I had the same problem. Here is a link to the whole story, together > with the solution, from the wxPython mailing list archive. > > http://tinyurl.com/o4jsu > > Frank Millman -- http://mail.python.org/mailman/listinfo/python-list
in need of some sorting help
Hey all, if i use a os.walk() to append files to a list like so... files = [] root = self.path.GetValue() # wx.TextCtrl input filter = self.fileType.GetValue().lower() # wx.TextCtrl input not_type = self.not_type.GetValue() # wx.CheckBox input for base, dirs, walk_files in os.walk(root): main.Update() # i only need the part of the filename after the user selected path: base = base.replace(root,"") for entry in walk_files: entry = os.path.join(base,entry) if filter != "": if filter in entry.lower() and not not_type: files.append(entry) if filter not in entry.lower() and not_type: files.append(entry) else: files.append(entry) ... will it sort properly on mac and *nix? if not, is there a tried an true sorting method someone could graciously let me know of? oh by sort properly i mean: file1.ext file2.ext file3.ext file4.ext zzfile.ext folder1\file1.ext folder1\file2.ext folder1\file3.ext folder2\file1.ext folder2\file2.ext folder2\file3.ext something tells me it's probably better to do my own sorting, just in case, so i tried: files.sort(key=lambda x: x.lower()) but that didn't work, made them out of order. TIA -- http://mail.python.org/mailman/listinfo/python-list
Re: in need of some sorting help
thank you for the help, i didn't know you could sort in place like that. definitly will come in handy. However, i need the sorting done after the walk, due to the way the application works... should have specified that, sorry. TIA -- http://mail.python.org/mailman/listinfo/python-list
Re: Write a GUI for a python script?
wxPython is another good option, especially since there is boa-constructor, which is a great GUI builder, almost makes it too easy to make a nice looking app in no time at all. http://www.wxpython.org/download.php http://boa-constructor.sourceforge.net/ if you decide to give wxPython a go, make sure to download the demo, it has tons of usefull code samples. -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython memory footprint? - Re: Write a GUI for a python script?
> What is the minimal memory footprint of a Hello World wxPython app > meanwhile (when you cx_freeze/py2exe it) it's kinda weird actually... I'm not 100% sure, but i think it relates more to py2exe options, not neccessarily to wxPython. in any case the least memory usage i've seen for an app that has at least some degree of functionality is around 12k running on win2000. But a much more complicated and larger app uses about 16k, while another small app uses like 20k... ??? -- http://mail.python.org/mailman/listinfo/python-list
Re: string stripping issues
from the python manual: strip( [chars]) The chars argument is not a prefix or suffix; rather, all combinations of its values are stripped: >>> 'www.example.com'.strip('cmowz.') 'example' in your case since the letter 'H' is in your [chars] and the name starts with an H it gets stripped, but with the second one the first letter is a K so it stops there. Maybe you can use: >>> a[31:] 'Hughes. John\r\n' >>> b[31:] 'Kim, Dong-Hyun\r\n' but maybe what you REALLY want is: >>> a[31:-14] 'Hughes. John' >>> b[31:-14] 'Kim, Dong-Hyun' -- http://mail.python.org/mailman/listinfo/python-list
Re: in need of some sorting help
arrrg i did it again, not enough explanation... new to asking for programing help online. anyway the reason is that the list can be rearanged later in the program by another function, and i need a way to put it in order again.. so yes it is doing some pretty funky stuff, lol. so although your method works well, it would have been problematic for me to implement a two list system in the app for various reasons. but you did make me understand a way to sort this thing finally: sort by base path then by full path, which is how i came up with: files.sort(key=lambda x: x.lower()) files.sort(key=lambda x: os.path.dirname(x)) well actually i am sorting first by full name, then by base, taking advantage of python2.4's stable sort(). If you can think of a more efficient (faster) way of doing this please let me know. i'm not crazy about having to sort this list twice, it can get pretty big (50,000 entries) anyway thanks all, this thing had me stuck for over a month !! -- http://mail.python.org/mailman/listinfo/python-list
Re: in need of some sorting help
sweet that works great! thanks again for all the help. -- http://mail.python.org/mailman/listinfo/python-list
id3 encoding testing
hey all, anybody know where i can download some mp3's and/or other file formats that use id3 tags in different encodings? working on an app that retrieves id3 info, and all the mp3's i have come across so far use iso-8859-1 encoding. i would like to test: 'Eastern Europe (iso-8859-2)' 'Cyrillic (iso-8859-5)' 'Arabic (iso-8859-6)' 'Greek (iso-8859-7)' 'Hebrew (iso-8859-8)' 'Turkish (iso-8859-9)' 'Nordic (iso-8859-10)' 'Japanese (iso2022_jp)' 'Korean (iso2022_kr)' 'utf_8' 'utf_16' thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Colored text
On Aug 12, 10:05 pm, Rohan <[EMAIL PROTECTED]> wrote: > Hello, > Can some one tell me how do I get colored text. Say when I want to > write something in a text file , how do I get it colored. Plain text files don't have color. You could output in html ... -- http://mail.python.org/mailman/listinfo/python-list
wx.ListBox drag and drop
Hey all, I see plenty of drag and drop examples but they are all for wx.ListCtrl. Anyone know of examples or tutorials for wx.ListBox? Specifically, I would like to be able to drag a selection from one ListBox to another. Thanks in advance, - ianaré -- http://mail.python.org/mailman/listinfo/python-list
Re: Colored text
On Aug 13, 1:50 am, Rohan <[EMAIL PROTECTED]> wrote: > On Aug 12, 10:01 pm, ianaré <[EMAIL PROTECTED]> wrote: > > > On Aug 12, 10:05 pm, Rohan <[EMAIL PROTECTED]> wrote: > > > > Hello, > > > Can some one tell me how do I get colored text. Say when I want to > > > write something in a text file , how do I get it colored. > > > Plain text files don't have color. You could output in html ... > > Oh ok what about a csv file, I know its also a text file but I want > the color to be say blue in an excel sheet. CSV is also pretty much plain text. No support for formatting. You will need to write xls files. Personaly, I avoid proprietary file formats like the plague, but this may be what you're looking for: http://www.answermysearches.com/index.php/generate-an-excel-formatted-file-right-in-python/122/ -- http://mail.python.org/mailman/listinfo/python-list
function call
Hey all, Is there a way of printing out how a function was called? In other words if I do the following: def someFunction(self): self.someOtherFunction(var1, var2) I would get something like "someOtherFunction: called by: someFunction, args are: var1, var2" Thanks in advance - ianaré -- http://mail.python.org/mailman/listinfo/python-list
Re: function call
> > Every reasonable use case for this (and several unreasonable ones) > > that I've encountered (and some that I've just imagined) can be better > > addressed with a trace function (sys.set_trace) than by trying to do > > this at the point of call. > > Indeed. Thanks for the correction. > > > relevant doc here:http://docs.python.org/lib/debugger-hooks.html > Thanks for your help. I was hoping to see a quick and easy way to do this, so this was helpful for this particular situation. I did not want to set up a debugger, although I am aware it's the "correct" thing to do ... Cheers! -- http://mail.python.org/mailman/listinfo/python-list
call to function by text variable
yeah the subject doesn't really make sense does it? anyway want I want to do is this: if n == 1: self.operations.insert(pos, operations.Replace.Panel(self, main)) elif n == 2: self.operations.insert(pos, operations.ChangeCase.Panel(self, main)) elif n == 3: self.operations.insert(pos, operations.Move.Panel(self, main)) As you can see all the different functions have the same variables, so it would be easier if I could just make a list and use that. like this: list = ["Replace", "ChangeCase", "Move"] textVariable = list[n] self.operations.insert(pos, operations.[textVariable].Panel(self, main)) Is something sort of like that possible? TIA -- http://mail.python.org/mailman/listinfo/python-list
Re: call to function by text variable
Cool now I can run it through the translator. ops = (_("Directory"), _("Replace"), _("ChangeCase"), _("Move"), _("Swap"), _("Insert"), _("ChangeLength")) self.operations.insert(pos, getattr(operations, ops[n]).Panel(self, main)) Thanks guys! -- http://mail.python.org/mailman/listinfo/python-list
Re: call to function by text variable
On Mar 25, 7:01 pm, "ianaré" <[EMAIL PROTECTED]> wrote: > Cool now I can run it through the translator. > > ops = (_("Directory"), _("Replace"), _("ChangeCase"), >_("Move"), _("Swap"), _("Insert"), _("ChangeLength")) > > self.operations.insert(pos, getattr(operations, ops[n]).Panel(self, > main)) > > Thanks guys! erm ... brainfart LOL. But now I can link it to the translated list. -- http://mail.python.org/mailman/listinfo/python-list
only loading a language installed on system
i'm doing this: mylocale = wx.Locale(wx.LANGUAGE_POLISH, wx.LOCALE_LOAD_DEFAULT) if not wx.Locale.IsOk(mylocale): mylocale = wx.Locale(wx.LANGUAGE_DEFAULT, wx.LOCALE_LOAD_DEFAULT) and getting this: Segmentation fault (core dumped) I'm trying to see if I can properly load a language. If the system will not load it, then use system default. What am I doing wrong? TIA -- http://mail.python.org/mailman/listinfo/python-list
real time updating of popen, bufsize=0 problems
hey all, I'm trying to get real time updates of batch file output. Here is my batch file: @echo off echo 1 @ping 127.0.0.1 -n 2 -w 1500 > nul echo 2 @ping 127.0.0.1 -n 2 -w 1500 > nul echo 3 If I run it in cmd.exe it will print "1", wait 15sec, print "2", wait 15sec, print "3". I tried doing it like this: r, w, e = popen2.popen3('"C:/path/to/test.bat"',bufsize=0) for line in r: self.display.WriteText(line) ... but get: ValueError: popen3() arg 3 must be -1 If I use -1, then it waits for the batch file to complete, and prints out all 3 lines at once. So I tried subprocess: proc = subprocess.Popen('"C:/path/to/test.bat"', bufsize=0, stdout=subprocess.PIPE) for line in proc.stdout: self.display.WriteText(line) No error message, but no real time printing either. info: self.display is a wx.TextCtrl - not that it should matter,as 'WriteText()' behaves basically like 'print' winXP pro SP2, python 2.5, wxPython 2.6.3.3 You help is appreciated. -- http://mail.python.org/mailman/listinfo/python-list
Re: real time updating of popen, bufsize=0 problems
On Apr 6, 3:22 pm, [EMAIL PROTECTED] wrote: > On Apr 6, 1:44 pm, "ianaré" <[EMAIL PROTECTED]> wrote: > > > > > hey all, I'm trying to get real time updates of batch file output. > > > Here is my batch file: > > @echo off > > echo 1 > > @ping 127.0.0.1 -n 2 -w 1500 > nul > > echo 2 > > @ping 127.0.0.1 -n 2 -w 1500 > nul > > echo 3 > > > If I run it in cmd.exe it will print "1", wait 15sec, print "2", wait > > 15sec, print "3". > > > I tried doing it like this: > > > r, w, e = popen2.popen3('"C:/path/to/test.bat"',bufsize=0) > > for line in r: > > self.display.WriteText(line) > > > ... but get: ValueError: popen3() arg 3 must be -1 > > > If I use -1, then it waits for the batch file to complete, and prints > > out all 3 lines at once. > > > So I tried subprocess: > > proc = subprocess.Popen('"C:/path/to/test.bat"', bufsize=0, > > stdout=subprocess.PIPE) > > for line in proc.stdout: > > self.display.WriteText(line) > > > No error message, but no real time printing either. > > > info: > > self.display is a wx.TextCtrl - not that it should matter,as > > 'WriteText()' behaves basically like 'print' > > winXP pro SP2, python 2.5, wxPython 2.6.3.3 > > > You help is appreciated. > > Hi, > > I think this script on another post will help: > > http://groups.google.com/group/comp.lang.python/msg/9fa3a3c287e8e2a3?... > > The 4 line code example (from Daniel) in one of the posts at this link > worked with your batch > file:http://www.velocityreviews.com/forums/t350573-redirect-ossystem-outpu... > > Mike Thanks but it doesn't work. Still prints it out all at once. It is supposed to print, then wait 15sec for the next line to print. -- http://mail.python.org/mailman/listinfo/python-list
Re: real time updating of popen, bufsize=0 problems
On Apr 6, 3:59 pm, Rob Wolfe <[EMAIL PROTECTED]> wrote: > "ianaré" <[EMAIL PROTECTED]> writes: > > hey all, I'm trying to get real time updates of batch file output. > > [...] > > > So I tried subprocess: > > proc = subprocess.Popen('"C:/path/to/test.bat"', bufsize=0, > > stdout=subprocess.PIPE) > > Instead of that: > > > for line in proc.stdout: > > self.display.WriteText(line) > > try that: > > while True: > line = proc.stdout.readline() > if not line: break > self.display.WriteText(line) > > When a file is used in a for loop it works like an iterator. > You can read details here (description of method > ``next``):http://docs.python.org/lib/bltin-file-objects.html > > -- > HTH, > Rob Rob, you are the man =) thanks! -- http://mail.python.org/mailman/listinfo/python-list
huge slowdown on append
Hey all, I have a for loop which included the line: items_ren.append(join(newPath,renamedItem)) I changed it to this: items_ren.append([join(newPath,renamedItem), False]) And processing speed is now much much slower. For 5780 items the old function would take 9.5 seconds (there is other stuff going on obviously), after changing that single line, speed is now 55 seconds in the same conditions! Can anyone give me some pointers please? I would like to keep the same structure if possible, as it allows the code in other places to be much faster. TIA BTW, the 'join' function is this: def join(newPath,renamedItem): return unicode(os.path.join(newPath,renamedItem)) -- http://mail.python.org/mailman/listinfo/python-list
Re: How to handle multi-line quotes
On Dec 21, 2:15 pm, [EMAIL PROTECTED] wrote: > Thinking about unclosed multi-line quotes. > > When you open a multi-line quote (type '"""') what does your editor > do? Does it color the remainder of your text as a quote, or does it > color the line with the open quote as a quote and leave the rest of > your code alone? > > What do you want it to do? > > This is a tokenizer question in disguise, of course. The simple way to > handle it, which is what my editor sees, is for the tokenizer to > return the remainder of the text as one great UNCLOSED_MULTILINE_QUOTE > token. The alternative is to assume that the line with the unclosed > quote is in error and to continue to tokenize the rest. An editor > might blink or otherwise draw attention to the unmatched quote. All the editors I use (Gedit, notepad++, boa contructor) will color the remainder of the document as a quote until I close it. I would say keep it that way, but maybe I'm only saying that since I'm so used to this behavior. -- http://mail.python.org/mailman/listinfo/python-list
Re: mac dashboad
On Dec 21, 12:37 pm, Carl K <[EMAIL PROTECTED]> wrote: > How do I hang an app off the mac dashboard? > > The goal is a python version of Weatherbug. > > something like: > read xml data from a URL, > display some numbers, > mouse over shows more details > > Carl K What is the dashboard - is it anything like the taskbar in windows/ Gnome? If it is, take a look at this: http://www.wxwidgets.org/manuals/2.6.3/wx_wxtaskbaricon.html -- http://mail.python.org/mailman/listinfo/python-list
Re: huge slowdown on append
On Dec 21, 3:29 pm, "ianaré" <[EMAIL PROTECTED]> wrote: > Hey all, > > I have a for loop which included the line: > > items_ren.append(join(newPath,renamedItem)) > > I changed it to this: > items_ren.append([join(newPath,renamedItem), False]) > > And processing speed is now much much slower. For 5780 items the old > function would take 9.5 seconds (there is other stuff going on > obviously), after changing that single line, speed is now 55 seconds > in the same conditions! > > Can anyone give me some pointers please? I would like to keep the same > structure if possible, as it allows the code in other places to be > much faster. TIA > > BTW, the 'join' function is this: > def join(newPath,renamedItem): > return unicode(os.path.join(newPath,renamedItem)) Seems like I found a way ... Use the old way, then at the end of the for loop add the 'False'. def addStatus(x): return (x,False) items_ren = map(addStatus, items_ren) 9.5 seconds wOOt! However, if anyone has a faster way, let me know! -- http://mail.python.org/mailman/listinfo/python-list
gettext errors with wxPython in linux
given the foolowing code: import gettext gettext.install('messages', './locale', unicode=0) def __init__(self, parent): # initialise preferences self.prefs = self.getPrefs() # initialise language: language = self.prefs['language='] langdir = self.realPath('./locale') Lang = gettext.translation(domain='messages', localedir=langdir, languages=[language]) Lang.install() # return full path: def realPath(self, file): return os.path.join(sys.path[0],file) and using following structure: application_folder/locale/fr/LC_MESSAGES/messages.mo works fine in windows2k, XP, however under linux: IOError: [Errno 2] No translation file found for domain: 'messages' what gives? thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: sorting for recursive folder rename
On Dec 16 2008, 7:36 pm, "Rhodri James" wrote: > On Tue, 16 Dec 2008 18:20:52 -, ianaré wrote: > > Hello all, > > > I trying to recursivelyrenamefolders and files, and am looking for > > some ideas on the best way of doing this. The problem is that the > > given list of items can be in order, and one to all items may be > > renamed. Here is some preliminary code I have, but which does not work > > very well. self.toRename has the following structure : [ [original_name, new_name, os.path.isdir] .. ] # define these here for faster processing def split(item): return os.path.split(item) def addSep(path): return os.sep + path + os.sep def recursiveFolderSort(x,y): return cmp(y[0], x[0]) sortedRename = sorted(self.toRename) # make a list of all folders that will be processed foldersToAdjust = [] for item in sortedRename: if item[2] is False: oF = split(item[0])[1] # original folder name nF = split(item[1])[1] # new folder name if oF is not nF: foldersToAdjust.append((oF, nF)) # replace all occurences of folders in path for i in range(len(self.toRename)): for f in foldersToAdjust: oF = addSep(f[0]) # original folder name nF = addSep(f[1]) # new folder name self.toRename[i][0] = self.toRename[i][0].replace(oF,nF) self.toRename[i][1] = self.toRename[i][1].replace(oF,nF) if progressDialog.update(i) is False: error = 'cancelled' break # make sure renaming will be in correct order ! self.toRename.sort(recursiveFolderSort) > import os > > for item in self.toRename: > os.renames(item[0], item[1]) > > That's it. os.renames will take care of all the intermediate > directory creation so you don't even need to sort the list. > > -- > Rhodri James *-* Wildebeeste Herder to the Masses It's been a while since I decided to work on this again ... Anyway, if only it were that easy !! Traceback (most recent call last): File "/home/ianare/Desktop/file-folder-ren/metamorphose2/Source/ MainWindow.py", line 1477, in renameItems os.renames(original[0], renamed[0]) File "/usr/lib/python2.5/os.py", line 213, in renames rename(old, new) OSError: [Errno 2] No such file or directory The problem is that if a directory is changed, all lower instances need to be changed as well. given the following directory structure ... recursive | |_1 | |_1 | | |_1.txt | | |_2.txt | |_2 | |_1.txt | |_2.txt |_2 |_1 | |_1.txt | |_2.txt |_2 |_1.txt |_2.txt ... and assuming I want to change : recursive/2/2/2.txt --> recursive/2/2/14.txt but, I ALSO want to change : recursive/2 --> recursive/04 it means that the first operation is really : recursive/04/2/2.txt --> recursive/04/2/14.txt os.renames will work, but it needs to have the correct path, so it comes down to the same thing. IOW, I need a way of : A) adjusting paths taking into consideration all changes up and down the tree B) sorting normalized paths so they are renamed in the proper sequence (depends on point 'A', obviously) I'm pretty sure I can take care of 'B' with the following sorting method: # order by path depth def recursiveFolderSort(x, y): x = x[0].count(os.sep) y = y[0].count(os.sep) return cmp(x, y) self.toRename.sort(recursiveFolderSort) but I still need a way of generating the correct names. Solution finder will have his/her name placed on the credits page. http://file-folder-ren.sourceforge.net/index.php?page=Links Thanks in advance !! -- http://mail.python.org/mailman/listinfo/python-list
Re: Copying files in directory
On Dec 15, 9:49 pm, pacsciad...@gmail.com wrote: > I'm writing a project management system, and I need the ability to > accept a directory name and move its contents to another directory. > Can someone give me a code sample that will handle this? I can't find > any "copying" functions in os or os.path. > > Regards, > LeafStorm shutil's move function does what you describe -- http://mail.python.org/mailman/listinfo/python-list
Re: ethical questions about global variables
For anything more complicated than a simple script, I find it easier to use some sort of config object. This could be a simple dictionnary type class, where the values can be set/retrieved by the other classes directly, or a more elaborate class including functions to set/ retrieve the variables. This way setting/retrieving can be 'smart' -- possibly looking at other variables, program states, thread count, whatever, for the requested config option. It also allows for a lot of expansion down the line if need be, rather than dealing with all sorts of global variables floating around - which gets annoying pretty quickly. On Dec 15, 9:45 pm, "Giampaolo Rodola'" wrote: > Hi, > in a module of mine (ftpserver.py) I'd want to add a (boolean) global > variable named "use_gmt_times" to decide whether the server has to > return times in GMT or localtime but I'm not sure if it is a good idea > because of the "ethical" doubts I'm gonna write below. > > In first place I've never liked global variables too much and always > preferred per-class-instance variables instead. > The problem in my case is that I have to use such variable in two > separated classes: FTPHandler and VirtualFileSystem. Also, I want that > for no reason one class uses times in GMT and the other one local > times. > > Another doubt is the naming convention. PEP-8 states that global > variables should use the lower_case_naming_convention but I've seen a > lot of library module using the UPPER_CASE_NAMING_CONVENTION. What am > I supposed to do about it? > > Thanks in advance for any comment. > > --- Giampaolohttp://code.google.com/p/pyftpdlib/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python plugin for Netbeans
On Dec 15, 3:23 pm, a wrote: > Netbeans added a python plugin to its plugin repository. > Do you tried it? What do you think about this plugin? If you like netbeans already it's great to finally have python officially supported. I find netbeans to be easier to use than eclipse. -- http://mail.python.org/mailman/listinfo/python-list
sorting for recursive folder rename
Hello all, I trying to recursively rename folders and files, and am looking for some ideas on the best way of doing this. The problem is that the given list of items can be in order, and one to all items may be renamed. Here is some preliminary code I have, but which does not work very well. self.toRename has the following structure : [ [original_name, new_name, os.path.isdir] .. ] # define these here for faster processing def split(item): return os.path.split(item) def addSep(path): return os.sep + path + os.sep def recursiveFolderSort(x,y): return cmp(y[0], x[0]) sortedRename = sorted(self.toRename) # make a list of all folders that will be processed foldersToAdjust = [] for item in sortedRename: if item[2] is False: oF = split(item[0])[1] # original folder name nF = split(item[1])[1] # new folder name if oF is not nF: foldersToAdjust.append((oF, nF)) # replace all occurences of folders in path for i in range(len(self.toRename)): for f in foldersToAdjust: oF = addSep(f[0]) # original folder name nF = addSep(f[1]) # new folder name self.toRename[i][0] = self.toRename[i][0].replace(oF,nF) self.toRename[i][1] = self.toRename[i][1].replace(oF,nF) if progressDialog.update(i) is False: error = 'cancelled' break # make sure renaming will be in correct order ! self.toRename.sort(recursiveFolderSort) First problem is adjusting the paths can take a very long time. Second problem is sorting is not always right and files get lost !! Any input welcome. -- http://mail.python.org/mailman/listinfo/python-list
Re: sorting for recursive folder rename
On Dec 16, 2:00 pm, MRAB wrote: > ianaré wrote: > > Hello all, > > > I trying to recursively rename folders and files, and am looking for > > some ideas on the best way of doing this. The problem is that the > > given list of items can be in order, and one to all items may be > > renamed. Here is some preliminary code I have, but which does not work > > very well. > > > self.toRename has the following structure : > > [ > > [original_name, new_name, os.path.isdir] > > .. > > ] > > > # define these here for faster processing > > def split(item): > > return os.path.split(item) > > def addSep(path): > > return os.sep + path + os.sep > > def recursiveFolderSort(x,y): > > return cmp(y[0], x[0]) > > > sortedRename = sorted(self.toRename) > > > # make a list of all folders that will be processed > > foldersToAdjust = [] > > for item in sortedRename: > > if item[2] is False: > > if not item[2]:> oF = split(item[0])[1] # original folder name > > nF = split(item[1])[1] # new folder name > > if oF is not nF: > > if oF != nF:> foldersToAdjust.append((oF, nF)) > > > # replace all occurences of folders in path > > for i in range(len(self.toRename)): > > for f in foldersToAdjust: > > oF = addSep(f[0]) # original folder name > > nF = addSep(f[1]) # new folder name > > self.toRename[i][0] = self.toRename[i][0].replace(oF,nF) > > self.toRename[i][1] = self.toRename[i][1].replace(oF,nF) > > > if progressDialog.update(i) is False: > > if not progressDialog.update(i):> error = 'cancelled' > > break > > > # make sure renaming will be in correct order ! > > self.toRename.sort(recursiveFolderSort) > > > First problem is adjusting the paths can take a very long time. > > Second problem is sorting is not always right and files get lost !! > > Any input welcome. > > You should use "is" and "is not" _only_ when checking for _identity, ie > are these 2 both references to the _same_ object. Most of the time that > would be "x is None" or "x is not None". Thanks, this has been corrected. -- http://mail.python.org/mailman/listinfo/python-list
suse linux 10 and wx.listctrl display issues
hey, Having some problems getting wxpython apps to look right on SuSE 10.0 and KDE 3.4. There are no RPMs that i could find so I built my own from source. First time using 'default' settings - GTK 2.x and unicode: rpmbuild -tb --define 'pyver 2.4' --define 'port gtk2' \ --define 'unicode 1' wxPython-src-2.6.2.1.tar. I can run my apps but they look, well, funky. Mainly the background color for my wx.listctrl's are unchangeable, and these default to the same color as the window background, making them hard to see. Also some widgets are positioned improperly... although i could maybe fix this by tweaking sizers around. I had an earlier (prior to HDD crash :( ) debian 3.1 install and everything was fine, using similar configs... though i'm fairly sure the KDE version was lower. I tried several different window styles and themes to no avail. Finally I tried making another set of RPMs, this time like so: rpmbuild -tb --define 'pyver 2.4' --define 'port gtk' \ --define 'unicode 0' wxPython-src-2.6.2.1.tar. (using GTK 1.2, ansi build).. and now my I can see my lists properly but everything else looks absolutly disgusting !! looks like circa 1990 LOL, besides it's very hard to see anything due to tiny text and oddly shaped/shaded widgets. Is there a fix, or at least a step in the right direction for this? I'm really liking SuSE 10 otherwise -especially YaST - and don't really want to go back to debian over a wx.listctrl. -- http://mail.python.org/mailman/listinfo/python-list
Re: suse linux 10 and wx.listctrl display issues
hum finally did find some SuSE specific RPM's through yast by setting the media directory to mirros.kernel.org. Cool. But still the same thing happens... -- http://mail.python.org/mailman/listinfo/python-list
Re: suse linux 10 and wx.listctrl display issues
Well that definitly works, thanks. Is there any way to keep the themes though? -- http://mail.python.org/mailman/listinfo/python-list
wxPython problem with freeze.py
I have a wxPython application that i can run no problem from source, now i want to freeze it for distribution. I tried the freeze.py script and got the following output: freezing Frame1 ... freezing UserDict ... freezing __main__ ... freezing codecs ... freezing copy ... freezing copy_reg ... freezing dis ... freezing distutils ... freezing distutils.dep_util ... freezing distutils.errors ... freezing distutils.log ... freezing distutils.spawn ... freezing distutils.util ... freezing dummy_thread ... freezing encodings ... freezing encodings.aliases ... freezing inspect ... freezing linecache ... freezing locale ... freezing macpath ... freezing ntpath ... freezing opcode ... freezing os ... freezing os2emxpath ... freezing popen2 ... freezing posixpath ... freezing py_compile ... freezing random ... freezing re ... freezing repr ... freezing site ... freezing sitecustomize ... freezing sre ... freezing sre_compile ... freezing sre_constants ... freezing sre_parse ... freezing stat ... freezing string ... freezing tempfile ... freezing token ... freezing tokenize ... freezing traceback ... freezing types ... freezing warnings ... freezing wx ... freezing wx.__version__ ... freezing wx._controls ... freezing wx._core ... freezing wx._gdi ... freezing wx._misc ... freezing wx._windows ... generating table of frozen modules Warning: unknown modules remain: _locale _random array binascii fcntl itertools math pwd strop time wx._controls_ wx._core_ wx._gdi_ wx._misc_ wx._windows_ Now run "make" in frozen to build the target: csv_generator What's going on? says it's freezing then says it can't find it ?!? Anyway continued and ran make, no errors. When I run the application I get: Traceback (most recent call last): File "csv_generator.py", line 4, in ? File "/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/__init__.py", line 42, in ? from wx._core import * File "/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/_core.py", line 4, in ? import _core_ ImportError: No module named _core_ Can someone help with this? Running OpenSuSE 10, all relevant packages installed through YaST. TIA! -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode question : turn "José" into u"José"
maybe a bit off topic, but how does one find the console's encoding from within python? -- http://mail.python.org/mailman/listinfo/python-list
Re: cross platform distribution
These are all good suggestions. I just wanted to add that you can distribute pre-built Linux packages for the most popular distros like one for RHEL/Centos/Fedora as RPM and one for Debian/Ubuntu as DEB. Any C code in them would be compiled. On Sep 4, 9:33 am, Philip Semanchuk wrote: > On Sep 4, 2009, at 9:24 AM, vpr wrote: > > > > > On Sep 4, 3:19 pm, Philip Semanchuk wrote: > >> On Sep 4, 2009, at 4:44 AM, vpr wrote: > > >>> Hi All > > >>> After a couple of experiments, searching around and reading Steve > >>> Holden's lament about bundling and ship python code, I thought I'd > >>> direct this to to the group. I'm using Python 2.6 btw. > > >>> I've build a commercial application that I'd like to bundle and > >>> ship. > >>> I'd like to protect some of my IP and the py2exe and cx_freeze > >>> builds > >>> provide good enough protection for me. > > >>> I'd like to provide a build for windows and a build for linux. > >>> Windows > >>> ironically has been easier to target and py2exe has given me a nice > >>> build that I can ship between XP, Vista & Server on both 32 and 64 > >>> bit. > > >>> On linux I've build a build using cx_freeze which works well except > >>> it's not really portable betweem distributions. > > >>> I've also been thinking about distributing bytcode versions but > >>> things > >>> get tricky quickly. > > >>> Can anywone give me some pointers? > > >> I don't know how much "critical" code you have, but you might want to > >> look at Cython which will translate your Python into C with little > >> change to your Python source. Of course, compiled C code can still be > >> disassembled, but it's harder than Python bytecode. > > >> HTH > >> P > > > Hi Peter > > It's Philip, actually. =) > > > Sounds like a plan, how portable will that be between Linux systems? > > Very portable, but I should have mentioned that it requires you to > distribute a C file that's compiled on the user's machine. That's easy > to do via distutils but it adds a requirement to your app. > > > Won't I run into some GLIBC problems? > > Can you force it to statically link the binary? > > I don't know the answer to those questions, but it's just a regular C > file, albeit one that's autogenerated. It comes with all of the pros > and cons of a C file you'd written yourself. > > Good luck > Philip -- http://mail.python.org/mailman/listinfo/python-list