Stani's python ide 'spe' editor problem
Hi everyone, The editor in spe on my system (win XP home sp2) does not do automatic indentation. I can't figure out why - it used to. I'm set up with subversion so I have the very latest stuff from Stani. It's amazing how not having automatic indentation can make working in the ide such a pain. This has been going on for a while (like a few years), and the situation is deteriorating - used to be that the indentation would work for a while after restarting my system and then stop (until the next restart). Now, with his latest stuff, it doesn't work at all. Because it used to reset with a restart, it must have something to do with a dll, like the scintilla editor dll? But that's kind of hard to believe: why would the editor dll care about indentation? Anyway, I am extremely frustrated. I've tried other ide's: pythonwin (I found it inadequate for my purposes - why is a command line prompt displayed in a dialog window?) - eclipse (editor is just ok, shell does not have command history(!), and then *really* funky things started happening that I could not explain and so had to stop using it) - idle is good for small things and ok for larger projects but limited in general. I really like spe and want to continue using it. Stani himself seems pretty unreachable. Does anyone have a clue for me about what the issue is? Is no one else using this great ide? Or is no one else having this problem? Thanks for any help. -Rick King Southfield MI -- http://mail.python.org/mailman/listinfo/python-list
Stani's python ide 'spe' editor problem (again)
In my previous post about spe I didn't mention that my set up is: python 2.4.4 wxpython 2.8.3 thanks. -Rick King -- http://mail.python.org/mailman/listinfo/python-list
Re: Pydev shell (was: Re: Stani's python ide 'spe' editor problem)
I guess this is appropriate to the list... the funky things in eclipse that were happening are hard to describe, but first let me say that none of the other ide's had any funky things happening so I don't think it was my code. That said: I'm working on a command line bulk file renaming tool (using cmd.py) in which I can redirect input to a batch file if I want to, and redirect output to a file (for testing purposes). Running within an eclipse console, I could run through one batch file after which input returns to the console, and then try to run through the same batch file again by typing in my 'run' command; suddenly it would be as if a bunch of the tool's commands were executed having little (but something) to do with the batch of commands I just ran, producing a lot of output that didn't really make any sense. When I stepped through the debugger it got really weird: for example, at one point I went to the variables pane and clicked to open 'self' and it was at that moment that all this output came through on the console. Absolutely nonsensical. I'll check out the new stuff for eclipse. -Rick Fabio Zadrozny wrote: >> Anyway, I am extremely frustrated. I've tried other ide's: pythonwin (I >> found it inadequate for my purposes - why is a command line prompt >> displayed in a dialog window?) - eclipse (editor is just ok, shell does >> not have command history(!), and then *really* funky things started >> happening that I could not explain and so had to stop using it) - idle >> is good for small things and ok for larger projects but limited in general. >> > > Hi Rick, > > The new release has an actual console shell (with code-completion, > history, etc: see http://pydev.sourceforge.net/ for more details). > Aside from that, which 'funky' things started happening? > > Cheers, > > Fabio > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: urgent question, about filesystem-files
Could you first find out if it exists with isfile(..) and then try to open it? If it fails I *think* it would have to be open by another process. -Rick King Southfield MI bvidinli wrote: i started python programming a few months ago. now i need the code to understand if a file already opened in filesystem by another process ? i looked at docs, howtos, but did not find related info. note that normal file open/write operations in python, i know it. i specificly need to know that "is a file already open by some other process other than python". Thank you in advance -- http://mail.python.org/mailman/listinfo/python-list
Re: annoying dictionary problem, non-existing keys
dict also has 'get' which provides a default if the key isn't defined: a={} print a.get('a','default') default -Rick King southfield MI -- http://mail.python.org/mailman/listinfo/python-list
Subclassing datetime.date does not seem to work
I would like to subclass datetime.date so that I can write: d = date2('12312008') I tried: from datetime import date class date2(date): def __init__( self, strng ): mm,dd,yy = int(strng[:2]), int(strng[2:4]), int(strng[4:]) date.__init__(self,yy,mm,dd) But then this statement: d = date2('12312008') Causes: TypeError: function takes exactly 3 arguments (1 given) Is there something basically wrong with subclassing date? -Rick King -- http://mail.python.org/mailman/listinfo/python-list
uniicode and executing a process with subprocess.call, or os.system
Hello, I want to copy files using subprocess.call or os.system where the file names are non-ascii, e.g. Serbian(latin), c's and s's with hacheks,etc. Windows stores all the file names in unicode so they are displayed ok in explorer, and I can read them into my program with listdir(u'.'), etc. and work with the names in the program. os.rename() can be used to rename such files successfully. But I want to be able to copy files using: cmdstr = u'copy' +u' /Y "'+pair[0]+u'" "'+pair[1]+u'"\n' cmdstr = cmdstr.encode(sys.getfilesystemencoding()) try: retcode = sp.call(cmdstr, shell=True) #SP=SUBPROCESS but the encoding can't handle all the characters and so the file isn't found to be copied. sp.call() returns 1. 'mbcs' encoding doesn't work either. 'utf-8' doesn't work. I am very confused about unicode. Can someone point me in the right direction? windows xp sp2 python 2.6.2 unicode Thanks! Rick King Southfield MI -- http://mail.python.org/mailman/listinfo/python-list
Re: uniicode and executing a process with subprocess.call, or os.system
Thanks. I looked around for alternatives but didn't find this one. Rick Chris Rebert wrote: On Sat, Jul 18, 2009 at 3:30 PM, Rick King wrote: Hello, I want to copy files using subprocess.call or os.system where the file names are non-ascii, e.g. Serbian(latin), c's and s's with hacheks,etc. Windows stores all the file names in unicode so they are displayed ok in explorer, and I can read them into my program with listdir(u'.'), etc. and work with the names in the program. You should try one of the copying functions in the shutil module instead, it'll be much simpler than using subprocess: http://docs.python.org/library/shutil.html Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
py2exe-created exe results in "application failed to initialize"
Hi everyone, I want to package up an application into an exe using py2exe but the result produces the dreaded "application failed to initialize 0x142" error. I'm using wxPython and basically just took the sample for wxpython GUI that came with py2exe and changed the name. My setup is python 2.6, wxpython 2.8. My setup.py looks like the following. from distutils.core import setup import py2exe import sys class Target: def __init__(self, **kw): self.__dict__.update(kw) # for the versioninfo resources self.version = "0.1" self.company_name = "OWDC" self.copyright = "no copyright" self.name = "FileTool" manifest_template = ''' etc. ''' RT_MANIFEST = 24 FileTool = Target( description = "FileTool", script = "filetoolGUI.py", other_resources = [(RT_MANIFEST, 1, manifest_template % dict(prog="FileTool"))], dest_base = "FileTool") setup( options = {"py2exe": {"compressed": 1,"optimize": 2,"ascii": 1,"bundle_files": 1}}, zipfile = None, windows = [FileTool], ) Any help will be greatly appreciated! Rick King Southfield MI USA -- http://mail.python.org/mailman/listinfo/python-list
how to use "exec" stmt to get input from user
I have a cmd.py-derived program (with a wxPython GUI) and want to execute python statements for lines that are not my own special commands. So basically it's either: def do_somecommand(self,arg): ... or def default(self,arg): exec arg in globals(),self.cmdlocals (where cmdlocals is a my local dictionary) in default() I'd like to be able to execute any python statement including something like "x = raw_input('>')" when I do this though it goes to the command window and so any user of the program would be confused, which also means I have to have a command window. If I add this: self.stdin = self.edt_console_input (where self.edt_console_input is a wxPython text control) it just gets an EOF right away. Is there any way to do what I want to do? This might be better posted on the wxpython list. Thanks for any help! Rick King Southfield MI -- http://mail.python.org/mailman/listinfo/python-list
Re: how to use "exec" stmt to get input from user
Thanks for your comment. The purpose of the application is to automate the manipulation of large numbers of files. For automation I want to be able to have scripts that I can use for various purposes. On input, cmd.py handles calling "do_" methods for known commands; for the rest I want to "exec" the lines with my own dictionary. This allows me to use python statements, so I can do things like concatenating variables to form directory names, and so on. I'd like to be able to use any python statement, including "x=raw_input('>')", but this currently brings everything to a halt. One thing this app does is execute processes using wxPythons wx.Process object and wx.Execute function. wxPython makes it easy to redirect stdin and stdout. I'm trying to do a similar thing for individual python statements. I'm not sure that makes sense. I hope that's clear. Rick David C Ullrich wrote: What you're trying to do and what's not working isn't entirely clear to me. But if I had a wxPython application and I wanted to execute user input (note the _if_) I'd just pop up a window (I forget how "ShowModal" is spelled in wx right now) with a text box and an Execute button and a Cancel button - if the user hits the Execute button I'd attempt to execute what he'd typed in the box. There are reasons you want to be very careful about this... On Mon, 10 Aug 2009 13:44:17 -0400, Rick King wrote: I have a cmd.py-derived program (with a wxPython GUI) and want to execute python statements for lines that are not my own special commands. So basically it's either: def do_somecommand(self,arg): ... or def default(self,arg): exec arg in globals(),self.cmdlocals (where cmdlocals is a my local dictionary) in default() I'd like to be able to execute any python statement including something like "x = raw_input('>')" when I do this though it goes to the command window and so any user of the program would be confused, which also means I have to have a command window. If I add this: self.stdin = self.edt_console_input (where self.edt_console_input is a wxPython text control) it just gets an EOF right away. Is there any way to do what I want to do? This might be better posted on the wxpython list. Thanks for any help! Rick King Southfield MI -- http://mail.python.org/mailman/listinfo/python-list
Re: Sanitising arguments to shell commands
shlex doesn't handle unicode input though, so, in general, it's not a good solution. Rick King Southfield MI http://docs.python.org/library/shlex.html module shlex — Simple lexical analysis New in version 1.5.2. "The shlex class makes it easy to write lexical analyzers for simple syntaxes resembling that of the Unix shell." -- http://mail.python.org/mailman/listinfo/python-list