[Tutor] command history in a console

2008-09-17 Thread Hans Dushanthakumar
G'day everyone. I'm experimenting with a custom console application, and trying to add command history functionality to it. It seems to basically work ok except for the fact that when I press the Up arrow key to run previous commands, the right commands are not displayed. It displays a wierd

Re: [Tutor] clearing lines for a 'front end' to a tool

2008-09-17 Thread Kent Johnson
On Wed, Sep 17, 2008 at 6:20 PM, James <[EMAIL PROTECTED]> wrote: > Kent, > > Thanks for the response. As a personal opinion, do you find it more > appropriate to use something like curses (since it's already built > into the standard Python library), or to use something "third party" > like urwid?

[Tutor] recursive using the os.walk(path) from the os module

2008-09-17 Thread A. Joseph
Hi, I want to search through a directory and re-arrange all the files into e.g All .doc files go into MS WORD folder, all .pdf files goes into PDF Folder. I`m thinking of doing something with the os.walk(path) method from os module, I need some ideal how the algorithm should look like, maybe rec

Re: [Tutor] How to parse InputFile to generate OutputFile?

2008-09-17 Thread Kent Johnson
On Wed, Sep 17, 2008 at 5:08 PM, Kamisetty, Rajendra <[EMAIL PROTECTED]> wrote: > Hi, > I am new to Python and need your help to generate an output file as > explained below. > > I need to generate an output text file based on the input text file data . > > Input.txt contents: > ('146 - Message',

Re: [Tutor] Sort Output

2008-09-17 Thread Alan Gauld
"Wayne Watson" <[EMAIL PROTECTED]> wrote I was surprised to find the result below. Well done, you just found one of the standard beginners gotchas! a =[4,2,5,8] b = a This makes b refer to the *same list* as a. a.sort() This sorts the list contents in-place a [2, 4, 5, 8] As sh

Re: [Tutor] How to parse InputFile to generate OutputFile?

2008-09-17 Thread Alan Gauld
"Kamisetty, Rajendra" <[EMAIL PROTECTED]> wrote I am new to Python and need your help It will help if you start a new thread by posting a new message rather than replying to an existing one and changing the subject. Those of us with threaded readers don;t see your post because it is hidden ins

Re: [Tutor] clearing lines for a 'front end' to a tool

2008-09-17 Thread Alan Gauld
"James" <[EMAIL PROTECTED]> wrote Thanks for the response. As a personal opinion, do you find it more appropriate to use something like curses (since it's already built into the standard Python library), or to use something "third party" like urwid? urwid is just a wrapper around curses. curse

Re: [Tutor] clearing lines for a 'front end' to a tool

2008-09-17 Thread W W
On Wed, Sep 17, 2008 at 5:20 PM, James <[EMAIL PROTECTED]> wrote: > Kent, > > Thanks for the response. As a personal opinion, do you find it more > appropriate to use something like curses (since it's already built > into the standard Python library), or to use something "third party" > like urwid

Re: [Tutor] clearing lines for a 'front end' to a tool

2008-09-17 Thread James
Kent, Thanks for the response. As a personal opinion, do you find it more appropriate to use something like curses (since it's already built into the standard Python library), or to use something "third party" like urwid? This program will be distributed to lots of individuals that will likely no

Re: [Tutor] clearing lines for a 'front end' to a tool

2008-09-17 Thread Kent Johnson
On Wed, Sep 17, 2008 at 5:02 PM, James <[EMAIL PROTECTED]> wrote: > Kent / Alan, > > Thanks for the responses. I'm not completely certain that urwid is > appropriate for the program I'm writing, as it seems to be more of a > framework for developing a text GUI application. (similar to curses?) It

[Tutor] How to parse InputFile to generate OutputFile?

2008-09-17 Thread Kamisetty, Rajendra
Hi, I am new to Python and need your help to generate an output file as explained below. I need to generate an output text file based on the input text file data . Input.txt contents: ('844 - Open File Message', '011 - System Trace Audit Number: 823301', '012 - Local Time: 033543', '013 - Loc

Re: [Tutor] clearing lines for a 'front end' to a tool

2008-09-17 Thread James
Kent / Alan, Thanks for the responses. I'm not completely certain that urwid is appropriate for the program I'm writing, as it seems to be more of a framework for developing a text GUI application. (similar to curses?) The behavior of the program I'm writing is actually identical to that of an op

Re: [Tutor] Sort Output

2008-09-17 Thread Shantanoo Mahajan
Solution 1: >>> a=[2,3,1,4] >>> b=a[:] >>> a [2, 3, 1, 4] >>> b [2, 3, 1, 4] >>> a.sort() >>> a [1, 2, 3, 4] >>> b [2, 3, 1, 4] >>> Solution 2: >>> from copy import deepcopy >>> a=[2,1,3,4] >>> b=deepcopy(a) >>> a [2, 1, 3, 4] >>> b [2, 1, 3, 4] >>> a.sort() >>> a [1, 2, 3, 4] >>> b [2, 1, 3, 4]

Re: [Tutor] Sort Output

2008-09-17 Thread greg whittier
On Wed, Sep 17, 2008 at 3:30 PM, Wayne Watson <[EMAIL PROTECTED]>wrote: > I'm using Python 2.4 in Win XP. I was surprised to find the result below. > > >>> a =[4,2,5,8] > >>> b = a > >>> a.sort() > >>> a > [2, 4, 5, 8] > >>> b > [2, 4, 5, 8] > > b no longer has the same value as it began. Apparen

Re: [Tutor] Sort Output

2008-09-17 Thread Jerry Hill
On Wed, Sep 17, 2008 at 3:30 PM, Wayne Watson <[EMAIL PROTECTED]> wrote: > I'm using Python 2.4 in Win XP. I was surprised to find the result below. > a =[4,2,5,8] b = a This binds the name "b" to the same object that "a" is bound to. a.sort() a > [2, 4, 5, 8] b > [2, 4,

Re: [Tutor] Sort Output

2008-09-17 Thread Kent Johnson
On Wed, Sep 17, 2008 at 3:30 PM, Wayne Watson <[EMAIL PROTECTED]> wrote: > I'm using Python 2.4 in Win XP. I was surprised to find the result below. > a =[4,2,5,8] b = a a.sort() a > [2, 4, 5, 8] b > [2, 4, 5, 8] > > b no longer has the same value as it began. Apparently to

Re: [Tutor] Sort Output

2008-09-17 Thread Shulin Zhuang
If you use sort(a), it will be ok. >>>a =[4,2,5,8] >>>b=a >>> sort(a) : array([2, 4, 5, 8]) >>> b [4, 2, 5, 8] >>> a [4, 2, 5, 8] On Wed, Sep 17, 2008 at 12:30 PM, Wayne Watson <[EMAIL PROTECTED] > wrote: > I'm using Python 2.4 in Win XP. I was surprised to find the result below. > > >>> a

[Tutor] Sort Output

2008-09-17 Thread Wayne Watson
Title: Signature.html I'm using Python 2.4 in Win XP. I was surprised to find the result below. >>> a =[4,2,5,8] >>> b = a >>> a.sort() >>> a [2, 4, 5, 8] >>> b [2, 4, 5, 8] b no longer has the same value as it began. Apparently to prevent sort from making it the same I have to resort to copy

Re: [Tutor] Shell scripting

2008-09-17 Thread Chris Fuller
Here's a trivial example using backquotes. The tricky part is getting bash to use them in conditionals, variable assignments, and such. 0 % cat > /tmp/fie.py print "Fie!" [ctrl-d] 0 % cat > /tmp/echo.sh echo `python /tmp/fie.py` [ctrl-d] 0 % sh /tmp/echo.sh Fie! 0 % Cheers On Wednesday 17 Sep

Re: [Tutor] Shell scripting

2008-09-17 Thread Chris Fuller
If you want the return code, there are at least two ways to do it. My zsh shell is configured to print the last return code in the prompt: 0 % python Python 2.4.4 (#2, Apr 15 2008, 23:43:20) [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2 Type "help", "copyright", "credits" or "lice

Re: [Tutor] Shell scripting

2008-09-17 Thread Alan Gauld
"Patrick" <[EMAIL PROTECTED]> wrote I was just wondering if there was a way to return the results of a python script to the bash shell? Here is a silly pseudo code example: bash command | some-python-script.py | some.other-script.sh That's called pipelining and uses standard input/outpu

Re: [Tutor] WMI

2008-09-17 Thread Steve Willoughby
On Wed, Sep 17, 2008 at 11:37:39AM -0600, Spencer Parker wrote: > Yes...you do have it all correct. Luckily this is all behind a private > network that is firewalled. There is no way to get to this network unless > you are physically on site. Since there isn't even VPN access to this > network c

Re: [Tutor] WMI

2008-09-17 Thread Spencer Parker
Yes...you do have it all correct. Luckily this is all behind a private network that is firewalled. There is no way to get to this network unless you are physically on site. Since there isn't even VPN access to this network currently. This was done for the security problems associated with rando

Re: [Tutor] WMI

2008-09-17 Thread Steve Willoughby
On Wed, Sep 17, 2008 at 10:52:33AM -0600, Spencer Parker wrote: > We have a web interface where people can provision virtual machines. > Currently we do this with Linux machines and it sets a unique IP, username, > startup services, and a password. This is all triggered at startup of the > linux m

Re: [Tutor] WMI

2008-09-17 Thread Spencer Parker
What I am doing is this: We have a web interface where people can provision virtual machines. Currently we do this with Linux machines and it sets a unique IP, username, startup services, and a password. This is all triggered at startup of the linux machines with perl and an xml file. We are try

Re: [Tutor] WMI

2008-09-17 Thread Steve Willoughby
On Wed, Sep 17, 2008 at 10:31:50AM -0600, Spencer Parker wrote: > Is there a way to remotely trigger an event from Linus to a windows machine? > I have basically a virtual machine that this script would run from. I need > to find a way to trigger this event from a linux machine that handles all of

Re: [Tutor] Shell scripting

2008-09-17 Thread Steve Willoughby
On Wed, Sep 17, 2008 at 12:30:58PM -0400, Patrick wrote: > I was just wondering if there was a way to return the results of a > python script to the bash shell? I was thinking about using the output > as an argumen for another shell command. I know that we can use the > shell from within Python via

Re: [Tutor] WMI

2008-09-17 Thread Spencer Parker
I meant to hit reply to all...stupid Gmail(not really...all on me...LOL) Is there a way to remotely trigger an event from Linus to a windows machine? I have basically a virtual machine that this script would run from. I need to find a way to trigger this event from a linux machine that handles al

[Tutor] Shell scripting

2008-09-17 Thread Patrick
I was just wondering if there was a way to return the results of a python script to the bash shell? I was thinking about using the output as an argumen for another shell command. I know that we can use the shell from within Python via the OS module but I believe this is usually used to feed input i

Re: [Tutor] WMI

2008-09-17 Thread Tim Golden
Spencer Parker wrote: I just need to create a local user. [copying back to the list in case it helps others] See if this sets you on the way: http://timgolden.me.uk/python/win32_how_do_i/create-a-local-group-with-a-new-user.html TJG ___ Tutor maill

Re: [Tutor] WMI

2008-09-17 Thread Tim Golden
Spencer Parker wrote: Is there a way to create new users in WMI? I was trying to research this on MSDN, but couldn't find it anywhere... Not possible as far as I know. Do you need a domain user or a local user? TJG ___ Tutor maillist - Tutor@pyth

Re: [Tutor] WMI

2008-09-17 Thread Spencer Parker
Is there a way to create new users in WMI? I was trying to research this on MSDN, but couldn't find it anywhere... On Tue, Sep 16, 2008 at 2:10 PM, Tim Golden <[EMAIL PROTECTED]> wrote: > Spencer Parker wrote: > >> It does of course help to spell IPAddress correctly to get this to work in >> the

[Tutor] How to parse InputFile to generate OutputFile?

2008-09-17 Thread Kamisetty, Rajendra
Hi, I am new to Python and need your help to generate an output file as explained below. I need to generate an output text file based on the input text file data which has fixed length format of 142 bytes each line. Input.txt contents: ('844 - Open File Message', '011 - System Trace Audit Number: