where to get modules for python

2005-10-11 Thread eight02645999
hi
i am new to python and was wondering where can i find modules for
python?
Something very much like what CPAN has for Perl.
I am searching for SSL/SSH modules for use in Python. 
thanks

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


odbc errors

2005-10-16 Thread eight02645999
hi

i have a piece of code:
...

def connectdb(sql):
import dbi
import odbc
import sys
try:
s = odbc.odbc('DSN=CONN;UID=user;PWD=pass')
cur = s.cursor()
   # cur.execute("set nocount on")
cur.execute(sql)
while 1:
rec = cur.fetchone()
if not rec: break
return rec
except:
print 'error while processing ', sys.exc_type,sys.exc_value
s.close()
cur.close()
s = None
cur = None

...
sql = r'update table set col = 'A' where user = "user1"'
connectdb(sql)


when i execute it from CGI, i encounter the following :
error while processing dbi.internal-error [MERANT][ODBC Sybase ASE
driver]Invalid cursor state. in FETCH None

but when i did check the table, the value of col is updated to 'A',
how can i suppress the above error message? or is there some other
things
that are wrong with the code.
thanks

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


how to return correct value of update stmt

2005-10-18 Thread eight02645999
hi
i use odbc to update a table in a database but i always get return
value of -1
even though i tried to return an integer. the table is updated though
...
sql = """
   update table
   set column = 0
   where col = "%s"
   select @@rowcount

"""  % (var1)

try:
s = odbc.odbc(connectstring)
cur = s.cursor()
res = cur.execute(sql)
s.commit()
s.close()
cur.close()
s = None
cur = None
print res
return res
except:
print 'error while processing ', sys.exc_type,sys.exc_value


how to properly get a positive return ?
thanks

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


Re: how to return correct value of update stmt

2005-10-19 Thread eight02645999
hi
yes , the table is updated. Just feels "uncomfortable" with the return
of -1.
was also concerned that what if the actual table doesn't exist, will it
return -1? 
anyway, i will go check it out ..
thanks

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


do cc list from smtplib

2005-10-21 Thread eight02645999
hi
i have email code:

def email(HOST,FROM,TO,SUBJECT,BODY):
import smtplib
import string, sys


body = string.join((
"From: %s" % FROM,
"To: %s" % TO,
"Subject: %s" % SUBJECT,
"",
BODY), "\r\n")

print body

server = smtplib.SMTP(HOST)
server.sendmail(FROM, [TO],body)
server.quit()


is there a way to include CC list for the smtplib module?
thanks

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


query a port

2005-10-29 Thread eight02645999
hi
in python, how do one query a port to see whether it's up or not?
thanks

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


Re: query a port

2005-10-29 Thread eight02645999
thanks alot!
that's all there is to it..so it's just a simple connect.

Dan M wrote:
> On Sat, 29 Oct 2005 20:21:20 -0700, eight02645999 wrote:
>
> > hi
> > in python, how do one query a port to see whether it's up or not?
> > thanks
>
> I'm an absolute beginner, but let's see if I can help. Assuming you want
> to check a port on another machine,
>
> import socket
> port=25   # Port we want to test
> host=machine.to.test  # Either IP address or FQDN
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> try:
>   s.connect((host, port))
>   print "We made the connection"
> except socket.error:
>   print "Sorry, that port is not open"
> s.close
> 
> Does that help?
> 
> Dan

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


python CGI,sybase and environ variables

2005-11-02 Thread eight02645999
hi
i am writing a CGI to process some database transactions using the
Sybase module.
so in my CGI script, i have:

...
import Sybase
import cgitb; cgitb.enable(display=1 , logdir="/tmp/weblog.txt")
...
...

the problem is , everytime i have ImportError: No module named Sybase
flagged out.

at first i think it's library path misconfiguration, so i put
os.environ["SYBASE"] = '/path/to/sybase'
os.environ["LD_LIBRARY_PATH"] =  '/path/to/sybase/lib'

before i import Sybase. but its still the same error

