Pexpect and telnet not communicating properly

2009-01-27 Thread David Anderson
I am trying to automate the following session - to talk to my router:

===
telnet speedtouch
Trying 192.168.1.254...
Connected to speedtouch.
Escape character is '^]'.
Username : Administrator
Password :


 __  SpeedTouch 780
 ___/_/\
/ /\  6.1.7.2
  _/__   /  \
_/   /\_/___ \  Copyright (c) 1999-2006, THOMSON
   //   /  \   /\ \
   ___//___/\ / _\/__
  /  / \   \// //\
   __/  /   \   \  // // _\__
  / /  / \___\// // /   /\
 /_/__/___/ // /___/  \
 \ \  \___\ \\ \   \  /
  \_\  \  /  /\\ \\ \___\/
 \  \/  /  \\ \\  /
  \_/  /\\ \\/
   /__/  \\  /
   \   _  \  /_\/
\ //\  \/___\/
 //  \  \  /
 \\  /___\/
  \\/


_{Administrator}=>?
Following commands are available :

help : Displays this help information
menu : Displays menu
?: Displays this help information
exit : Exits this shell.
..   : Exits group selection.
saveall  : Saves current configuration.
ping : Send ICMP ECHO_REQUEST packets.
traceroute   : Send ICMP/UDP packets to trace the ip path.

Following command groups are available :

firewallservice autopvc connection  cwmp
dhcpdns dsd dyndns  eth
adslatm config  debug   env
exprgrp hostmgr ids igmp
interface   ip  ipqos   label   language
mbusmemmmlp nat ppp
pptpscript  snmpsntpsoftware
system  systemlog   upgrade upnpuser
voice   wireless

{Administrator}=>exit



I am using the following code:

#!/usr/bin/env python

import pexpect
import sys

child = pexpect.spawn('telnet 192.168.1.254')
fout = file('mylog.txt','w')
child.logfile = fout

child.expect('sername : ')
child.sendline('Administrator')
child.expect('assword : ')
child.sendline('')


child.expect('_{Administrator}=>')
child.sendline('?')
child.expect('_{Administrator}=>')
child.expect('exit')



This times out after child.sendline('Administrator')

mylog.txt contains:
Trying 192.168.1.254...

Connected to 192.168.1.254.

Escape character is '^]'.

Username : Administrator
Administrator


Can anyone help me in finding out what I am doing wrong?

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


What's the api tat I should use to connect python to a MS Access Db?

2008-05-18 Thread David Anderson
Please answer me the question of the subject =)
--
http://mail.python.org/mailman/listinfo/python-list

How to make an Activation Issue?

2008-05-15 Thread David Anderson
Hi, How can I make something like this...
The final user installs the app
The app Runs and the User has to authenticate the app, which will be by
acessing a remote file on a Server, If he user dont authenticate the program
will run only for 3 days, after that it will be blocked until the user
authenticates it...
How can I do this?
Cya =)
--
http://mail.python.org/mailman/listinfo/python-list

how to separate words from a string?

2008-05-11 Thread David Anderson
Hi, how can I separate words from a sentence in a string? Like the
java.String.split method
I need something that gets an string "This is a sentence", and return to em
a list["This","is","a","sentence"]
Can anyone help?
Thx
--
http://mail.python.org/mailman/listinfo/python-list

Re: Weird bug with an integer

2008-05-08 Thread David Anderson
Ps:
When I go to shell and type:rowN = int(0)

