I've checked in changes to samples.py, resourceEditor.py, codeEditor.py and
findfiles.py that hopefully take care of spaces in both the Python
executable and script paths. Please report any problems directly to me
rather than the list and I'll iterate over some variations (if necessary) to
get this issue closed out. The changes impact Linux and Mac OS X, not just
Windows. I did some basic tests and didn't notice any problems, but that
doesn't mean I didn't introduce a quoting bug by mistake.
ka
> -----Original Message-----
> From: pythoncard-users-admin@...
> [mailto:pythoncard-users-admin@... Behalf Of
> Michael Sorich
> Sent: Sunday, November 10, 2002 3:18 PM
> To: pythoncard-users@...
> Subject: RE: [Pythoncard-users] run script path problem
>
>
> I am running version 0.6.9. Furthermore, I am using PythonCard with both
> Python 2.2.2 and 2.1.2 (there does not seem to be any difference between
> the two in terms of this problem).
>
> I ran a few experiments and it is the sys.executable variable that is
> the problem. Furthermore the value of sys.executable does vary depending
> on how you launch the script.
>
> If I run sample.py from the command line, then the value of
> sys.executable is c:\progra~1\python21\python.exe. In this case you can
> launch the example programs.
>
> If I run sample.py from codeEditor the value of sys.executable is
> c:\program files\python21\python.exe. In this case trying to launch the
> examples only results in the following being printed to the prompt:
> C:\program: can't open file 'Files\python21\python.exe'.
>
> The same happens with findfiles.
>
> However, when I run findfiles from the start menu and attempt to open a
> file found, the value of sys.executable is C:\Program
> Files\Python22\pythonw.exe. However, sys.executable is
> C:\PROGRA~1\Python22\python.exe for samples.py when run from the start
> menu. In this case samples.py works, while findfiles.py doesn't.
>
>
> If I use this,
> if ' ' in sys.executable:
> os.spawnv(os.P_NOWAIT, sys.executable, ['"'+sys.executable+'"',
> program] + args)
> else:
> os.spawnv(os.P_NOWAIT, sys.executable, [sys.executable, program]
> + args)
> samples and findfiles work under all three situations described above.
>
> Hope this helps. Let me know if there is anything else I can do.
>
>
> Michael Sorich
> PhD Student
> School of Pharmaceutical, Molecular and Biomedical Sciences
> University of South Australia
> Email: michael.sorich@...
> mike_sorich@...
>
>
> -----Original Message-----
> From: Kevin Altis [mailto:altis@...]
> Sent: Saturday, 9 November 2002 5:00 AM
> To: Michael Sorich
> Subject: RE: [Pythoncard-users] run script path problem
>
> Hi Michael,
> if you have time to do a little debugging with me that would be helpful.
> First of all, I want to make sure you are using the PythonCardPrototype
> that
> is in cvs or the version 0.6.9 release.
>
> I'm looking at the samples.py launch code and it looks like it is doing
> the
> same thing as the findfiles launch code, but I'll go ahead and make some
> adjustments. In particular, I'm using sys.executable, which seems to get
> quoted correctly, otherwise neither samples.py or findfiles.py should
> work.
> However, I guess that the problem might instead be the quoting on the
> program with findfiles, so perhaps this change would work:
>
> log.debug(args)
> if ' ' in program:
> program = '"' + program + '"'
> if sys.platform[:3]=='win':
> os.spawnv(os.P_NOWAIT, sys.executable, [sys.executable,
> program]
> + args)
>
> I deleted the commented lines for brevity here. The only new code is the
> if
> ' ' to add quotes. I'm going to update the samples.py code in the same
> way:
>
> if ' ' in filename:
> filename = '"' + filename + '"'
> if sys.platform[:3]=='win':
> os.spawnv(os.P_NOWAIT, sys.executable, [sys.executable,
> filename] + args)
>
> If this works we can move onto the resourceEditor and codeEditor.
>
> ka
>
> > -----Original Message-----
> > From: pythoncard-users-admin@...
> > [mailto:pythoncard-users-admin@... Behalf Of
> > Michael Sorich
> > Sent: Thursday, November 07, 2002 9:17 PM
> > To: pythoncard-users@...
> > Subject: RE: [Pythoncard-users] run script path problem
> >
> >
> > I am running Windows XP. Findfiles and resourceEditor do not work
> > without adjustment, however samples launcher seems to.
> >
> > Michael
> >
> >
> > -----Original Message-----
> > From: pythoncard-users-admin@...
> > [mailto:pythoncard-users-admin@...] On Behalf Of
> Kevin
> > Altis
> > Sent: Friday, 8 November 2002 11:48 AM
> > To: Michael Sorich; pythoncard-users@...
> > Subject: RE: [Pythoncard-users] run script path problem
> >
> > Which version of Windows are you using? I thought we solved this
> > problem,
> > but I guess I dropped the ball. You'll have similar issues with
> > findfiles,
> > the samples launcher, and the resourceEditor.
> >
> > ka
> >
> > > -----Original Message-----
> > > From: pythoncard-users-admin@...
> > > [mailto:pythoncard-users-admin@... Behalf Of
> > > Michael Sorich
> > > Sent: Thursday, November 07, 2002 3:32 PM
> > > To: pythoncard-users@...
> > > Subject: [Pythoncard-users] run script path problem
> > >
> > >
> > > Hi,
> > >
> > > I have just started to use PythonCard. Just thought you may want to
> > know
> > > about a bug/problem I may have found.
> > >
> > > My python path is c:\program files\python22 and when I tried to run
> > > scripts from the editors (eg CodeEditor) they would not work,
> because
> > > there was a space in the path.
> > >
> > > In the runScript function of the editor files, if I change
> > > os.spawnv(os.P_NOWAIT, python, [python, '-i', filename] + args)
> > > to
> > > os.spawnv(os.P_NOWAIT, python, ['"'+python+'"', '-i', filename] +
> > args)
> > > the scripts run (eg line 1017 in CodeEditor.py)
> > >
> > > Let me know if there is a better way to fix this.
> > >
> > > Cheers
> > >
> > > Michael Sorich
|