Ok.so now, is it necesary to configure the web server's "nobody" user's
profile to point to the Sybase libraries? or worse, configure root's
profile to point to Sybase libraries? what's could be wrong?
thanks for any help rendered.

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


Re: python CGI,sybase and environ variables

2005-11-02 Thread eight02645999
i have solved the problem.
thanks.

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


how to check for unix password

2005-11-02 Thread eight02645999
hi
i created a login page that authenticate the user and his/her password
to the unix ssystem. what modules can i used to compare the unix
password with what the user typed in the cgi form? the password is
encrypted (shadowed) so i need to
decrypt it first before comparing to what the user typed. or this
cannot be done at all?
thanks

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


help converting some perl code to python

2005-11-04 Thread eight02645999
hi
i need help with converting a piece of perl code to python
.
my $start = '\[start\]';
my $file = '\[files\]';
my $end = '\[end\]';


while() #open a file
{
if ( /$start/ .. /$file/ ) { # if line match [start] till
[files]
do something with $_
}
if (/$file/ .. /$end/  )
{
   do something with $_
}
}

The file looks something like:

[start]
...
[files]
...
[end]

the problem is the '..' operator in perl. Is there any equivalent in
python?
any suggestions ?
thanks

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


pls help me with strange result

2005-11-07 Thread eight02645999
hi
i defined a func

db  = Sybase.connect(DSN) 
...
def x_dml(SQL,conn):
''' Connects to database specified, exec the SQL and returns
value'''
try:
c = conn.cursor()
try:
c.execute(SQL)
res = c.rowcount
conn.commit()
return res
except :
return -1
except:
return -2
stmt = """
update table1 set col = '%s' where col = '%s'
update table2 set col = '%s' where col = '%s'
 """ % ( blah, blah ,blah,blah)

try:
r = x_dml(stmt,db)
if r > 0:
   print r
except:
print "some error"


Whenever i execute x_dml , it raise the exeception, even though my r is
value of 1 and i checked the database tables, they are updated with
what i want.
somehow the condition r>0 did not work..any advice ?
thanks

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


Re: pls help me with strange result

2005-11-07 Thread eight02645999
hi
thanks!
i used your method to rearrange the  try,except clauses, and the
problem is solved.
I also redefined my funcs to get rid of the try/except clauses and
leave it to the caller to 
do the job of try/except.

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


Re: pls help me with strange result

2005-11-07 Thread eight02645999
hi
thanks for your advice. yes,the args parameter can be included.
Yes , the syntax is valid. I tried and it works for the 2 tables. looks
like sybase knows
how to distinguish that 2 update statements..as separate ones.
cheers

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


passing values from one form to another

2005-11-12 Thread eight02645999
hi

i have 3 python cgi scripts created, one is a login page(login.py),
another is the main page(main.py) with a lot of user inputs and the
last one is a python cgi script results.py to process main.py

In main.py, i am able to check for the value of the user and password
field, eg

if form.has_key("user") and form["button"].value == "Login" and
form.has_key("password"):
  # show all fields

how can i also check for the user field in the results.py script? ie ,
pass the value of the "user" to the python script..so that user must
always login to get to results.py

thanks..

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


how to catch error with system()

2005-12-12 Thread eight02645999
hi

i have a piece of python code extract that calls an external java
program
cmd = """java someclass someargs"""
try:
   ret = os.WEXITSTATUS(os.system(cmd))
except:
   print blah
else:
   dosomething(ret)

the thing is, the java class "someclass" produces it's own errors when
something goes wrong.
something like
java.io.FileNotFoundException: somefile (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:106)
at java.io.FileInputStream.(FileInputStream.java:66)
..

how can i supress this error from showing when i execute
./pythonscript.py and at the same time logging it to an errlog file??

thanks

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


gathering some opinions