rows = [["1223", "11/23/08", "Purchase", "To be shipped", "Gallery Name",
"Art Title[22 of 300]", "$10,000"],#1st row
["1223", "11/23/08", "Purchase", "To be shipped", "Gallery
Name", "Art Title[22 of 300]", "$10,000"],#2nd row
["1223", "11/23/08", "Purchase", "To be shipped", "Gallery
Name", "Art Title[22 of 300]", "$10,000"],#etc, obviouslly these info will
be fetched from the db
["1223", "11/23/08", "Purchase", "To be shipped", "Gallery
Name", "Art Title[22 of 300]", "$10,000"]
]
for row in rows:

colN = int(0)
for col in row:
print str(colN) + "," + str(rowN) + " - " + col


It works and print everything correctly Oo
On Thu, May 8, 2008 at 10:44 PM, David Anderson <[EMAIL PROTECTED]>
wrote:

> Look this slice of code:
>
> rowN = int(0)
> for row in rows:
> success = self.resultGrid.AppendRows();
> colN = int(0)
> for col in row:
> self.resultGrid.SetReadOnly(self.resultGrid.GetNumberRows()
> - 1,colN,isReadOnly = True)
> print rowN
> self.resultGrid.SetCellValue(int(rowN),int(colN),col)
>
> I am getting this output:
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> (1,)
> Traceback (most recent call last):
>  in populateGrid
> self.resultGrid.SetCellValue(int(rowN),int(colN),col)
> TypeError: int() argument must be a string or a number, not 'tuple'
>
>
> Why is this happening?
>
--
http://mail.python.org/mailman/listinfo/python-list

Weird bug with an integer

2008-05-08 Thread David Anderson
Look this slice of code:

rowN = int(0)
for row in rows:
success = self.resultGrid.AppendRows();
colN = int(0)
for col in row:
self.resultGrid.SetReadOnly(self.resultGrid.GetNumberRows()
- 1,colN,isReadOnly = True)
print rowN
self.resultGrid.SetCellValue(int(rowN),int(colN),col)

I am getting this output:
0
0
0
0
0
0
0
(1,)
Traceback (most recent call last):
 in populateGrid
self.resultGrid.SetCellValue(int(rowN),int(colN),col)
TypeError: int() argument must be a string or a number, not 'tuple'


Why is this happening?
--
http://mail.python.org/mailman/listinfo/python-list

Cannot import opj

2008-05-08 Thread David Anderson
I'm trying to import the opj module
Trying like this:
from Main import opj
It says it doesn't exists
And like this:
import os.path.join as opj

Raises error.
What should I do?
--
http://mail.python.org/mailman/listinfo/python-list

How to generate binary python?

2008-05-05 Thread David Anderson
Hi, i'm comingo from Java and I'm wanting to know what in Python is the
equivalent to the file.class in java, I am producing some apps that ar not
open source, so I would like to share only the binaries, Both for Windows
and for Linux, Can you suggest me anything?
Bye
--
http://mail.python.org/mailman/listinfo/python-list

psycopg2 ReferenceManual

2008-05-05 Thread David Anderson
Hi all, where can I find the reference manual from the psycopg2 or the
dbapi2.0 because in their official pages I could'nt find
thx
--
http://mail.python.org/mailman/listinfo/python-list

Re: Problems with psycopg2

2008-05-03 Thread David Anderson
The thing is this query works fine on the console through psql, but not in
my code? can anyone explain me why?

On Thu, May 1, 2008 at 9:31 PM, David Anderson <[EMAIL PROTECTED]>
wrote:

> Hi all
> I have this function:
> def checkName(self, name):
> cur = self.conn.cursor()
>
> sql = "SELECT * from patient WHERE fn_pat = '" + name + "'"
> cur.execute(sql)
> rows = cur.fetchall()
>
> if rows == "[]":
> self.insert()
>
> It seems to work fine, But I'm getting this exception:
> psycopg2.ProgrammingError: current transaction is aborted, commands
> ignored until end of transaction block
> at: cur.execute(sql)
>
> What's the problem?
> thx
>
> ps: fn_pat is the column of the db, name is the string passed in the
> function parameter
>
--
http://mail.python.org/mailman/listinfo/python-list

Problems with psycopg2

2008-05-01 Thread David Anderson
Hi all
I have this function:
def checkName(self, name):
cur = self.conn.cursor()

sql = "SELECT * from patient WHERE fn_pat = '" + name + "'"
cur.execute(sql)
rows = cur.fetchall()

if rows == "[]":
self.insert()

It seems to work fine, But I'm getting this exception:
psycopg2.ProgrammingError: current transaction is aborted, commands ignored
until end of transaction block
at: cur.execute(sql)

What's the problem?
thx

ps: fn_pat is the column of the db, name is the string passed in the
function parameter
--
http://mail.python.org/mailman/listinfo/python-list

Re: Python and Db

2008-03-31 Thread David Anderson
It's DB = DataBase, I typed wrong on the text, but right at the subject =)

On Mon, Mar 31, 2008 at 5:50 PM, David Anderson <[EMAIL PROTECTED]>
wrote:

> I would like to use sqlite, But I also wanted a tutorial with the basis of
> the sql and etc, I never dealed with dbs before
>
>
> On Mon, Mar 31, 2008 at 3:42 PM, Gabriel Genellina <[EMAIL PROTECTED]>
> wrote:
>
> > En Mon, 31 Mar 2008 14:50:27 -0300, David Anderson <
> > [EMAIL PROTECTED]>
> > escribió:
> >
> > > Hi! I'm don't know almost nothing about bds, Can You suggest me an
> > Simple
> > > but efficient Bd to work with python apps? Can You suggest me any
> > > tutorials?
> >
> > See the Python wiki at: http://wiki.python.org/moin/DatabaseProgramming
> > If you stick with DBAPI 2.0 you won't have much trouble writing for one
> > database or another. sqlite is a good start and is included with Python
> > 2.5
> >
> > --
> > Gabriel Genellina
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python and Db

2008-03-31 Thread David Anderson
I would like to use sqlite, But I also wanted a tutorial with the basis of
the sql and etc, I never dealed with dbs before

On Mon, Mar 31, 2008 at 3:42 PM, Gabriel Genellina <[EMAIL PROTECTED]>
wrote:

> En Mon, 31 Mar 2008 14:50:27 -0300, David Anderson <[EMAIL PROTECTED]>
> escribió:
>
> > Hi! I'm don't know almost nothing about bds, Can You suggest me an
> Simple
> > but efficient Bd to work with python apps? Can You suggest me any
> > tutorials?
>
> See the Python wiki at: http://wiki.python.org/moin/DatabaseProgramming
> If you stick with DBAPI 2.0 you won't have much trouble writing for one
> database or another. sqlite is a good start and is included with Python
> 2.5
>
> --
> Gabriel Genellina
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Python and Db

2008-03-31 Thread David Anderson
Hi! I'm don't know almost nothing about bds, Can You suggest me an Simple
but efficient Bd to work with python apps? Can You suggest me any tutorials?
Thanx
-- 
http://mail.python.org/mailman/listinfo/python-list

Newbie Question.. How to add python to system path in windows?

2008-03-30 Thread David Anderson
hi All, I have my Phitno 25 installed on the default directory, but How can
I dd to the ubild path?
Thx
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Error Raised But dont know what it means

2008-03-30 Thread David Anderson
I found the problem

Topic closed

On Sun, Mar 30, 2008 at 5:07 PM, David Anderson <[EMAIL PROTECTED]>
wrote:

> Here is the code:
> This one raises the error:
> def criaLista(self):
> self.listbox.Clear()
> for dupla in self.duplas:
> self.listbox.Append(dupla.__str__())
>
> This one works well but doesn't raises error
>
> dupla1 = Duplas("2422", "2455")
> dupla2 = Duplas("454", "15")
> list = []
> list.append(dupla1)
> list.append(dupla2)
> erros = ErrorMgr()
> erros.geraErro("1", "erro idiota", 2.2)
> dic = {1:dupla1, 2:dupla2}
> a = Arquivos("batata.txt")
> a.saveFile(list, erros, dic)
> a.openFile()
> lista = a.getListaDuplas()
> e = a.getErrorsManager()
> d = a.getDicDuplas()
>
> for i in lista:
> print i
>
> print d[1]
>
>
> On Sun, Mar 30, 2008 at 5:03 PM, David Anderson <[EMAIL PROTECTED]>
> wrote:
>
> > Well, I'm dealing with files in Pickle, I'm saving at the file a List of
> > Objects from the same Class, When I try to retrive this information and try
> > to iterate over them this error is raised:
> > TypeError: 'instancemethod' object is not iterable
> >
> > But if I just print the method I get the 'real thing' what's the
> > problem?
> >
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Error Raised But dont know what it means

2008-03-30 Thread David Anderson
Here is the code:
This one raises the error:
def criaLista(self):
self.listbox.Clear()
for dupla in self.duplas:
self.listbox.Append(dupla.__str__())

This one works well but doesn't raises error

dupla1 = Duplas("2422", "2455")
dupla2 = Duplas("454", "15")
list = []
list.append(dupla1)
list.append(dupla2)
erros = ErrorMgr()
erros.geraErro("1", "erro idiota", 2.2)
dic = {1:dupla1, 2:dupla2}
a = Arquivos("batata.txt")
a.saveFile(list, erros, dic)
a.openFile()
lista = a.getListaDuplas()
e = a.getErrorsManager()
d = a.getDicDuplas()

for i in lista:
print i

print d[1]

On Sun, Mar 30, 2008 at 5:03 PM, David Anderson <[EMAIL PROTECTED]>
wrote:

> Well, I'm dealing with files in Pickle, I'm saving at the file a List of
> Objects from the same Class, When I try to retrive this information and try
> to iterate over them this error is raised:
> TypeError: 'instancemethod' object is not iterable
>
> But if I just print the method I get the 'real thing' what's the problem?
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Error Raised But dont know what it means

2008-03-30 Thread David Anderson
Well, I'm dealing with files in Pickle, I'm saving at the file a List of
Objects from the same Class, When I try to retrive this information and try
to iterate over them this error is raised:
TypeError: 'instancemethod' object is not iterable

But if I just print the method I get the 'real thing' what's the problem?
-- 
http://mail.python.org/mailman/listinfo/python-list

Getting back an Object

2008-03-27 Thread David Anderson
Well, I've got a little problem, I have a list that contains objects from
the class C, then I use those objects.__str__ to generate a ListCtrl, A
wxPython widget that makes a list of strings and then you can handle events
when selected, and returns the string selcted, how can I access the "parent"
of that string?
I tried to search on the array like this:
def search(self, string):
  for obj in self.list:
   if string == obj.__str__:
 return obj
   return None

But I always get None... What am I doing wrong?
-- 
http://mail.python.org/mailman/listinfo/python-list

Problems wit List Object

2008-03-27 Thread David Anderson
Hello all, I have a Class1 that there has a list, and a function that
returns this list, In another class I got an instance of this first class,
and when I make:

obj1 = Class1()
list = obj1.getList()

I got this exception:

traceback (most recent call last):
  File "xxx", line 184, in onAddErro
list = self.errorMgr.getList()
TypeError: 'list' object is not callable

How can I solve it?
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: what does ^ do in python

2008-03-26 Thread David Anderson
ANd...  By express I mean... Dereferencing... Habits from my native language
where the verb express also means this

On Wed, Mar 26, 2008 at 4:14 PM, David Anderson <[EMAIL PROTECTED]>
wrote:

> Err even I cant understand what I wrote...
> The right question was:HOw can we use/express pointers python as in C or
> Pascal?
> But thx to Heiko, He got what I mean =)
>
>
> On Wed, Mar 26, 2008 at 3:46 PM, Tim Chase <[EMAIL PROTECTED]>
> wrote:
>
> > >> HOw can we use express pointers as in C or python?
> > >
> > > Traceback (most recent call last):
> > >File "", line 1, in 
> > >File "parser.py", line 123, in parse_text
> > >  tree = language.parse_text(text)
> > >File "english.py", line 456, in parse_text
> > >  tree = self.parse_sentence(sentence)
> > >File "english.py", line 345, in parse_sentence
> > >  raise ParserError, "can't parse %r" % sentence
> > > ParserError: can't parse 'HOw can we use express pointers as in C or
> > > python?'
> >
> > Possible "express pointers":
> >
> > http://www.geocities.com/derwin_b/sr91sign.jpg
> >
> > http://www.gribblenation.net/njpics/drive/78/exp78on78w.jpg
> >
> >
> > http://adcentered.typepad.com/photos/uncategorized/2007/03/31/subway2.jpg
> >
> > If those meet the OP's need, I recommend urllib2 and PIL.
> >
> > -tkc
> >
> >
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: what does ^ do in python

2008-03-26 Thread David Anderson
Err even I cant understand what I wrote...
The right question was:HOw can we use/express pointers python as in C or
Pascal?
But thx to Heiko, He got what I mean =)

On Wed, Mar 26, 2008 at 3:46 PM, Tim Chase <[EMAIL PROTECTED]>
wrote:

> >> HOw can we use express pointers as in C or python?
> >
> > Traceback (most recent call last):
> >File "", line 1, in 
> >File "parser.py", line 123, in parse_text
> >  tree = language.parse_text(text)
> >File "english.py", line 456, in parse_text
> >  tree = self.parse_sentence(sentence)
> >File "english.py", line 345, in parse_sentence
> >  raise ParserError, "can't parse %r" % sentence
> > ParserError: can't parse 'HOw can we use express pointers as in C or
> > python?'
>
> Possible "express pointers":
>
> http://www.geocities.com/derwin_b/sr91sign.jpg
>
> http://www.gribblenation.net/njpics/drive/78/exp78on78w.jpg
>
> http://adcentered.typepad.com/photos/uncategorized/2007/03/31/subway2.jpg
>
> If those meet the OP's need, I recommend urllib2 and PIL.
>
> -tkc
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: what does ^ do in python

2008-03-26 Thread David Anderson
HOw can we use express pointers as in C or python?

On Tue, Mar 25, 2008 at 7:36 PM, Tim Chase <[EMAIL PROTECTED]>
wrote:

> > In most of the languages ^ is used for 'to the power of'.
> >
> > No, not in most languages. In most languages (C, C++, Java, C#, Python,
> > Fortran, ...), ^ is the xor operator ;)
>
> ...and in Pascal it's the pointer-dereferencing operator...
>
> -tkc
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Problems with wxPython

2008-03-24 Thread David Anderson
Thanx

On Mon, Mar 24, 2008 at 2:00 PM, Frank Niessink <[EMAIL PROTECTED]> wrote:

> Hi David,
>
> 2008/3/24, David Anderson <[EMAIL PROTECTED]>:
> > Hi, If ther's anyone who knows pretty much about wxPython can e-mail me?
> I'm
> > having some trouble in dealing with some guis here, I would thank u very
> > much if you could help me
>
> You should subscribe to the wxPython users mailinglist and ask there.
> It's a very helpful mailinglist. Robin Dunn (wxPython author) is very
> active in answering questions from wxPython users.
>
> See http://www.wxpython.org/maillist.php
>
> Cheers, Frank
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Problems with wxPython

2008-03-24 Thread David Anderson
Hi, If ther's anyone who knows pretty much about wxPython can e-mail me? I'm
having some trouble in dealing with some guis here, I would thank u very
much if you could help me
bye
[]'s
-- 
http://mail.python.org/mailman/listinfo/python-list