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