<div class="gmail_quote">On Sat, Feb 11, 2012 at 2:03 PM, Walter Prins <span dir="ltr">&lt;<a href="mailto:wprins@gmail.com">wprins@gmail.com</a>&gt;</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&#39;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&#39;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 &lt;<a href="mailto:wprins@gmail.com">wprins@gmail.com</a>&gt;<br>Date: 8 February 2012 01:29<br>Subject: Re: [Tutor] Cmd Advice<br>To: Dave Hanson &lt;<a href="mailto:dave@hansonforensics.co.uk">dave@hansonforensics.co.uk</a>&gt;<br>
<br><br>HI Dave,<br><br><br>On 7 February 2012 16:55, Dave Hanson &lt;<a href="mailto:dave@hansonforensics.co.uk">dave@hansonforensics.co.uk</a>&gt; wrote:<br>&gt;<br>&gt; I tried what you said, many attempts result in this message:<br>
&gt;<br>&gt;&gt;<br>&gt;&gt; C:\Documents and Settings\dhanson2\Desktop&gt;&quot;C:\Python27\python.exe&quot; &quot;C:\t.py&quot;<br>&gt;&gt;<br>&gt;&gt; C:\Python27\python.exe: can&#39;t open file &#39;C:\t.py&#39;: [Errno 2] No such file or directory<br>
&gt;<br>&gt;<br>&gt; I&#39;ve tried moving t.py around but still no joy?<br>&gt;<br>&gt; Here is what I put in my bat file with and without the quotes:<br>&gt;<br>&gt;&gt;<br>&gt;&gt; &quot;C:\Python27\python.exe&quot; &quot;C:\t.py&quot; %1 %2 %3 %4 %5 %6 %7 %8 %9<br>
&gt;<br>&gt;<br><br>The error message implies that the program &quot;t.py&quot; is in the root of<br>your C:\ drive?  I&#39;d have thought this would not be the case -- you<br>need to give the correct path to the &quot;t.py&quot; 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>
&quot;Documents and Settings&quot; 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&#39;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&#39;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 &quot;C:\Users\walterp\Documents\Python&quot;<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 &quot;t&quot; 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 &quot;t.bat&quot; in<br>&quot;C:\Users\walterp\Documents\Python\t&quot;, so the full filename is<br>
&quot;C:\Users\walterp\Documents\Python\t\t.bat&quot;, containing these lines:<br><br>@echo off<br>c:<br>cd C:\Users\walterp\Documents\Python\t<br>c:\python27\python.exe &quot;C:\Users\walterp\Documents\Python\t\t.py&quot; %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 &quot;@echo off&quot; line, and then setting up the environment<br>
prior to running the t.py program such that it will always run having<br>the &quot;current working folder&quot; 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&#39;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 &quot;system wide&quot; 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&#39;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&#39;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 &quot;run from<br>
source&quot; and don&#39;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&#39;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&#39;s method to create a &#39;fake shell&#39; 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&#39;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&#39;ll post what I come up with (If I&#39;m able to come up with something) somewhere incase it&#39;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>