2006-07-04 Thread eight02645999
hi
i am working on cgi and wish to gather some input on correct/often used
methods of what i am going to do.
I need to let the user choose (in the form of check boxes) whether they
need the data to be emailed to them periodically. So if they click the
check box on "activate", then email system will start.
I was thinking of creating schedular jobs after they click "activate".
In windows, i have read the demos of creating a job in task schedular
using the win32 modules..In unix, i am not sure how yet, but i will do
more research. The main thing is, is this the only way ? Sometimes,
there is not enough privlege to create jobs and things like that...
anyone has done such a setup before?what are other better approach?
thanks for any suggestions and inputs...

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


simulate enumerate in python 2.1

2006-07-10 Thread eight02645999
hi,
i am using python 2.1. Can i use the code below to simulate the
enumerate() function in 2.3? If not, how to simulate in 2.1?
thanks

from __future__ import generators
def enumerate(sequence):
index = 0
for item in sequence:
yield index, item
index += 1

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


changing list items

2006-11-22 Thread eight02645999
hi

say i have a list

alist = ['a','b','c','e','d','f']
I wanted to change the elements , say alist[2:4] .

If i do alist[2:4] = "t" , it gives
['a', 'b', 't', 'd', 'f']  which is not what i want.
I wanted  alist = ['a','b','t','t','d','f']

My list may have more elements, and i may need to replace elements from
different positions,
eg alist[10:15] , alist[30:40] etc..

thanks.

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


paramiko public key

2006-12-11 Thread eight02645999
hi
i downloaded paramiko and was trying to create private/pub key pairs
from the docs, i use this method to create private key

import paramiko
k = paramiko.RSAKey.generate(1024)
k.write_private_key_file("test_priv")

How do i generate the public key for this ?
thanks

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


Re: paramiko public key

2006-12-13 Thread eight02645999

hg wrote:
> [EMAIL PROTECTED] wrote:
>
> > paramiko
> http://www.lag.net/paramiko/docs/
>
> __str__ ?

hi
thanks for the tip
i done up a function to generate priv/pub key pairs like this

def keygen(bits,fil,password=None):
k = paramiko.RSAKey.generate(bits)
k.write_private_key_file(fil, password)
pk = paramiko.RSAKey(filename=fil)
o = open(pubk ,"w").write(pk.__str__())


Is this the correct way to do it ?
thanks

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


skip last line in loops

2006-12-14 Thread eight02645999
hi,
how can i skip printing the last line using loops (for /while)

eg

