Help please using telnetlib module

2006-12-23 Thread dudds
Hi Guys,

I just started learning Python a couple of days ago and to put some of
what I learnt into practice. As such I thought I might try and write a
simple program (based on examples I had seen) that would allow me to
log into a Cisco router, enter configuration mode, change an interface
description and also grab a snapshot of the running configuration.

So far I've managed to be able to log in and change the interface
configuration. The tn.read_until() function seems to work pretty much
as I expected however for the life of me I cannot get the running
configuration to display with any of the read functions.

Suggestion pleasemy code thus far follows:
import getpass
import sys
import telnetlib

#This can actually log in and change an interface description on a
router


HOST = "xxx.xxx.xxx.xxx"
#user = raw_input("Enter your remote account: ")
#password = getpass.getpass()
password = "tacis345int"

tn = telnetlib.Telnet(HOST)
#tn.interact()
tn.read_until("Password:")
tn.write(password + "\n")
#if password:
#tn.read_until("Password: ")
#tn.write(password + "\n")
tn.read_until("port>")
#tn.write("show version\n")
#tn.write("\n\n")
#tn.read_until("port>")
tn.write("enable\n")
tn.read_until("assword: ")
tn.write("tacis345int\n")
tn.read_until("port#")
tn.write("conf t\n")
tn.read_until("config)#")
tn.write("int ethernet0\n")
tn.read_until("config")
tn.write("desc This was written by my script\n")
tn.write("show run\n")
print tn.read_very_lazy()
tn.write("exit\n")
tn.read_until("#")
tn.write("quit\n")
tn.close()
print tn.read_all()


The only output I get from this is:
-if)#
show

I have tried the other read options but nothing seems to work for me.
I'm obviously missing something, so if anyone could shed some light
that would be great.

-- 
http://mail.python.org/mailman/listinfo/python-list


PythonCard installation

2007-01-23 Thread dudds
Anyone had any joy with this using FC6?? When I try to run code editor
I get the error "Traceback (most recent call last):
  File
"/usr/lib/python2.4/PythonCard-0.8.2/tools/codeEditor/codeEditor.py",
line 13, in ?
from PythonCard import about, configuration, dialog, log, menu,
model, resource, util
ImportError: No module named PythonCard"

-- 
http://mail.python.org/mailman/listinfo/python-list


wx Python event question

2007-01-26 Thread dudds
Hi I really haven't used wxPython before and I was just wondering if
there was some sort of timer event that can be used. For example if I
have a database that I want to query at regular intervals and display
the results in a window is that possibly to do under a wx Python
program?

So far I have come across certain event handlers, but they all seem to
wait for something to happen, like moving the mouse, clicking on a
button etc. I just want to display the results of a query every so
often automatically without having to press a button to do so.

I'm not looking for a complete solution as I'm doing this so I can
teach myself Python, but a bit of a hint or a nudge in the right
direction would be great.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wx Python event question

2007-01-27 Thread dudds
Thanks Steve.

On Jan 27, 8:01 pm, "Steve" <[EMAIL PROTECTED]> wrote:
> use wx.Timer - you bind a method to a timer event and define the
> timer's interval when you start it
>
> timer = wx.Timer(self, -1)
> self.Bind(wx.EVT_TIMER, self.timerMethod, timer)
> timer.Start(500)
>
> On Jan 27, 5:56 pm, "dudds" <[EMAIL PROTECTED]> wrote:
>
> > Hi I really haven't used wxPython before and I was just wondering if
> > there was some sort of timer event that can be used. For example if I
> > have a database that I want to query at regular intervals and display
> > the results in a window is that possibly to do under a wx Python
> > program?
>
> > So far I have come across certain event handlers, but they all seem to
> > wait for something to happen, like moving the mouse, clicking on a
> > button etc. I just want to display the results of a query every so
> > often automatically without having to press a button to do so.
>
> > I'm not looking for a complete solution as I'm doing this so I can
> > teach myself Python, but a bit of a hint or a nudge in the right
> > direction would be great.

-- 
http://mail.python.org/mailman/listinfo/python-list