Passing a object to my test case from mainthread using unittest

2012-04-19 Thread venkat



i am new to python and just now started developing an linux application 
automation.


scenario i am trying is

thread.py --- will invoke all primary device threads and load test from 
testcase


admincase.py --- hold my tests for the case..

what i am unable to do is i want to pass certain objects from thread.py 
to admincase.py when loading the test. how do i do that..


object which i am tryin to pass is (*EppQueue*)

thread.py code

|import  threading
import  sys
import  time
import  logging
import  os
import  Queue
from  EPPimport  EPP
import  ldtp
import  ldtputils
from  functionsimport  functions
from  admincasesimport  admincases
import  unittest

#logging.basicConfig(level=logging.DEBUG,
#format='(%(threadName)-10s) %(message)s',
#)
class  inittest(unittest.TestCase):
global  fun
global  EppQueue
global  window_name

def  cleanup(epp_port):
if  os.path.exists(epp_port):
os.unlink(epp_port)

def  start_threads(EppQueue,server_ip,epp_port):
epp=  EPP
EPP1=  threading.Thread(name='EPP',  target=epp,  
args=(server_ip,54321,epp_port,EppQueue,))
EPP1.setDaemon(True)
EPP1.start()
return  epp
fun=  functions()
EppQueue  =  Queue.Queue(1)
server_ip='192.168.10.125'
epp_port='/dev/ttyS17'
print  "Starting"
cleanup(epp_port)
print  "Clean up Over"
epp=  start_threads(EppQueue,server_ip,epp_port)
raw_input("## Please Start the main appilcation in the ATM and hit a KEY to 
continue ")
check=  0
while  check==  0:
window_name=  fun.start_up_verify('atm_main_app')
if  any(window_name):
check=  1
else:
check=  0
if  not  any(window_name):
print  "Please start the application and run the test"
sys.exit(0)
else:
print  window_name
print  "SYSTEM IS READY TO PERFORM TEST"
raw_input("## HIT ANY KEY TO START UNIT TEST ")
raw_input("kkk")  
test=  unittest.defaultTestLoader.loadTestsFromName("admincases")

unittest.TextTestRunner(verbosity=2).run(test)
raw_input("keyy")
print  "final"
|

admincase.py code

|import  unittest
from  functionsimport  functions
import  time
import  Queue

class  admincases(unittest.TestCase):
global  fun
global  EppQueue
global  window_name

def  test_case_1(self):
print  "test case 1"
window_name=  'frmatm_main_app'
fun.send_queue(self.EppQueue,"send_keys,&")
fun.verify_screen(window_name,"ico0")
fun.send_queue(self.EppQueue,"send_keys,C")
fun.verify_screen(window_name,"ManagementFunctions")
fun.send_queue(self.EppQueue,"send_keys,001234")
fun.verify_screen(window_name,"MainMenu")
fun.send_queue(self.EppQueue,"send_keys,1")
fun.verify_screen(window_name,"Diagnostics")
fun.send_queue(self.EppQueue,"send_keys,1")
fun.verify_screen(window_name,"TerminalStatus")
fun.send_queue(self.EppQueue,"send_keys,2")
time.sleep(10)
fun.send_queue(self.EppQueue,"send_keys,")


fun=  functions()
#EppQueue = Queue.Queue(1)
|

Need some assistance on this...

--
Regards
Venkat.S

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


Generalized Linear Least Squares Problems

2005-05-31 Thread venkat
Hi,

I want to solve linear least sqaure problem( min||c-Ax||2 subject to
Bx=d ). How do I do it in python. lapack has a routine for doing this
(DGGLSE). Can I access this from python?

TIA,
venkat.

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


Installation problem: Python 2.5 on solaris 8

2007-03-02 Thread Venkat
I am very new to Python. I installed Python in Windows and learning
it. But i need to install Python on Solaris 8 to automate few things
as my build environment is on Solaris. When i tried to download python
2.5 source code and tried to compile i got the error saying
"configure: error: cannot compute sizeof (int), 77".

Between i am also getting parse errors for few files including
siginfo.h

/usr/include/sys/siginfo.h:74: parse error before `pthread_attr_t'
/usr/include/sys/siginfo.h:76: parse error before `}'
/usr/include/pthread.h:152: parse error before `*'
/usr/include/pthread.h:153: parse error before `*'
/usr/include/pthread.h:154: parse error before `*'
/usr/include/pthread.h:155: parse error before `*'
/usr/include/pthread.h:156: parse error before `*'
/usr/include/pthread.h:157: parse error before `*'
/usr/include/pthread.h:158: parse error before `*'
/usr/include/pthread.h:159: parse error before `*'
/usr/include/pthread.h:160: parse error before `*'
/usr/include/pthread.h:161: parse error before `*'
/usr/include/pthread.h:162: parse error before `*'
/usr/include/pthread.h:163: parse error before `*'
/usr/include/pthread.h:164: parse error before `*'
/usr/include/pthread.h:165: parse error before `*'
/usr/include/pthread.h:166: parse error before `*'
/usr/include/pthread.h:168: parse error before `*'
/usr/include/pthread.h:170: parse error before `*'
/usr/include/pthread.h:171: parse error before `void'
/usr/include/pthread.h:172: parse error before `*'
/usr/include/pthread.h:172: parse error before `)'
/usr/include/pthread.h:173: parse error before `void'
/usr/include/pthread.h:177: parse error before `int'
/usr/include/pthread.h:178: parse error before `int'
/usr/include/pthread.h:183: parse error before `*'
/usr/include/pthread.h:183: parse error before `)'
/usr/include/pthread.h:185: parse error before `const'
/usr/include/pthread.h:187: parse error before `pthread_self'
/usr/include/pthread.h:192: parse error before `*'
/usr/include/pthread.h:193: parse error before `*'
/usr/include/pthread.h:194: parse error before `*'
/usr/include/pthread.h:195: parse error before `*'
/usr/include/pthread.h:196: parse error before `*'
/usr/include/pthread.h:197: parse error before `*'


==
uname -m = sun4u
uname -r = 5.8
uname -s = SunOS
uname -v = Generic_108528-15

/usr/bin/uname -p = sparc
/bin/uname -X = System = SunOS
Node = sword
Release = 5.8
KernelID = Generic_108528-15
Machine = sun4u
BusType = 
Serial = 
Users = 
OEM# = 0

==


Thanks a lot
-Venkat

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


Re: newbie ?s

2005-01-13 Thread Venkat B
> > 1) I was wondering if anyone has opinions on the ability of
CGIHTTPServer (a
> > forking variant) to be able to handle this.
>
> Why not use apache?

Wanted something with less footprint.


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


newbie ?s

2005-01-13 Thread Venkat B
Hi folks,

I'm looking build a CGI-capable SSL-enabled web-server around Python 2.4 on
Linux.
It is to handle ~25 hits possibly arriving "at once". Content is non-static
and built by the execution of py cgi-scripts talking to a few backend
processes.

1) I was wondering if anyone has opinions on the ability of CGIHTTPServer (a
forking variant) to be able to handle this.
2) If so, would something like pyOpenSSL be useful to make such a webserver
SSL-enabled.

I checked out John Goerzen's book: Foundations of Python Network Programming
(ISBN 1590593715) and searched around. While I found how one can write py
scripts that could communicate with SSL-enabled webservers, tips on building
SSL-enabled webservers isn't obvious.

I was hoping to build a cleaner solution around the CGIHTTPServer variant
instead of say something like mini-httpd/OpenSSL/Python. I'd appreciate any
pointers.

TIA,
/venkat




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


Re: BaseHTTPServer.BaseHTTPRequestHandler and HTTP chunking

2005-03-10 Thread Venkat B
> No. Hardly any HTTP 1.1 features are supported.

Hi all,

I'd like to know more about the limitations.

Somewhere, is there a list of the actual subset of HTTP 1.1 features
supported. There's not much related info at the python.org site. There
appears to be just a limited note on 1.1 in
http://www.python.org/doc/2.4/lib/module-BaseHTTPServer.html with regards to
using the protocol_version variable/setting. No clue to extent of support.

Thanks,
/v


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


Re: Web framework

2005-03-13 Thread Venkat B
> I'd say Nevow! For apache setup, you might be interested in my wsgi [1]
> implementation.

Hi Sridhar,

Are you aware of Nevow's "integrability" with the webservers (CGIHTTPServer
in particular) that come packaged with Python itself ?

Thanks,
/venkat


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


Python & LEGO Mindstorm control...

2005-03-29 Thread Venkat B
Hi all,

I have a question re the use of Python to control a robot built with the
LEGO Mindstorm system.
This is to help my 11yr old with his increased interest in 'programming' and
'robotics'... If not feasible, he wants to use the graphical-tool that comes
with it...

Would you suggest:
1. Using LegOS (http://legos.sourceforge.net/) and writing/using py
extensions from a Linux-box, OR
2. Using LeJOS (http://lejos.sourceforge.net/) and writing Jython utils.

Wanted to incorporate Python somehow, as it may be quite appropriate for his
age. Will have to help quite a bit in either case, tho... but was wondering
which is a more treaded path...

TIA,
/venkat


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


Python 2.4.1 build (configure) ?

2005-03-30 Thread Venkat B
Hi all,

While building the latest 2.4.1 version for Linux/RH9, I wanted to enable
IPV6
support (sockets). So, I ran the configure command ./configure --enable-ipv6
Then I ran the 'make' and 'make altinstall' commands.

When I checked the .py sources (in Lib folder) thru grep for 'ipv6', I see
the same
references I'd see, if I ran the configure command without the --enable-ipv6
option.
Is that normal or is there an issue I need to address here.

Thanks,
/venkat


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


mini_httpd (ACME Labs) & Python 2.4.1 integration

2005-04-03 Thread Venkat B
Hi folks,I have a webserver based on mini_httpd
v1.19(http://www.acme.com/software/mini_httpd/).I'd like to run some
python-based CGI scripts via this webserver on an RH9 system.In theory, with
the right env settings, Ishould be able to launch mini_httpd like so:
mini_httpd -c *.pyand be able to run scripts like so:
http://fqdn/simple.pyUsing info from (python) sys.path, multiple
get_config_var(..)s and sys.executable, Iwas able to build and use the env
settings (CGI_PATH, CGI_LD_LIBRARY_PATH) in the mini_httpd sources.However,
when I tried accessing the simple.pyscript as in the url above, I get an
error(errno of 8 - Exec format error) when thecode attempts to invoke the
execve() function. This same script works ok from a CGIHTTPServer.py based
test webserver.I was wondering if you knew what the right env settings
should be to get the py script working... I tried to google around to no
avail.

Thanks a lot.
Regards,
/venkat


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


Re: mini_httpd (ACME Labs) & Python 2.4.1 integration

2005-04-04 Thread Venkat B
We found the answer, just in case one was looking for it...

I turns out that setting the environment params (CGI_PATH & CGI_LD_LIB_PATH)
is not sufficient. One has to still add the path entry to the script
itself... like so: #! /python2.4

May also work with ensuring env variable PYTHONPATH is set right.

/venkat


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


MySQLdb Help

2013-09-17 Thread Venkat Addala
Hi all,


  I'm new to python, i am connecting mysql database with python. now i want
to do sanitation on the database, like to remove "\n", extra spaces blah
blah.. and update it back to mysql database. i was trying somthing, here is
my code, can you please provide me solution for this..

#!/usr/bin/python
import MySQLdb as mdb

con = mdb.connect('localhost', 'root', 'pass@123', 'workbench');

with con:
  cur = con.cursor()
  cur.execute("SELECT descrip FROM table LIMIT 1")
  rows = cur.fetchall()
  for row in rows:
row_new = row[0].split("\n", " ")
row = "".join(row_new)
  print row
exit(0)
--

Regards
Boffin
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: MySQLdb Help

2013-09-17 Thread Venkat Addala
hey Ben,

Thanks for your solution, i am done with this before, now i'm having
problem after deleting \n and extra spaces, i want to update it back it
again to mysql db.

For this i tried using regular expression  check this code;

# -*- coding: utf-8 -*-
import re
import MySQLdb

pattern = re.compile('@(.*)@.*$')

conn = MySQLdb.connect(
  host='localhost', user='root',
  passwd='pass123', db='workbench', charset='utf8')

cursor = conn.cursor()

cursor.execute("""
SELECT * FROM gene where gene_id=13 AND `descrip` regexp "^@.*@.*$"
LIMIT 1""")
rows = cursor.fetchall()
for row in rows:
  rows_new = pattern.match(row[1])
if rows_new.group(1) is not None:
  cursor.execute("""
  update gene set descrip = %s where descrip = %s""",
(rows_new.group(1), row[0]))
  #cursor.execute("""
  #update gene set descrip = %s where descrip = %s""",
(rows_new.group(1), row[0]))

  conn.close()


--
Regards
Boffin





On Tue, Sep 17, 2013 at 1:05 PM, Ben Finney wrote:

> Venkat Addala  writes:
>
> >   I'm new to python
>
> Welcome! Congratulations on choosing Python for programming.
>
> > i am connecting mysql database with python. now i want to do
> > sanitation on the database, like to remove "\n", extra spaces blah
> > blah.. and update it back to mysql database.
>
>
> > i was trying somthing, here is my code, can you please provide me
> > solution for this..
>
> Thank you for providing a small, complete example.
>
> You should also describe what behaviour you expect, and what behaviour
> you're getting instead. What happens, and how are you expecting it to be
> different?
>
> > #!/usr/bin/python
> > import MySQLdb as mdb
> >
> > con = mdb.connect('localhost', 'root', 'pass@123', 'workbench');
>
> There's no need to end Python statements with a semicolon; it's only
> confusing to do it.
>
> >   rows = cur.fetchall()
> >   for row in rows:
>
> You never use ‘rows’ for anything else, so you may as well forget it and
> just iterate directly over the return value::
>
> for row in cur.fetchall():
>
> > row_new = row[0].split("\n", " ")
>
> Read the documentation for ‘str.split’ to see what is wrong with the
> above call.
>
>
> You might also be interested in the ‘python-tutor’ forum, specially
> designed for beginners with basic questions about Python
> http://mail.python.org/mailman/listinfo/tutor>
> http://dir.gmane.org/gmane.comp.python.tutor>.
>
> Good hunting to you!
>
> --
>  \ “Sunday: A day given over by Americans to wishing that they |
>   `\  themselves were dead and in Heaven, and that their neighbors |
> _o__)were dead and in Hell.” —Henry L. Mencken |
> Ben Finney
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Remove \n, " " from tuple.

2013-09-18 Thread Venkat Addala
Hi all,

I have a tuple in this format, which is retrived using MySQLdb, now i want
to remove \n and extra spaces in this.

13L, 'ssDsC', 'CEs5s1, DsC', 'srylscetsmight\nghtscetylsse', '3', '3q25.1',
151531861L, 151546276L, '+', '1 kjafhkfhlad\fdfdsdf ghtscetylsse \ncontends
the sctivity of dsfdk srylsmine N-scetyltrsnsfersse thst scts ss s cstslyst
inbiotrsnsformstion fghjfg for srylsmine snd bvhghbh smine csrcinogens.
Bgskjdg in ssDsC dfkdkdf in bresst snd prostrste csncer.', '', 'Msdhurs
\nsgdfgvslingegowds', dstetime.dste(2013, 6, 14), None



--
Regards
Venkat Addala  <http://in.linkedin.com/in/venkataddala/>
Computational Biologist
  O__  
 _/ /`_ ---
(*) \(*) --
-- 
https://mail.python.org/mailman/listinfo/python-list


About __files

2006-07-10 Thread venkat pathy
Hi all,  I came across a series of functions starting with "__". For example, __fun() . May I know what are all these functions ? I came across __init__ like functions starting and ending with "__".
Whether they are constructors which are overloaded ?
-- 
http://mail.python.org/mailman/listinfo/python-list

problem with urllib

2009-03-31 Thread venkat sanaka
hii everyone

I am new to python programming.And i started implementing a http client
using urllib in which
i was facing a problem with proxy support.i was behind a proxy server and
need to use
proxy of format 10.1.2.21:8080 to connect to internet.when i used this with
proxyhandler
of urllib i got errors showing invalid proxy.can someone help me out plzzz.


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


Re: problem with urllib

2009-03-31 Thread venkat sanaka
This was the code i executed.

>>> proxies={'http':'10.1.2.21:9090'}
>>> opener = urllib.request.FancyURLopener(proxies)
>>> f = opener.open("http://www.python.org";)

Exception AttributeError: AttributeError("'FancyURLopener' object has no
attribute 'tempcache'",) in > ignored
Traceback (most recent call last):
  File "", line 1, in 
f = opener.open("http://www.python.org";)
  File "C:\Python30\lib\urllib\request.py", line 1439, in open
return self.open_unknown_proxy(proxy, fullurl, data)
  File "C:\Python30\lib\urllib\request.py", line 1458, in open_unknown_proxy
raise IOError('url error', 'invalid proxy for %s' % type, proxy)
IOError: [Errno url error] invalid proxy for http: '10.1.2.21:9090'

I know that url has to be used in proxies list but my proxy address is
10.1.2.21:9090 and it is squid proxy server.

Regards
venkat

On Wed, Apr 1, 2009 at 4:35 AM, Chris Rebert  wrote:

> 2009/3/31 venkat sanaka :
> > hii everyone
> >
> > I am new to python programming.And i started implementing a http client
> > using urllib in which
> > i was facing a problem with proxy support.i was behind a proxy server and
> > need to use
> > proxy of format 10.1.2.21:8080 to connect to internet.when i used this
> with
> > proxyhandler
> > of urllib i got errors showing invalid proxy.can someone help me out
> plzzz.
>
> What errors exactly? People will need the error message and full
> traceback in order to help you.
> A copy of your code would also be necessary for anyone trying to help you.
>
> Cheers,
> Chris
> --
> I have a blog:
> http://blog.rebertia.com
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: problem with urllib

2009-03-31 Thread venkat sanaka
Yeah I did i was getting the same error as i got without using http in the
url.

Regards venkat.

On Wed, Apr 1, 2009 at 4:46 AM, Chris Rebert  wrote:

> > On Wed, Apr 1, 2009 at 4:35 AM, Chris Rebert  wrote:
> >>
> >> 2009/3/31 venkat sanaka :
> >> > hii everyone
> >> >
> >> > I am new to python programming.And i started implementing a http
> client
> >> > using urllib in which
> >> > i was facing a problem with proxy support.i was behind a proxy server
> >> > and
> >> > need to use
> >> > proxy of format 10.1.2.21:8080 to connect to internet.when i used
> this
> >> > with
> >> > proxyhandler
> >> > of urllib i got errors showing invalid proxy.can someone help me out
> >> > plzzz.
> >>
> >> What errors exactly? People will need the error message and full
> >> traceback in order to help you.
> >> A copy of your code would also be necessary for anyone trying to help
> you.
>
> On Tue, Mar 31, 2009 at 4:10 PM, venkat sanaka 
> wrote:
> > This was the code i executed.
> >
> >>>> proxies={'http':'10.1.2.21:9090'}
> >>>> opener = urllib.request.FancyURLopener(proxies)
> >>>> f = opener.open("http://www.python.org";)
> >
> > Exception AttributeError: AttributeError("'FancyURLopener' object has no
> > attribute 'tempcache'",) in  > > ignored
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > f = opener.open("http://www.python.org";)
> >   File "C:\Python30\lib\urllib\request.py", line 1439, in open
> > return self.open_unknown_proxy(proxy, fullurl, data)
> >   File "C:\Python30\lib\urllib\request.py", line 1458, in
> open_unknown_proxy
> > raise IOError('url error', 'invalid proxy for %s' % type, proxy)
> > IOError: [Errno url error] invalid proxy for http: '10.1.2.21:9090'
> >
> > I know that url has to be used in proxies list but my proxy address is
> > 10.1.2.21:9090 and it is squid proxy server.
>
> Have you tried including the protocol in the proxy URL as per the
> module's examples? Like:
>
> proxy = {'http' : 'http://10.1.2.21:9090'}
> f = urllib.urlopen("http://python.org";, proxies=proxy)
>
> Cheers,
> Chris
>
> --
> I have a blog:
> http://blog.rebertia.com
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: problem with urllib

2009-03-31 Thread venkat sanaka
The correct one was 10.1.2.21:9090.In my code i tried with all the possible
ways and end up in getting no result.sry for that.
For more clarity I will give proxy settings in mozilla as:
 Http proxy:10.1.2.21   port:9090

Regards
venkat

On Wed, Apr 1, 2009 at 5:37 AM, Emile van Sebille  wrote:

> venkat sanaka wrote:
>
>> Yeah I did i was getting the same error as i got without using http in the
>> url.
>>
>>
> In your first message you say you need to use proxy of format
> 10.1.2.21:8080 -- but in your code example you've written and the
> traceback shows '10.1.2.21:9090 <http://10.1.2.21:9090>'
>
> Which is right?
>
> Emile
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: problem with urllib

2009-03-31 Thread venkat sanaka
Thanks for ur suggestions Terry.These are really helpful for a newbie like
me in python programming.

Regards
Venkat

On Wed, Apr 1, 2009 at 5:59 AM, Terry Reedy  wrote:

> venkat sanaka wrote:
>
>> This was the code i executed.
>>
>>  >>> proxies={'http':'10.1.2.21:9090 <http://10.1.2.21:9090>'}
>>  >>> opener = urllib.request.FancyURLopener(proxies)
>>  >>> f = opener.open("http://www.python.org";)
>>
>> Exception AttributeError: AttributeError("'FancyURLopener' object has no
>> attribute 'tempcache'",) in > > ignored
>> Traceback (most recent call last):
>>  File "", line 1, in 
>>f = opener.open("http://www.python.org";)
>>  File "C:\Python30\lib\urllib\request.py", line 1439, in open
>>return self.open_unknown_proxy(proxy, fullurl, data)
>>  File "C:\Python30\lib\urllib\request.py", line 1458, in
>> open_unknown_proxy
>>raise IOError('url error', 'invalid proxy for %s' % type, proxy)
>> IOError: [Errno url error] invalid proxy for http: '10.1.2.21:9090 <
>> http://10.1.2.21:9090>'
>>
>
> If you do not understand the error message and the error is in Python code,
> you can go look at the code in the file to get a better idea.  In this case,
> the 'raise' statement is almost certainly preceded by an if statement.  See
> what condition was checked that your input would fail. If necessary, you can
> edit request.py to add print statements (what I would do, after copying to
> request.bak) what args are actually passed to open_unknown_proxy.  Or try
> pdb (which I never have).
>
>
>> I know that url has to be used in proxies list but my proxy address is
>> 10.1.2.21:9090 <http://10.1.2.21:9090> and it is squid proxy server.
>>
>> Regards
>> venkat
>>
>> On Wed, Apr 1, 2009 at 4:35 AM, Chris Rebert > [email protected]>> wrote:
>>
>>2009/3/31 venkat sanaka ><mailto:[email protected]>>:
>> > hii everyone
>> >
>> > I am new to python programming.And i started implementing a http
>>client
>> > using urllib in which
>> > i was facing a problem with proxy support.i was behind a proxy
>>server and
>> > need to use
>> > proxy of format 10.1.2.21:8080 <http://10.1.2.21:8080> to connect
>>to internet.when i used this with
>> > proxyhandler
>> > of urllib i got errors showing invalid proxy.can someone help me
>>out plzzz.
>>
>>What errors exactly? People will need the error message and full
>>traceback in order to help you.
>>A copy of your code would also be necessary for anyone trying to
>>help you.
>>
>>Cheers,
>>Chris
>>--
>>I have a blog:
>>http://blog.rebertia.com
>>
>>
>>
>> 
>>
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: problem with urllib

2009-03-31 Thread venkat sanaka
Hello everyone
I am happy that my code finally worked and got the expected result.i suppose
the problem is with python 3 becoz i wrote
the similar code with python 2.5 without explicitly mentioning the proxy and
it worked.It has taken the system's proxy settings as given in the
documentation.Thanks a lot for ur replies.
Final code:
>>>import urllib2
>>> opener = urllib2.build_opener()
>>> opener.add_header = [('User-agent', 'Mozilla')]
>>>res=opener.open('http://www.google.com')
>>> print res.read()


On Wed, Apr 1, 2009 at 5:59 AM, Terry Reedy  wrote:

> venkat sanaka wrote:
>
>> This was the code i executed.
>>
>>  >>> proxies={'http':'10.1.2.21:9090 <http://10.1.2.21:9090>'}
>>  >>> opener = urllib.request.FancyURLopener(proxies)
>>  >>> f = opener.open("http://www.python.org";)
>>
>> Exception AttributeError: AttributeError("'FancyURLopener' object has no
>> attribute 'tempcache'",) in > > ignored
>> Traceback (most recent call last):
>>  File "", line 1, in 
>>f = opener.open("http://www.python.org";)
>>  File "C:\Python30\lib\urllib\request.py", line 1439, in open
>>return self.open_unknown_proxy(proxy, fullurl, data)
>>  File "C:\Python30\lib\urllib\request.py", line 1458, in
>> open_unknown_proxy
>>raise IOError('url error', 'invalid proxy for %s' % type, proxy)
>> IOError: [Errno url error] invalid proxy for http: '10.1.2.21:9090 <
>> http://10.1.2.21:9090>'
>>
>
> If you do not understand the error message and the error is in Python code,
> you can go look at the code in the file to get a better idea.  In this case,
> the 'raise' statement is almost certainly preceded by an if statement.  See
> what condition was checked that your input would fail. If necessary, you can
> edit request.py to add print statements (what I would do, after copying to
> request.bak) what args are actually passed to open_unknown_proxy.  Or try
> pdb (which I never have).
>
>
>> I know that url has to be used in proxies list but my proxy address is
>> 10.1.2.21:9090 <http://10.1.2.21:9090> and it is squid proxy server.
>>
>> Regards
>> venkat
>>
>> On Wed, Apr 1, 2009 at 4:35 AM, Chris Rebert > [email protected]>> wrote:
>>
>>2009/3/31 venkat sanaka ><mailto:[email protected]>>:
>> > hii everyone
>> >
>> > I am new to python programming.And i started implementing a http
>>client
>> > using urllib in which
>> > i was facing a problem with proxy support.i was behind a proxy
>>server and
>> > need to use
>> > proxy of format 10.1.2.21:8080 <http://10.1.2.21:8080> to connect
>>to internet.when i used this with
>> > proxyhandler
>> > of urllib i got errors showing invalid proxy.can someone help me
>>out plzzz.
>>
>>What errors exactly? People will need the error message and full
>>traceback in order to help you.
>>A copy of your code would also be necessary for anyone trying to
>>help you.
>>
>>Cheers,
>>Chris
>>--
>>I have a blog:
>>http://blog.rebertia.com
>>
>>
>>
>> 
>>
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


"str object is not callable" error

2009-04-08 Thread venkat sanaka
HIi everyone.
i was using python/c api to call a python function from c and I know the
name of the function which i want to call.Is there any way to do that??
This is the method i tried...

for eg:This is the python function i wants to call.
 >>>def add(x):
...   return x+10


This is my code in C:
PyObject *result = NULL;
int arg;
PyObject *arglist;
arg = 123;
my_callback = "add";
arglist = Py_BuildValue("(i)", arg);
result = PyObject_CallObject(my_callback, arglist);
Py_DECREF(arglist);
return result;

I was getting a error like "str object is not callable".From the error i
came to know that i was assigning "add" as a string which caused this
error.Then how to make it a callable object??

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


Help needed to resolve ImportError

2009-05-13 Thread Venkat Raju





Hi,
We currently use VC6.0 and Python 2.2 for our project. 
 
As part of porting our project to VC2005 when i try to compile our application, 
it gives the following error
 
Traceback (most recent call last):
File 
"v:\Component\DS\scripts\messagebuilder\IL_Messagebuilder\test\test_IL_setget.py",
 line 20, in 
import IL_setget
File "\Component\DS\scripts\messagebuilder\IL_messagebuilder\IL_setget.py", 
line 22, in 
import IL_IEbuilder
File "\Component\DS\scripts\messagebuilder\IL_messagebuilder\IL_IEbuilder.py", 
line 11, in 
from MessageDictionary import *
File "\Component\LS\LSPythonFiles\MessageDictionary.py", line 3, in 
import ScriptInterpreter
ImportError: No module named ScriptInterpreter
 
 
 Basically, we are trying to import a VC compiled DLL into python script which 
generates another Python file. This issue doesnt occur in VC6.0 setup
 
I have tried setting path variables and options like copying 
scriptInterpreter.dll to python installation path and so on. HOwever it doesnt 
work.
 
Are there any compatibility issues between VC2005 and python 2.2? HOw can i 
resolve this.
 
Your help is highly appreciated.
 
Best Regards
Venkat
 
 
 
 


_
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/india/windows/windowslive/photos.aspx-- 
http://mail.python.org/mailman/listinfo/python-list