for line in open("file):
 print line.

I want to skip printing last line of the file.thanks

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


Re: skip last line in loops

2006-12-15 Thread eight02645999

Fredrik Lundh wrote:
> [EMAIL PROTECTED] wrote:
>
> > how can i skip printing the last line using loops (for /while)
> >
> > eg
> >
> > for line in open("file):
> >  print line.
> >
> > I want to skip printing last line of the file.
>
> do it lazily:
>
>  last_line = None
>  for line in open("file):
>  if last_line:
>  print last_line
>  last_line = line
>
> or just gobble up the entire file, and slice off the last item:
>
>  for line in list(open("file"))[:-1]:
>  print line
>
> 

hi
would it be a problem with these methods if the file is like 20Gb in
size...?

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


removing characters before writing to file

2006-02-08 Thread eight02645999
hi
i have some output that returns a lines of tuples eg

('sometext1', 1421248118, 1, 'P ')
('sometext2', 1421248338, 2, 'S ')
and so on


I tried this
re.sub(r" '() ",'',str(output)) but it only get rid of the ' and not
the braces. I need to write the output to a file such that

sometext1, 1421248118, 1, P
sometext2, 1421248338, 2, S

I also tried escaping , re.sub(r" '\(\) ",'',str(output)) but also did
not work
How can i get rid of the braces before writing to file? thanks

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


pymssql and date format

2006-02-16 Thread eight02645999
hi
i am using pymmsql to query a date column in MSSQL database table.
However the result shows for example
(datetime.datetime(2006, 2, 16, 17, 50, 19) which is supposed to be
2006-02-16 17:50:19.000
anyway to correct query a date column using pymssql so that it gives
the correct date format? thanks

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


days since epoch

2006-02-17 Thread eight02645999
hi
how can i get the number of days since epoch using the time module?
or do i have to manually do the arithmetic?
thanks

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


multiple email recipients

2006-02-20 Thread eight02645999
hi
i currently am using this email function that can send single email
address
def email(HOST,FROM,TO,SUBJECT,BODY,CC=None):
import smtplib
import string, sys
body = string.join((
"From: %s" % FROM,
"To: %s" % TO,
"Subject: %s" % SUBJECT,
"CC: %s" % CC,
"",
BODY), "\r\n")

server = smtplib.SMTP(HOST)
server.sendmail(FROM, [TO,CC],body)
server.quit()

was wondering how to modify the code so as i can send to multiple email
recipients using "TO"? thanks.

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


Qns on blank lines

2006-03-02 Thread eight02645999
hi

i have some regular exp code in perl that i want to convert to python.


if $line =~ m#<(tag1)>(.*)#
   {
 $variable = $2;
}

the perl code finds a line that matches something like

"sometext<\tag1>" in the line and then assign $variable the value
of  "sometext"

how can i do an equivalent of that using re module?
thanks

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


help in converting perl re to python re

2006-03-02 Thread eight02645999
hi

i have some regular exp code in perl that i want to convert to python.


if $line =~ m#<(tag1)>(.*)#
   {
 $variable = $2;
}

the perl code finds a line that matches something like

"sometext<\tag1>" in the line and then assign $variable the value
of  "sometext"

how can i do an equivalent of that using re module?
thanks

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


stripping spaces in front of line

2006-03-03 Thread eight02645999
hi
wish to ask a qns on strip
i wish to strip all spaces in front of a line (in text file)

f = open("textfile","rU")
while (1):
line = f.readline().strip()
if line == '':
break
print line
f.close()

in "textfile", i added some spaces in and then ran the code, it prints
out the lines without the spaces in front. I double checked "textfile"
and it does contains some lines with spaces in front.
Is it true that "readline().strip()" perform the removing of spaces in
front of a line as well? Is it documented anywhere?
I am using Windows environment. thanks

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


a good algo to do this

2006-03-06 Thread eight02645999
hi
i need to do something like this
eg given a number (as a string) = "123"
there are a few combination i want to find with this string, ie
"132","321","231","312" and "213". so there are 6 combinations
altogether. i remember there's a formula for this, but forgot. Does
python have any modules/functions to do this?

thanks

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


an enumerate question

2007-03-19 Thread eight02645999
hi
say i want to enumerate lines of a file
eg
for n,l in enumerate(open("file")):
 # print  next line ie

is there a way to print out the next line from current line using the
above?.
Or do i have to do a readlines() first to get it into a list eg
d = open("file").readlines()
for n, l in enumerate(d):
print d[n+1]

thanks

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


Re: an enumerate question

2007-03-19 Thread eight02645999
On Mar 20, 9:48 am, Paul Rubin  wrote:
> [EMAIL PROTECTED] writes:
> > hi
> > say i want to enumerate lines of a file
> > eg
> > for n,l in enumerate(open("file")):
> >  # print  next line ie
>
> > is there a way to print out the next line from current line using the
> > above?.
>
> I don't understand what you're trying to do.  You mean you're
> trying to print all lines except the first one?

thanks for replying. sorry i make clear again.
say
for n,l in enumerate(open("file")):
   print n,l # this prints current line
   print next line in this current iteration of the loop.
hope you can understand now.
thanks.


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


Re: an enumerate question

2007-03-19 Thread eight02645999
On Mar 20, 11:00 am, Steven Bethard <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > for n,l in enumerate(open("file")):
> >print n,l # this prints current line
> >print next line in this current iteration of the loop.
>
> Depends what you want to happen when you request "next".  If you want to
> renumber the lines, you can call .next() on the iterator::
>
>  >>> open('temp.txt', 'w').write('1\n2\n3\n4\n5\n6\n7\n')
>  >>> lines_iter = open('temp.txt')
>  >>> for i, line in enumerate(lines_iter):
>  ... print 'LINE %i, %r %r' % (i, line, lines_iter.next())
>  ...
>  LINE 0, '1\n' '2\n'
>  LINE 1, '3\n' '4\n'
>  LINE 2, '5\n' '6\n'
>  Traceback (most recent call last):
>File "", line 2, in 
>  StopIteration
>
> If you want to peek ahead without removing the line from the iterator,
> check out this recipe::
>
>  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/304373
>
> Which allows code like::
>
>  >>> lines_iter = peekable(open('temp.txt'))
>  >>> for i, line in enumerate(lines_iter):
>  ... print 'LINE %i, %r %r' % (i, line, lines_iter.peek())
>  ...
>  LINE 0, '1\n' '2\n'
>  LINE 1, '2\n' '3\n'
>  LINE 2, '3\n' '4\n'
>  LINE 3, '4\n' '5\n'
>  LINE 4, '5\n' '6\n'
>  LINE 5, '6\n' '7\n'
>  Traceback (most recent call last):
>...
>  StopIteration
>
> (Note that the recipe doesn't try to catch the StopIteration, but if you
> want that suppressed, it should be a pretty simple change.)
>
> STeVe

thanks,  lines_iter.next() is what i need at the moment.

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


which version libpcap

2007-04-13 Thread eight02645999
hi
from the web, i found 2 kinds of wrappers for libpcap, one is
pylibpcap, the other is pcapy. may i know which is more popularly
used? thanks

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


list insertion question

2007-04-16 Thread eight02645999
hi
i have a list (after reading from a file), say
data = [ 'a','b','c','d','a','b','e','d']

I wanted to insert a word after every 'a', and before every 'd'. so i
use enumerate this list:
for num,item in enumerate(data):
if "a" in item:
data.insert(num+1,"aword")
if "d" in item:
data.insert(num-1,"dword") #this fails
but the above only inserts after 'a' but not before 'd'.  What am i
doing wrong? is there better way?thanks

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


regexp qns

2007-01-19 Thread eight02645999
hi
suppose i have a string like

test1?test2t-test3*test4*test5$test6#test7*test8

how can i construct the regexp to get test3*test4*test5 and
test7*test8, ie, i want to match * and the words before and after?
thanks

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


Re: regexp qns

2007-01-19 Thread eight02645999
James Stroud wrote:
> [EMAIL PROTECTED] wrote:
> > hi
> > suppose i have a string like
> >
> > test1?test2t-test3*test4*test5$test6#test7*test8
> >
> > how can i construct the regexp to get test3*test4*test5 and
> > test7*test8, ie, i want to match * and the words before and after?
> > thanks
> >
>
>
> py> import re
> py> s = 'test1?test2t-test3*test4*test5$test6#test7*test8'
> py> r = re.compile(r'(test\d(?:\*test\d)+)')
> py> r.findall(s)
> ['test3*test4*test5', 'test7*test8']
>
> James

thanks !
I check the regexp doc it says:
"""
(?:...)
A non-grouping version of regular parentheses. Matches whatever
regular expression is inside the parentheses, but the substring matched
by the group cannot be retrieved after performing a match or referenced
later in the pattern.
"""
but i could not understand this : r'(test\d(?:\*test\d)+)'. which
parenthesis is it referring to? Sorry, could you explain the solution ?
thanks

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


strip question

2007-01-26 Thread eight02645999
hi
can someone explain strip() for these :
[code]
>>> x='www.example.com'
>>> x.strip('cmowz.')
'example'
[/code]

when i did this:
[code]
>>> x = 'abcd,words.words'
>>> x.strip(',.')
'abcd,words.words'
[/code]

it does not strip off "," and "." .Why is this so?
thanks

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


catching java program return

2006-03-13 Thread eight02645999
hi

i have to run a java program inside my python script.
i have some java classes declared:
os.environ['CLASSPATH'] = "blah path"

then i used the os.system method to invoke the java program and using
ret = os.WEXITSTATUS(os.system(cmd)) to catch the return

Java gave me an error about unable to locate some classes,  and the ret
value is 0. Why is this so? thanks
can anyone advise also on how can i properly catch the correct Java
generated exceptions in the above case. I was thinking i could use
subprocess module, is there a good example of using this module instead
of using os.system? or are they both achieve the same results?

thanks very much for your help.

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


insert chars into string

2006-03-17 Thread eight02645999
hi
is there a string method to insert characters into a string?
eg
str = "abcdef"
i want to insert "#" into str so that it appears "abc#def"

currently what i did is convert it to a list, insert the character
using insert() and then join them back as string.. 
thanks

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


telnet session

2006-03-29 Thread eight02645999
hi
i am using a telnet session to simulate an authentication mechanism
USER = "user"
PASSWORD = "password"
try:
telnet = telnetlib.Telnet(HOST)
telnet.set_debuglevel(5)
telnet.read_until("login: ")
telnet.write(USER + "\n")
telnet.read_until("Password: ")
telnet.write(PASSWORD + "\n")
except:
print "failed to telnet"
else:
try:
telnet.write("ls\n")
except:
print "cannot ls"
else:
telnet.write("exit\n")
print telnet.read_all()


When i purposely input a wrong password, it "hangs" at the login prompt
waiting for
login and Password. The host i am telnetting to is a unix server.
How can i "exit" this login prompt if the user keys in wrong password
in my script?

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


telnet session

2006-03-29 Thread eight02645999
hi
i am using a telnet session to simulate an authentication mechanism
USER = "user"
PASSWORD = "password"
try:
telnet = telnetlib.Telnet(HOST)
telnet.set_debuglevel(5)
telnet.read_until("login: ")
telnet.write(USER + "\n")
telnet.read_until("Password: ")
telnet.write(PASSWORD + "\n")
except:
print "failed to telnet"
else:
try:
telnet.write("ls\n")
except:
print "cannot ls"
else:
telnet.write("exit\n")
print telnet.read_all()


When i purposely input a wrong password, it "hangs" at the login prompt
waiting for
login and Password. The host i am telnetting to is a unix server.
How can i "exit" this login prompt if the user keys in wrong password
in my script?

thanks

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


a question on re

2006-03-31 Thread eight02645999
hi

i tried to search 2 patterns

pat1 = re.compile("blah")
pat2 = re.compile("blah2")


if i do
if re.findall(pat1,something) and re.findall(pat2,something):
   do something

if does not work

but when i do a nest if,

if re.findall(pat1,something) :
   if re.findall(pat2,something):
   do something

it works..

please advise on why the first code doesnt work. 
thanks

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


ftplib question

2006-04-07 Thread eight02645999
hi
my purpose is just to connect to an FTP server and delete all files in
a directory
Is there a way using ftplib module? something like ftp.delete("*") ?
another way i can do is using LIST to list out all the files in that
directory, grab the filename, append to an array, then do a for loop to
delete one by one.
using the ftplib retrlines('LIST') , it shows me all the lines with
-rw-r--r--   1 user grp 6302 Apr  7 15:30  some file
how can i get only the filename?
thanks

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


passing argument to script

2006-04-07 Thread eight02645999
hi

if i have a string like this

"ABCE-123456  ABC_DEF_Suggest(abc def ghi).txt"

that needs to be passed to a python script
and i wanted to get the words inside the brackets after i passed this
string. I did a re
something like

thestring = sys.argv[1:]
pat = re.compile(r".*\((.*)\)\.txt$")
if pat.search(thestring):
   words = pat.search(thestring).group(1)

but it doesn't return anything for words variable.
When i specifically define the string inside the python script , it
works

thestring = "ABCE-123456  ABC_DEF_Suggest(abc def ghi).txt"

I also tried str(thestring) but also did not work
what is wrong with the argument passing?

thanks

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


how to pipe to variable of a "here document"

2006-04-09 Thread eight02645999
hi

I need to execute sql command using a "here document" like in unix.

os.popen("osql", "w").write("""\
select * from table
go
""") 

how can i pipe these result of the select into a variable?
thanks

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