On Sat, Feb 11, 2012 at 2:03 PM, Walter Prins <wpr...@gmail.com> wrote:
> Hi all, > > Below is an *earlier* (note the date) private response by myself that > at the time accidentally didn't get sent to the list and only to Dave > (as he privately replied to me only and not to the list.) Given that > the thread on the list has resumed, I thought I'd forward this to the > thread for completeness sake as otherwise a bit of context might be > lost. > > Regards, > > Walter > > > ---------- Forwarded message ---------- > From: Walter Prins <wpr...@gmail.com> > Date: 8 February 2012 01:29 > Subject: Re: [Tutor] Cmd Advice > To: Dave Hanson <d...@hansonforensics.co.uk> > > > HI Dave, > > > On 7 February 2012 16:55, Dave Hanson <d...@hansonforensics.co.uk> wrote: > > > > I tried what you said, many attempts result in this message: > > > >> > >> C:\Documents and Settings\dhanson2\Desktop>"C:\Python27\python.exe" > "C:\t.py" > >> > >> C:\Python27\python.exe: can't open file 'C:\t.py': [Errno 2] No such > file or directory > > > > > > I've tried moving t.py around but still no joy? > > > > Here is what I put in my bat file with and without the quotes: > > > >> > >> "C:\Python27\python.exe" "C:\t.py" %1 %2 %3 %4 %5 %6 %7 %8 %9 > > > > > > The error message implies that the program "t.py" is in the root of > your C:\ drive? I'd have thought this would not be the case -- you > need to give the correct path to the "t.py" file for Python to load > it. (And as an aside, you need to quote paths if theycontains spaces, > otherwise the command prompt will interpret the first part up to a > space in the path as the path/command and the remainder of the path as > a command line argument! (One subtlety of command lines...) The > "Documents and Settings" folder on Windows XP was therefore very > unfortunately chosen since the spaces causes endless problems with > people not realising this and trying to use files located inside > Documents and Settings. You'll notice on Windows 7 Microsoft has > wisely (at last) decided to shorten and remove spaces as much as > possible from paths to avoid gotchas with people forgetting to quote > paths, and similarly Python itself does not uses spaces in any of its > folder names. But I digress. > > Anyway, I've had a quick further look at this program and got it > working the way you want on my machine. The precise steps I followed > was: > 1.) Install Mercurial for Windows (to be able to checkout the source). > I got it here: http://tortoisehg.bitbucket.org/download/index.html > 2.) Retrieved the source code. On my machine I opened a command prompt, > and: > cd "C:\Users\walterp\Documents\Python" > hg clone https://bitbucket.org/sjl/t > > This creates a folder called "t" inside of my Python source folder. > Adjust folders as required for your machine and/or where you keep your > Python source. > > 3) Create a batch file called "t.bat" in > "C:\Users\walterp\Documents\Python\t", so the full filename is > "C:\Users\walterp\Documents\Python\t\t.bat", containing these lines: > > @echo off > c: > cd C:\Users\walterp\Documents\Python\t > c:\python27\python.exe "C:\Users\walterp\Documents\Python\t\t.py" %1 > %2 %3 %4 %5 %6 %7 %8 %9 > > The effect of these commands is to stop the command interpreter from > displaying the commands issues by the batch file (which is unwanted > here) via the "@echo off" line, and then setting up the environment > prior to running the t.py program such that it will always run having > the "current working folder" be the same folder that the t.py program > is located in. > > This is important since the t.py program currently assumes that it > will always be run from the same starting location, which is not the > case if you go and put the program on the command line search path so > that you can use it from any other working folder. (Without this, if > you run the program from another location, then the t.py program will > create a new task list in the new location -- basically the t.py > command will create and manage a task list in whatever folder you > happen to be in, so in order to ensure it always updates the same task > list, the lines above therefore ensures it always effectively runs > from the same place, regardless of where the batch file t.bat might > have been run from, thereby effectively ensuring it to always uses the > same task list file.) > > Also, note that in order to in fact use the t.bat file from any other > folder, you'll have to add the bat files location to you system (or > user) PATH variable. Do you know how to do this, and are you allowed > to do so, or are you blocked by your IT policies? If so you should > also be able to do this via e.g. another batch file, perhaps the same > one you use to circumvent the cmd.exe blocks on your system, by simply > adding it to the PATH variable there, e.g. a line like this ought to > do it: > PATH=%PATH%;C:\Users\walterp\Documents\Python\t > > Lastly a minor observation: I note this source code includes a > setup.py script. This implies you can install t.py into your Python > environment such that an .exe file will be created for it (really copy > of the t.py file and the python interpreter [I think, or a launcher of > some sort] combined) in the Python\Scripts folder. Some Python > distributions (e.g. Activestate IIRC) puts this folder onto the system > Path thereby making "system wide" installed Python packages/commands > (where appropriate) instantly usable from the command prompt, others > (e.g. standard Python on Windows) do not and leaves this step for you > to complete. Anyway, I've obviously not gone the route of installin > via setup.py, since installing this program in this way will make it > difficult/impossible for you to tinker/edit the program easily, and > I'm assuming you want to actually be able to edit the program (and > possibly submit patches back to the author?) while using it etc. So, > for this to be possible you actually need the t.py to "run from > source" and don't want to embedded in your Python environment, which > is what not using setup.py and doing the above effectively enables you > to do easily. (Aside: when I noticed the program isn't > location/working directory independent I immediately thought this > might be a useful patch/enhancement to make -- make it get the folder > location of itself and use that for the location of the tasks list > etc.) > > Let me know if you have further problems. > > Walter > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > Hi Guys, > Apologies again for my slow response. I tried Dave's method to create a 'fake shell' and also Walters methods - All result in: The command prompt has been disabled by your administrator. I think I'll just have to do some restructuring to the program and just use raw_input() with some kind of loop to keep the window open. I'll post what I come up with (If I'm able to come up with something) somewhere incase it's helps someone out. [For future reference - should I have snipped the previous message out of this email or trimmed it down a bit? Just thinking about my top posting telling off from DaveA during the weekend!] (only kidding Dave) :) Best Regards, Dave Hanson
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor