Re: Unable to use Python IDLE after downloading the application

2017-04-17 Thread ASHISH A
Hi Team,

I also tried installing the 64 bit Python and now i get the attached
snapshot as error message,


Regards
Ashish


On Mon, Apr 17, 2017 at 11:06 PM, ASHISH A  wrote:

> Hi Team,
>
> I have a 64 bit system with Windows 801 Pro OS. I tried to install Python
> 3.6.1 from the below link :
> https://www.python.org/downloads/
>
> It automatically downloaded that 32 bit Python application and tried to
> launch IDLE (32 bit). I could not launch IDLE and it gave me an error
> saying DLL file missing (attached snapshot). I have downloaded the DLL file
> and also installed Microsoft C++ redistributable 2015.(After following
> steps on you-tube to fix such DLL issues).
>
> I am still unable to launch IDLE . Could you please let me know if the
> issue is because of the 32 bit version of Python on my 64 bit laptop ?
> Because the DLL file can not be an issue as i have already fixed it.
>
>
> Regards
> Ashish
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Unable to use Python IDLE after downloading the application

2017-04-17 Thread ASHISH A
PFA the snapshot of the error message..


Regards
Ashish

On Mon, Apr 17, 2017 at 11:06 PM, ASHISH A  wrote:

> Hi Team,
>
> I have a 64 bit system with Windows 801 Pro OS. I tried to install Python
> 3.6.1 from the below link :
> https://www.python.org/downloads/
>
> It automatically downloaded that 32 bit Python application and tried to
> launch IDLE (32 bit). I could not launch IDLE and it gave me an error
> saying DLL file missing (attached snapshot). I have downloaded the DLL file
> and also installed Microsoft C++ redistributable 2015.(After following
> steps on you-tube to fix such DLL issues).
>
> I am still unable to launch IDLE . Could you please let me know if the
> issue is because of the 32 bit version of Python on my 64 bit laptop ?
> Because the DLL file can not be an issue as i have already fixed it.
>
>
> Regards
> Ashish
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Unable to use Python IDLE after downloading the application

2017-04-17 Thread ASHISH A
Hi Team,

I have a 64 bit system with Windows 801 Pro OS. I tried to install Python
3.6.1 from the below link :
https://www.python.org/downloads/

It automatically downloaded that 32 bit Python application and tried to
launch IDLE (32 bit). I could not launch IDLE and it gave me an error
saying DLL file missing (attached snapshot). I have downloaded the DLL file
and also installed Microsoft C++ redistributable 2015.(After following
steps on you-tube to fix such DLL issues).

I am still unable to launch IDLE . Could you please let me know if the
issue is because of the 32 bit version of Python on my 64 bit laptop ?
Because the DLL file can not be an issue as i have already fixed it.


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


Tools/libraries to determine the call graph(call flow) of an python program (module/package)

2016-01-12 Thread ashish
Hi Folks,

I am trying to do the following.

I have a moderately complex python module/application X, whose source code i 
have access to.

I run X with the following command

python x.py   ... 


Internally, x.py callls y.py, which in turn calls z.py, etc etc

x.py ---> y.py ---> z.py ---> u.py ---> v.py

Is there a python library/tool/module , to which i give input the start point 
of X, x.py
and the input arguments, arg1, arg2, ..., argn

and which can come up with the call graph of X

I have tried looking at pycallgraph[0], but havent had much luck with it.
0. https://pypi.python.org/pypi/pycallgraph

Any suggestions,advice, pointers welcome.

Thanks a ton,
ashish


"Talk is cheap. Show me the code."
 - Linus Torvalds [ https://lkml.org/lkml/2000/8/25/132 ]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can tuples be replaced with lists all the time?

2014-03-02 Thread Ashish Panchal
No, not always. You can use yuples as dictionary key as keys are immutable
and you can't use it as list.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Diving in to Python - Best resources?

2014-01-21 Thread Ashish Panchal
The best resource I think is documentation provided by python
http://docs.python.org/
If You need to learn python from scratch http://docs.python.org/tut/tut.html
If you need a book for reference http://diveintopython3.ep.io/
-- 
https://mail.python.org/mailman/listinfo/python-list


Creating a torrent file & associated tracker through a django web app

2012-11-20 Thread ashish
Hi c.l.p folks

Following is a description of what i am trying to achieve :

The user should log into a django web app, select a file & the web app should 
generate a .torrent file & a private 
tracker(http://IP_ADDRESS:PORT_NUMBER/announce) for that .torrent file.

Basically, i want to programmatically create a .torrent file, on the server 
side.

I found two libraries mktorrent[1] & py3createtorrent [2], but i need help with 
how to create a torrent from a django web app.

Any suggestions for django modules or libraries which can do this ?

Any suggestions/pointers/ideas/links will be greatly appreciated

Thanks a ton,

cheers,

ashish

1. http://mktorrent.sourceforge.net/
2. http://www.robertnitsch.de/projects/py3createtorrent
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Remove uncide notation

2012-10-18 Thread Ashish Jain
On Thursday, 18 October 2012 15:10:33 UTC+5:30, Chris Rebert  wrote:
> On Thu, Oct 18, 2012 at 2:27 AM, Ashish Jain wrote:
> 
> > Hi,
> 
> >
> 
> > I have a html string in an object, when I do repr() of that object, I get 
> > value as:
> 
> >
> 
> > {'Id' : 1, 'Body': u' Hello '}
> 
> >
> 
> > I don't wish to have 'u' as the character in my string representation. As 
> > this is not a valid json notation now.
> 
> 
> 
> If you want JSON, then *use the freakin' `json` std lib module*!
> 
> http://docs.python.org/library/json.html
> 
> 
> 
> repr(...) != JSON
> 
> [It's similar only coincidentally, and only to a degree.]
> 
> 
> 
> Regards,
> 
> Chris

Thanks a lot!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Remove uncide notation

2012-10-18 Thread Ashish Jain
Hi,

I have a html string in an object, when I do repr() of that object, I get value 
as:

{'Id' : 1, 'Body': u' Hello '}

I don't wish to have 'u' as the character in my string representation. As this 
is not a valid json notation now.

Thanks for your help

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


Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine

2012-09-20 Thread ashish
On Thursday, September 20, 2012 10:39:28 AM UTC+5:30, Chris Angelico wrote:
> On Thu, Sep 20, 2012 at 2:27 PM, Steven D'Aprano
> 
>  wrote:
> 
> > On Wed, 19 Sep 2012 12:46:33 -0700, ashish wrote:
> 
> >
> 
> >> 2. I have a python script, local.py, running on local which needs to
> 
> >> pass arguments ( 3/4 string arguments, containing whitespaces like
> 
> >> spaces, etc ) to a python script, remote.py running on remote (the
> 
> >> remote machine).
> 
> >
> 
> > If 3/4 of the arguments are strings, what sort of objects are the other
> 
> > 1/4?

Sorry for the confusion Steven.
There are 3 or 4 arguments, all of which are strings.

> 
> 
> 
> I understand the OP as meaning "three or four string arguments".

Yup, that's what i meant.
> 
> 
> 
> ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Passing arguments to & executing, a python script on a remote machine from a python script on local machine (using ssh ?)

2012-09-19 Thread ashish
Hi c.l.p folks

Here is my situation

1. I have two machines. Lets call them 'local' & 'remote'.
Both run ubuntu & both have python installed

2. I have a python script, local.py, running on 'local' which needs to pass 
arguments ( 3/4 string arguments, containing whitespaces like spaces, etc ) to 
a python script, remote.py running on 'remote' (the remote machine).

I have the following questions:

1. What's the best way to accomplish my task ?
I have researched quite a bit & pretty much everybody is using ssh.
After googling a bunch, most people are using very complex workarounds to do 
this sort of thing. 

I googled & found people using several libraries to accomplish ssh to remote 
machine & execute a command on remote machine.
paramiko ( now forked into the ssh moduke), fabric, pushy ,etc

People who have used any of these libraries, which one would you recommend, as 
the most apt (simple & easy to use, lightweight, best performance, etc) for my 
situation ?

2. I would prefer a solution, which does NOT require the installation of extra 
libraries on the local & remote machines.
If installing external librar

3. Has anybody been able to do this using os.system ?

I tried this
>>> import os
>>> os.system ("ssh remoteuser@remote python remote.py arg1 arg2 arg3")

This worked, but if the arguments i tried to pass, had spaces, i was not able 
to 'escape' the spaces.

Any & all explanations/links/code 
snippets/thoughts/ideas/suggestions/feedback/comments/ of the Python tutor 
community would be greatly appreciated.

Thanks a ton

cheers
ashish

email : 
ashish.makani
domain:gmail.com

“The only way to do great work is to love what you do. If you haven’t found it 
yet, keep looking. Don’t settle. As with all matters of the heart, you’ll know 
when you find it.” - Steve Jobs (1955 - 2011)
-- 
http://mail.python.org/mailman/listinfo/python-list


Passing arguments to & executing, a python script on a remote machine from a python script on local machine

2012-09-19 Thread ashish
Hi PyTutor Folks

Here is my situation

1. I have two machines. Lets call them local & remote.
Both run ubuntu & both have python installed

2. I have a python script, local.py, running on local which needs to pass 
arguments ( 3/4 string arguments, containing whitespaces like spaces, etc ) to 
a python script, remote.py running on remote (the remote machine).

I have the following questions:

1. What's the best way to accomplish my task ?
I have researched quite a bit & so far found really conflicting & complex 
workarounds. 

I googled & found people using several libraries to accomplish ssh to remote 
machine & execute a command on remote machine.
paramiko ( now forked into the ssh moduke), fabric, pushy ,etc

People who have used any of these libraries, which one would you recommend, as 
the most apt (simple & easy to use, lightweight, best performance, etc) for my 
situation ?

2. I would prefer a solution, which does NOT require the installation of extra 
libraries on the local & remote machines.
If installing external librar

3. Has anybody been able to do this using os.system ?

I tried this
>>> import os
>>> os.system ("ssh remoteuser@remote python remote.py arg1 arg2 arg3")

This worked, but if the arguments i tried to pass, had spaces, i was not able 
to 'escape' the spaces.

Any & all explanations/links/code 
snippets/thoughts/ideas/suggestions/feedback/comments/ of the Python tutor 
community would be greatly appreciated.

Thanks a ton

cheers
ashish

email : 
ashish.makani
domain:gmail.com

“The only way to do great work is to love what you do. If you haven’t found it 
yet, keep looking. Don’t settle. As with all matters of the heart, you’ll know 
when you find it.” - Steve Jobs (1955 - 2011)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to send email programmatically from a gmail email a/c when port 587(smtp) is blocked

2012-09-19 Thread ashish
Folks,

I asked the same query on the python tutor mailing list.
The responses i received are here :
http://thread.gmane.org/gmane.comp.python.tutor/77601


Mark,

There is nothing wrong in asking a query on multiple forums.

Poeple on the tutor list, may not be part of comp.lang.python & subscribers to 
comp.lang.python

On Wednesday, September 12, 2012 4:18:05 AM UTC+5:30, Mark Lawrence wrote:
> On 11/09/2012 22:51, ashish makani wrote:
> 
> > Hi c.l.p peeps
> 
> >
> 
> > I am stuck with an issue, so am coming to the Pythonista deltaforce who 
> > rescue me everytime :)
> 
> >
> 
> 
> 
> [big snip]
> 
> 
> 
> I say old chap, it's simply not cricket to ask a question like this some 
> 
> 32 minutes after asking the same question on the tutor mailing list.
> 
> 
> 
> -- 
> 
> Cheers.
> 
> 
> 
> Mark Lawrence.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to send email programmatically from a gmail email a/c when port 587(smtp) is blocked

2012-09-11 Thread ashish makani
Hi c.l.p peeps

I am stuck with an issue, so am coming to the Pythonista deltaforce who rescue 
me everytime :)

I am trying to send out email programmatically, from a gmail a/c, using 
smtplib, using the following chunk of code (b/w [ & ] below)

[

import smtplib
from email.mime.text import MIMEText

#uname, pwd are username & password of gmail a/c i am trying to send from

server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls() # get response(220, '2.0.0 Ready to start TLS')
server.login(uname,pwd)  # get response(235, '2.7.0 Accepted')

toaddrs  = ['x...@gmail.com', 'y...@gmail.com' ] # list of To email addresses
msg = MIMEText('email body')
msg['Subject'] = 'email subject'
server.sendmail(fromaddr, toaddrs, msg.as_string())


]

The code above works perfectly fine on my local machine, but fails on the 
production server at the university where i work( all ports other than port 80 
are blocked) :(

So , when i try to run the 2 py statements (in bold below) on a python prompt 
from the production server, which has port 587 blocked, i get the following 
error

{
>>> import smtplib
>>> server = smtplib.SMTP('smtp.gmail.com:587')
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.6/smtplib.py", line 239, in __init__
(code, msg) = self.connect(host, port)
  File "/usr/lib/python2.6/smtplib.py", line 295, in connect
self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib/python2.6/smtplib.py", line 273, in _get_socket
return socket.create_connection((port, host), timeout)
  File "/usr/lib/python2.6/socket.py", line 514, in create_connection
raise error, msg
socket.error: [Errno 101] Network is unreachable

}


1. How can i overcome this ?
A friend suggested , that i could use something called smtp relay, which would 
solve my problem, but would be time-consuming & a pain to set up.
I did some cursory googling & searching on stackoverflow but could not find any 
good, well explained results. 
I dont know anything about SMTP.
Anybody has any recommendations on a good explanation on smtp relay & how to 
set it up for sending email from a gmail a/c using a python script ?

2. Also, is there a more elegant/cleaner/graceful solution to my problem than 
using an smtp relay ?

Any & all explanations/links/code 
snippets/thoughts/ideas/suggestions/feedback/comments/wisdom of the c.l.p 
community would be greatly appreciated.

Thanks a ton

cheers
ashish

email : 
ashish.makani
domain:gmail.com

p.s. some more context so people dont presume we are spammers :)

These emails are automated diagnostic emails sent to a group of a few of us 
admins, so we get notified when a python heartbeat script, detects a failure in 
things like n/w connectivity, router status, etc.
All of us dont use university email, we use gmail .


“The only way to do great work is to love what you do. If you haven’t found it 
yet, keep looking. Don’t settle. As with all matters of the heart, you’ll know 
when you find it.” - Steve Jobs (1955 - 2011)
-- 
http://mail.python.org/mailman/listinfo/python-list


How Python empowers Java?

2012-03-11 Thread Ashish Aggarwal
I am a Java developer but new to Python.
I am trying to assess, as what are new capabilities that Python will
provide me if I use it with Java.

Guys can you please help me?
-- 
http://mail.python.org/mailman/listinfo/python-list


No rule to make target `Parser/printgrammar.o'

2010-11-24 Thread ashish
I'm trying to compile Python from source and get the same error on
RedHat and Mac OS X. I did not pass any options to configure. The
error occurs immediately.

Redhat:~/Downloads/Python-2.7$ make
gcc -pthread -c -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -
Wall -Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE -
o Modules/python.o ./Modules/python.c
make: *** No rule to make target `Parser/printgrammar.o', needed by
`Parser/pgen'.  Stop.

MacOSX:Python-2.7$ make
gcc -c -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -
Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE -o
Modules/python.o ./Modules/python.c
make: *** No rule to make target `Parser/printgrammar.o', needed by
`Parser/pgen'.  Stop.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Performance evaluation of HTTPS library

2010-10-14 Thread Ashish
On Oct 13, 6:12 pm, Antoine Pitrou  wrote:
> On Wed, 13 Oct 2010 05:27:29 -0700 (PDT)Ashish  wrote:
>
> > Well, CBSocket is socket implementation that calls my callback on
> > data.
> > Both my classes AsyncHTTPSConnection and AsyncHTTPConnection use it
> > and use it the same way ( self.sock = CBSocket(sock2) ).
> > The implemetation of AsyncHTTPConnection differs from
> > AsyncHTTPSConnection only in connect method: sock2 =
> > ssl.wrap_socket(sock, self.key_file, self.cert_file)
>
> > class CBSocket(asynchat.async_chat):
>
> [...]
>
> Ok, this won't work as expected. The first issue is that
> ssl.wrap_socket() is a blocking operation, where your client will send
> data and wait for the server reply (it's the SSL's handshake),
> *before* the socket has been set in non-blocking mode by asyncore. It
> means that your client will remain idle a lot of time, and explains
> that neither the client nor the server reach 100% CPU utilization.
>
> The second issue is that combining SSL and asyncore is more complicated
> than that; there are various situations to consider which your code
> doesn't address. The stdlib right now doesn't provide SSL support for
> asyncore (seehttp://bugs.python.org/issue10084), so you would have to
> do it yourself. I don't think it's worth the trouble, and would
> recommend switching your client to a simple thread-based approach,
> where you handle each HTTP(S) connection in a separate thread and stick
> to blocking I/O.
>
> Regards
>
> Antoine.

I am impressed by the knowledge and also thankful to you for helping
me out.

I thought threads will be costly to use and if I go for say 200
parallel connections with 200 total threads (+ a few more I have in my
tool), it may not be efficient either. Let me try to change the
implementation to use threads + blocking i/o and get back with
results.

One more question: If I run the tool from multicore machine, will
python3.1 or 3.2 be able to actually use multicore? or it will be
running only on one core?

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


Re: Performance evaluation of HTTPS library

2010-10-13 Thread Ashish
On Oct 13, 3:19 pm, Antoine Pitrou  wrote:
> On Wed, 13 Oct 2010 02:12:21 -0700 (PDT)
>
> Ashish  wrote:
>
> > > > Is the client machine at 100% CPU when you do that?
>
> > > With HTTP, I see client CPU at appx. 97%. However with HTTPS, it stays
> > > at 53-55%.
>
> And is the server at 100% CPU then?
> If the client is not at 100% CPU, it shouldn't be the bottleneck,
> unless you have something wrong in the client implementation.
>
> > >             sock = socket.create_connection((self.host, self.port),
> > > self.timeout)
> > >             sock2 = ssl.wrap_socket(sock, self.key_file,
> > > self.cert_file)
> > >             self.sock = CBSocket(sock2)
>
> What is CBSocket? What happens if you just write:
>     self.sock = sock2
>

Server's java process is taking 15% cpu.

Well, CBSocket is socket implementation that calls my callback on
data.
Both my classes AsyncHTTPSConnection and AsyncHTTPConnection use it
and use it the same way ( self.sock = CBSocket(sock2) ).
The implemetation of AsyncHTTPConnection differs from
AsyncHTTPSConnection only in connect method: sock2 =
ssl.wrap_socket(sock, self.key_file, self.cert_file)

class CBSocket(asynchat.async_chat):
""" This is a class that calls the callback when it has data and
it read it."""
def __init__(self, socket):
asynchat.async_chat.__init__(self, socket)

self._in_buffer = io.BytesIO()
self._closed = False
self._cb = None

def handle_read(self):
try:
read = self.socket.recv(65536)
except:
read = 0
raise
if not read and not self._closed:
self.handle_close()
self.close()
self._closed = True
return

self._in_buffer.write(read)

def sendall(self, data):
self.send(data)

def makefile(self, mode, buffsize= 8192):
self._in_buffer.seek(0)
return self._in_buffer

def set_cb(self, cb):
self._cb = cb
if self._closed:
   self._cb()
else:
   pass


def handle_close(self):
if self._cb:
self._cb()
self._closed = True
self.close()
del self._in_buffer

> > > > Also, there's a feature request to reduce overhead of SSL
> > > > connections, but it needs implementing:http://bugs.python.org/issue8106
>
> > > Well good to know this. Do we have any date when this will be
> > > available? I feel like contributing to this but kind of over occupied
> > > with several activities right now.
>
> Probably not in Python 3.2 anyway. But given your client isn't at 100%
> CPU when you launch your HTTPS test, it might not make a lot of
> difference.
>
> Regards
>
> Antoine.

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


Re: Performance evaluation of HTTPS library

2010-10-13 Thread Ashish
On Oct 13, 2:36 pm, Stefan Behnel  wrote:
> Ashish Vyas, 12.10.2010 14:40:
>
> > When I send request using HTTP, I am able to reach 1 transaction (request 
> > sent,
> > response rcvd and validated.) per second from 20 parallel connections 
> > easily.
> > Average response time shown is about 0.15 seconds.
> > However, when I send request using HTTPS, I am seeing that the response time
> > shown by tool goes to 1.1 seconds for same 20 parallel connection each 
> > trying 1
> > transaction per second.
>
> You shouldn't overestimate the performance requirements for SSL/TLS support
> inside of the server application itself, simply because it's not used that
> much in real world deployments.
>
> It's actually very common to use a proxy to handle HTTPS traffic, and to
> forward the requests as plain HTTP to the "real" server. Separating the two
> gives you more freedom in your deployment (e.g. you can deploy the HTTPS
> proxy locally or on an entirely different machine at a suitable place in
> the network architecture), and makes your server generally more scalable.
> You can additionally use the HTTPS proxy machine to distribute the normal
> HTTP load over multiple server instances. There's even dedicated networking
> hardware for SSL/TLS proxying if you need it.
>
> Stefan

Yes, I absolutely agree to you that the server shall also have similar
overhead when HTTPS is used in place of HTTP. Thanks for suggesting
the HTTPS proxy box.

However, my problem here is:-

client on XEON machine sending req over HTTPS:average response
time ~= .2 secs
client on P4 machine sending req over  HTTP:  average response
time ~= .15 secs
client on P4 machine sending req over HTTPS:  average response
time ~= 1.1 secs

And I understand that until we have the feature implementation of
issue8106 as pointed out by Antoine, we may see no further improvement
on 1.1 secs (or .97 secs with 3.2a2) that I see.

Kindly confirm if my above conclusion is correct.

Thanks
Ashish.

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


Re: Performance evaluation of HTTPS library

2010-10-13 Thread Ashish
On Oct 13, 11:11 am, Ashish  wrote:
> On Oct 12, 6:33 pm, Antoine Pitrou  wrote:> On Tue, 12 
> Oct 2010 05:40:43 -0700 (PDT)
>
> > Ashish Vyas  wrote:
> > > Another observation that I have made is with 10 parallel HTTPS connection 
> > > each
> > > trying 1 transaction per second from 2 different machines (effectively 
> > > same load
> > > on server), the response time is again reducing to .17 secs.
> > > However if I run two instances of the tool with 10 parallel HTTPS 
> > > connection
> > > each trying 1 transaction per second from from same machine, the response 
> > > time
> > > is again shooting up to 1.1 seconds.
>
> > Is the client machine at 100% CPU when you do that?
>
> With HTTP, I see client CPU at appx. 97%. However with HTTPS, it stays
> at 53-55%.
>
> > > So the question is does anyone here have any idea or some data about 
> > > performance
> > > limitation of HTTPS implementation in Python 3.1?
>
> > Which API are you using? urlopen()?
> > The HTTPS implementation is basically the same as the HTTP
> > implementation, except for the additional SSL layer. So if indeed
> > Python is responsible for the slowdown, it may be because of excessive
> > overhead brought by the SSL layer.
>
> I am doing something like this:-
>
> self.conn = AsyncHTTPSConnection(self.URL, HTTPS_PORT)
>
> self.conn.putrequest('POST', WEBSERVER_IP)
> self.conn.putheader('Cookie', cookie)
> self.conn.putheader('Content-Length', reqLen)
> ..
> self.conn.endheaders()
> self.conn.send(str.encode(reqest))
>
> and AsyncHTTPSConnection class is something like this:-
>
> class AsyncHTTPSConnection(client.HTTPConnection):
>     default_port = HTTPS_PORT
>     def __init__(self, host, port=HTTPS_PORT, key_file=None,
> cert_file=None,
>                      strict=None,
> timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
>         """ Init has same eparameters as HTTPSConnection. """
>         client.HTTPConnection.__init__(self, host, port, strict,
> timeout)
>         self.key_file = key_file
>         self.cert_file = cert_file
>
>     def connect(self):
>         try:
>             log.mjLog.LogReporter ("Model", "info",
> "AsyncHTTPSConnection::connect trying to connect... "+ str(self.host)
> + ":"+ str(self.port))
>             sock = socket.create_connection((self.host, self.port),
> self.timeout)
>             sock2 = ssl.wrap_socket(sock, self.key_file,
> self.cert_file)
>             self.sock = CBSocket(sock2)
>         except:
>             log.mjLog.LogReporter ("Model", "critical",
> "AsyncHTTPSConnection::connect Failed to connect to the GWS")
>
> > It would be nice if you tried the just-released Python 3.2 alpha,
> > because some changes have been made to the SSL 
> > wrapper:http://python.org/download/releases/3.2/
>
> Let me try to use this, I will come back with my observations.

Well, I tried python3.2a2 and the average response time for 20 HTTPS
tps reduced from about 1.1 seconds to about .97 seconds.
This is a noticeable change but not enough I feel.
Also when I tried running same test client on XEON, I am able to see
average response time appx. 0.23 seconds.

>
> > Also, there's a feature request to reduce overhead of SSL
> > connections, but it needs implementing:http://bugs.python.org/issue8106
>
> Well good to know this. Do we have any date when this will be
> available? I feel like contributing to this but kind of over occupied
> with several activities right now.
>
>
>
> > Regards
>
> > Antoine.
>
> Thanks a lot,
> Ashish

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


Re: Performance evaluation of HTTPS library

2010-10-12 Thread Ashish
On Oct 12, 6:33 pm, Antoine Pitrou  wrote:
> On Tue, 12 Oct 2010 05:40:43 -0700 (PDT)
>
> Ashish Vyas  wrote:
> > Another observation that I have made is with 10 parallel HTTPS connection 
> > each
> > trying 1 transaction per second from 2 different machines (effectively same 
> > load
> > on server), the response time is again reducing to .17 secs.
> > However if I run two instances of the tool with 10 parallel HTTPS connection
> > each trying 1 transaction per second from from same machine, the response 
> > time
> > is again shooting up to 1.1 seconds.
>
> Is the client machine at 100% CPU when you do that?
>
With HTTP, I see client CPU at appx. 97%. However with HTTPS, it stays
at 53-55%.

> > So the question is does anyone here have any idea or some data about 
> > performance
> > limitation of HTTPS implementation in Python 3.1?
>
> Which API are you using? urlopen()?
> The HTTPS implementation is basically the same as the HTTP
> implementation, except for the additional SSL layer. So if indeed
> Python is responsible for the slowdown, it may be because of excessive
> overhead brought by the SSL layer.
>
I am doing something like this:-

self.conn = AsyncHTTPSConnection(self.URL, HTTPS_PORT)

self.conn.putrequest('POST', WEBSERVER_IP)
self.conn.putheader('Cookie', cookie)
self.conn.putheader('Content-Length', reqLen)
..
self.conn.endheaders()
self.conn.send(str.encode(reqest))


and AsyncHTTPSConnection class is something like this:-

class AsyncHTTPSConnection(client.HTTPConnection):
default_port = HTTPS_PORT
def __init__(self, host, port=HTTPS_PORT, key_file=None,
cert_file=None,
 strict=None,
timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
""" Init has same eparameters as HTTPSConnection. """
client.HTTPConnection.__init__(self, host, port, strict,
timeout)
self.key_file = key_file
self.cert_file = cert_file

def connect(self):
try:
log.mjLog.LogReporter ("Model", "info",
"AsyncHTTPSConnection::connect trying to connect... "+ str(self.host)
+ ":"+ str(self.port))
sock = socket.create_connection((self.host, self.port),
self.timeout)
sock2 = ssl.wrap_socket(sock, self.key_file,
self.cert_file)
self.sock = CBSocket(sock2)
except:
log.mjLog.LogReporter ("Model", "critical",
"AsyncHTTPSConnection::connect Failed to connect to the GWS")


> It would be nice if you tried the just-released Python 3.2 alpha,
> because some changes have been made to the SSL 
> wrapper:http://python.org/download/releases/3.2/
>
Let me try to use this, I will come back with my observations.

> Also, there's a feature request to reduce overhead of SSL
> connections, but it needs implementing:http://bugs.python.org/issue8106

Well good to know this. Do we have any date when this will be
available? I feel like contributing to this but kind of over occupied
with several activities right now.
>
> Regards
>
> Antoine.

Thanks a lot,
Ashish

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


Performance evaluation of HTTPS library

2010-10-12 Thread Ashish Vyas
Hi All

I have made a tool for load testing of my company's web-server product. The 
tool 
is written using Python 3.1.


The tool basically does a HTTP or HTTPS post, gets response and parses the 
response, does the response validation against expected response and maintains 
the stats of average response time.
The tool can open several such parallel connections and send different request 
and get different responses and validate them. This can continue till the time 
I 
specify or the number of request I specify in the tool per parallel connection.

I am seeing some strange behavior with this tool. 

When I send request using HTTP, I am able to reach 1 transaction (request sent, 
response rcvd and validated.) per second from 20 parallel connections easily. 
Average response time shown is about 0.15 seconds.
However, when I send request using HTTPS, I am seeing that the response time 
shown by tool goes to 1.1 seconds for same 20 parallel connection each trying 1 
transaction per second.

Another observation that I have made is with 10 parallel HTTPS connection each 
trying 1 transaction per second from 2 different machines (effectively same 
load 
on server), the response time is again reducing to .17 secs.
However if I run two instances of the tool with 10 parallel HTTPS connection 
each trying 1 transaction per second from from same machine, the response time 
is again shooting up to 1.1 seconds.

So I feel HTTPS is blocking my test if I want to achieve higher TPS 
(transactions per second.) than 10*1=10 TPS. [I can not send the next request 
till I get response to previous one and since response time is more than 1 
second, I can never reach 1 TPS from each connection.] If I use HTTP I can 
easily reach 20 TPS. Also if I use multiple machines, I can reach 20 TPS on 
HTTPS also.


So the question is does anyone here have any idea or some data about 
performance 
limitation of HTTPS implementation in Python 3.1?

Regards
Ashish Vyas



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


Python packet capture utility

2010-02-01 Thread VYAS ASHISH M-NTB837
 
Dear All

I want to capture tcp packets in python. I need to do this on both
Windows and Linux on python3.1

I came across the following:
http://sourceforge.net/projects/pycap/
http://sourceforge.net/projects/pylibpcap/
http://code.google.com/p/pypcap/
http://oss.coresecurity.com/projects/pcapy.html


I am not able to evaluate on my own. Which one should I pick up?
Priority is python3.1 support on both windows and Linux. I don't have to
do many/complex operations. If it is not so programmer friendly I am OK.

Also let me know if 2to3 would help here if there is not python3
support.

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


dtd validation on python 3.1 on Windows.

2010-01-08 Thread VYAS ASHISH M-NTB837
 
What is the best way to validate xmls against my dtd in python?
 
I dont see minodom doing this. 
 
Sax has dtd validation, but does not complain on dtd violations. (it
does access the dtd, if it does not find dtd it complains me.)
 
I am using python 3.1 on Win32 machine.
 
I was planning to try lxml2.2.4 but it shows DLL importerror. I posted
the problem on this forum a few days back, but there is no reply on
that.
 
Any help?!
 
Regards
Ashish
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: How to execute a script from another script and other script doesnotdo busy wait.

2010-01-07 Thread VYAS ASHISH M-NTB837
Did you try?

Thanks Ashish.

I've single CPU machine. I've a feeling that the thread created, which
would run script2, would eat up all of the CPU if I do not use sleep()
in script2.

That way, script1 would still be waiting for script2 to finish. Thus, my
program is no way different from the sample program I posted earlier.

Is there any other way out?
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: How to execute a script from another script and other script does notdo busy wait.

2010-01-07 Thread VYAS ASHISH M-NTB837
 
Use threads

Regards,
Ashish Vyas

-Original Message-
From: python-list-bounces+ntb837=motorola@python.org
[mailto:python-list-bounces+ntb837=motorola@python.org] On Behalf Of
Rajat
Sent: Thursday, January 07, 2010 2:42 PM
To: python-list@python.org
Subject: How to execute a script from another script and other script
does notdo busy wait.

I want to run a python script( aka script2) from another python script
(aka script1). While script1 executes script2 it waits for script2 to
complete and in doing so it also does some other useful work.(does not
do a busy wait).

My intention is to update a third party through script1 that script2 is
going to take longer.

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


RE: lxml 2.2.4 on python3.1, Windows XP gives importerror

2010-01-06 Thread VYAS ASHISH M-NTB837
Processor is Intel Pentium 32 bit. 

import platform
print (platform.architecture()) gives -> ('32bit', 'WindowsPE')


Regards,
Ashish Vyas
 

-Original Message-
From: Sridhar Ratnakumar [mailto:sridh...@activestate.com] 
Sent: Wednesday, January 06, 2010 10:15 PM
To: VYAS ASHISH M-NTB837
Cc: python-list@python.org
Subject: Re: lxml 2.2.4 on python3.1, Windows XP gives importerror

On 1/5/2010 1:38 AM, VYAS ASHISH M-NTB837 wrote:
> Dear All
> I have Python 3.1 installed on Windows XP and Works nice.
> I downloaded lxml 2.2.4 (lxml-2.2.4.win32-py3.1.exe) from pypi.
> When I try:
> from lxml import etree
> I get:
> ImportError: DLL load failed: This application has failed to start 
> because the application configuration is incorrect. Reinstalling the 
> application may fix this problem.

Are you by any chance running 64-bit Python (whereas the lxml binary you
have installed is 32-bit)?

C:> python -c "import platform; print platform.architecture()"

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


RE: Convert month name to month number faster

2010-01-06 Thread VYAS ASHISH M-NTB837
 
How about using list.index() and storing month names in a list? You may
want to measure performance your self and conclude.

Regards,
Ashish Vyas

-Original Message-
From: python-list-bounces+ntb837=motorola@python.org
[mailto:python-list-bounces+ntb837=motorola@python.org] On Behalf Of
wiso
Sent: Wednesday, January 06, 2010 4:34 PM
To: python-list@python.org
Subject: Convert month name to month number faster

I'm optimizing the inner most loop of my script. I need to convert month
name to month number. I'm using python 2.6 on linux x64.


month_dict = {"Jan":1,"Feb":2,"Mar":3,"Apr":4, "May":5, "Jun":6,
   "Jul":7,"Aug":8,"Sep":9,"Oct":10,"Nov":11,"Dec":12}

def to_dict(name):
  return month_dict[name]

def to_if(name):
if name == "Jan": return 1
elif name == "Feb": return 2
elif name == "Mar": return 3
elif name == "Apr": return 4
elif name == "May": return 5
elif name == "Jun": return 6
elif name == "Jul": return 7
elif name == "Aug": return 8
elif name == "Sep": return 9
elif name == "Oct": return 10
elif name == "Nov": return 11
elif name == "Dec": return 12
else: raise ValueError

import random
l = [random.choice(month_dict.keys()) for _ in range(100)]

from time import time
t = time(); xxx=map(to_dict,l); print time() - t # 0.5
t = time(); xxx=map(to_if,l); print time() - t   # 1.0


is there a faster solution? Maybe something with str.translate?

The problem is a little different because I don't read random data, but 
sorted data. For example:

l = [x for x in 
("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
) 
for _ in range(1000)] # ["Jan","Jan", ..., "Feb", "Feb", ...]

so maybe the to_if approach will be faster if I write the case in the
best 
order. Look:

l = ["Jan"] * 100 # to_if is in the best order for "Jan"
t = time(); xxx=map(to_dict,l); print time() - t # 0.5
t = time(); xxx=map(to_if,l); print time() - t # 0.5


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


RE: lxml 2.2.4 on python3.1, Windows XP gives importerror

2010-01-06 Thread VYAS ASHISH M-NTB837
Posting again as I did not get any response:

Dear All
 
I have Python 3.1 installed on Windows XP and Works nice.
I downloaded lxml 2.2.4 (lxml-2.2.4.win32-py3.1.exe) from pypi.
 
 
When I try:
from lxml import etree
I get:
ImportError: DLL load failed: This application has failed to start
because the application configuration is incorrect. Reinstalling the
application may fix this problem.
 
For information: 'import lxml' works fine.
 
After reinstalling python3.1 also the error message is the same. Any
help is appreciated!
 
 
Regards,
Ashish Vyas
 
-- 
http://mail.python.org/mailman/listinfo/python-list


lxml 2.2.4 on python3.1, Windows XP gives importerror

2010-01-05 Thread VYAS ASHISH M-NTB837
Dear All
 
I have Python 3.1 installed on Windows XP and Works nice.
I downloaded lxml 2.2.4 (lxml-2.2.4.win32-py3.1.exe) from pypi.
 
 
When I try:
from lxml import etree
I get:
ImportError: DLL load failed: This application has failed to start
because the application configuration is incorrect. Reinstalling the
application may fix this problem.
 
For information: 'import lxml' works fine.
 
After reinstalling python3.1 also the error message is the same. Any
help is appreciated!
 
 
Regards,
Ashish Vyas
 
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: How to run a repeating timer every n minutes?

2009-10-29 Thread VYAS ASHISH M-NTB837
 
Thanks a lot, this helps.

-Original Message-
From: python-list-bounces+ntb837=motorola@python.org
[mailto:python-list-bounces+ntb837=motorola@python.org] On Behalf Of
Frank Millman
Sent: Thursday, October 29, 2009 5:19 PM
To: python-list@python.org
Subject: Re: How to run a repeating timer every n minutes?

Ashish Vyas wrote:

> Dear All
>
> How do I write a code that gets executed 'every x' minutes?
>

[...]

> Regards,
> Ashish Vyas

Here is one way -

import threading

class Timer(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.event = threading.Event()

def run(self):
while not self.event.is_set():
 """ The things I want to do go here. """
 self.event.wait(number_of_seconds_to_wait)

def stop(self):
self.event.set()

In your main program -
  - to start the timer
  tmr = Timer()
  tmr.start()

  - to stop the timer
  tmr.stop()

It is easy to extend this by passing the number_of_seconds_to_wait, or a
function name to be executed, as arguments to the Timer.

Frank Millman



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


How to run a repeating timer every n minutes?

2009-10-29 Thread VYAS ASHISH M-NTB837
 
Dear All

How do I write a code that gets executed 'every x' minutes?



I know how to do it 'after x' minutes, I do the following:

def doAtTimerFire(): 
""" The things I want to do 'after x' minutes go here. """

And then from main code, I do this:

tmr = threading.Timer(timeInSeconds, doAtTimerFire)
tmr.start()


Sorry about the earlier post with wrong subject line.
Please help.

Regards,
Ashish Vyas
 
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Python 2.6 Global Variables

2009-10-29 Thread VYAS ASHISH M-NTB837
 
Dear all

How do I write a code that gets executed 'every x' minutes?



I know how to do it 'after x' minutes, I do the following:

def doAtTimerFire(): 
""" The things I want to do 'after x' minutes go here. """

And then from main code, I do this:

tmr = threading.Timer(timeInSeconds, doAtTimerFire)
tmr.start()



Please help.

Regards,
Ashish Vyas
 
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: AttributeError: 'SSLSocket' object has no attribute 'producer_fifo'

2009-10-22 Thread VYAS ASHISH M-NTB837
Tried using asyncore.dispatcher_with_send in place of
asynchat.async_chat and after a few request-responses, I get this:
 
Exception in thread Thread-2:
Traceback (most recent call last):
  File "C:\Python31\lib\threading.py", line 509, in _bootstrap_inner
self.run()
  File "C:\Python31\lib\threading.py", line 462, in run
self._target(*self._args, **self._kwargs)
  File "D:\XPress_v1.3\XPress\Model.py", line 3328, in run
asyncore.loop()
  File "C:\Python31\lib\asyncore.py", line 206, in loop
poll_fun(timeout, map)
  File "C:\Python31\lib\asyncore.py", line 124, in poll
is_w = obj.writable()
  File "C:\Python31\lib\asyncore.py", line 516, in writable
return (not self.connected) or len(self.out_buffer)
  File "C:\Python31\lib\asyncore.py", line 399, in __getattr__
return getattr(self.socket, attr)
AttributeError: 'SSLSocket' object has no attribute 'out_buffer'
 
Someone please throw some light on this!
 
Ashish



From: VYAS ASHISH M-NTB837 
Sent: Friday, October 23, 2009 11:35 AM
To: python-list@python.org
Subject: AttributeError: 'SSLSocket' object has no attribute
'producer_fifo'


I am getting the following error when I try to run my program to post
and receive xmls to an https server.
 
 
Traceback (most recent call last):
  File "C:\Python31\lib\threading.py", line 509, in _bootstrap_inner
self.run()
  File "C:\Python31\lib\threading.py", line 462, in run
self._target(*self._args, **self._kwargs)
  File "D:\XPress_v1.3\XPress\Model.py", line 3328, in run
asyncore.loop()
  File "C:\Python31\lib\asyncore.py", line 206, in loop
poll_fun(timeout, map)
  File "C:\Python31\lib\asyncore.py", line 124, in poll
is_w = obj.writable()
  File "C:\Python31\lib\asynchat.py", line 222, in writable
return self.producer_fifo or (not self.connected)
  File "C:\Python31\lib\asyncore.py", line 398, in __getattr__
return getattr(self.socket, attr)
AttributeError: 'SSLSocket' object has no attribute 'producer_fifo'

Does any one know what is wrong here?
 
Regards,
Ashish 
-- 
http://mail.python.org/mailman/listinfo/python-list


AttributeError: 'SSLSocket' object has no attribute 'producer_fifo'

2009-10-22 Thread VYAS ASHISH M-NTB837
I am getting the following error when I try to run my program to post
and receive xmls to an https server.
 
 
Traceback (most recent call last):
  File "C:\Python31\lib\threading.py", line 509, in _bootstrap_inner
self.run()
  File "C:\Python31\lib\threading.py", line 462, in run
self._target(*self._args, **self._kwargs)
  File "D:\XPress_v1.3\XPress\Model.py", line 3328, in run
asyncore.loop()
  File "C:\Python31\lib\asyncore.py", line 206, in loop
poll_fun(timeout, map)
  File "C:\Python31\lib\asyncore.py", line 124, in poll
is_w = obj.writable()
  File "C:\Python31\lib\asynchat.py", line 222, in writable
return self.producer_fifo or (not self.connected)
  File "C:\Python31\lib\asyncore.py", line 398, in __getattr__
return getattr(self.socket, attr)
AttributeError: 'SSLSocket' object has no attribute 'producer_fifo'

Does any one know what is wrong here?
 
Regards,
Ashish 
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Help with my program

2009-10-22 Thread VYAS ASHISH M-NTB837
 
So What is stopping you to do this? Make some methods getName,
getHeight... and call classObj.getName() etc from other class. 
 
Ashish



From: python-list-bounces+ntb837=motorola@python.org
[mailto:python-list-bounces+ntb837=motorola@python.org] On Behalf Of
tanner barnes
Sent: Friday, October 23, 2009 7:30 AM
To: python-h...@python.org; python-list@python.org; tu...@python.org
Subject: Help with my program


Ok so im in need of some help! I have a program with 2 classes and in
one 4 variables are created (their name, height, weight, and grade).
What im trying to make happen is to get the variables from the first
class and use them in the second class.




Windows 7: It helps you do more. Explore Windows 7.
<http://www.microsoft.com/Windows/windows-7/default.aspx?ocid=PID24727::
T:WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen3:102009>  
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: deepcopy of class inherited from Thread

2009-10-12 Thread VYAS ASHISH M-NTB837
 
The function that I want to run is part of a class, not a standalone
function. There are several class member variables also.

Regards,
Ashish Vyas
 

-Original Message-
From: python-list-bounces+ntb837=motorola@python.org
[mailto:python-list-bounces+ntb837=motorola@python.org] On Behalf Of
Mick Krippendorf
Sent: Monday, October 12, 2009 10:52 PM
To: python-list@python.org
Subject: Re: deepcopy of class inherited from Thread

VYAS ASHISH M-NTB837 schrieb:
> I have an object which has a run() method. But I can call it only
once.
> Calling the start() again will give
> 
> RuntimeError: thread already started
> 
> So what is the way to do this?
> 
> I thought of doing a deep copy of the object, as shallow copy will 
> also lead to the above error.
> I tried this:
> - deepcopy the object
> - call start() for the object you got from deepcopy
> - delete the object.
> 
> Is there a simpler way to achieve this?

Indeed, there is:

def threaded():
   """ do threaded stuff here """

Thread(target=threaded).start()
Thread(target=threaded).start()
Thread(target=threaded).start()
Thread(target=threaded).start()
Thread(target=threaded).start()


Now threaded() runs five times.

Python is not Java where one has to subclass from Thread (AFAIR the dark
ages where I used to speak Javanese).


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


RE: deepcopy of class inherited from Thread

2009-10-12 Thread VYAS ASHISH M-NTB837
Hi

I have an object which has a run() method. But I can call it only once.
Calling the start() again will give 

RuntimeError: thread already started

So what is the way to do this?

I thought of doing a deep copy of the object, as shallow copy will also
lead to the above error. 
I tried this:
- deepcopy the object
- call start() for the object you got from deepcopy
- delete the object.

Is there a simpler way to achieve this?


Regards,
Ashish Vyas
-Original Message-
From: Dave Angel [mailto:da...@ieee.org] 
Sent: Monday, October 12, 2009 7:14 PM
To: VYAS ASHISH M-NTB837
Cc: python-list@python.org
Subject: Re: deepcopy of class inherited from Thread

VYAS ASHISH M-NTB837 wrote:
> Dear All
>  
> I am running this piece of code:
>  
> from threading import Thread
> import copy
>  
> class Ashish(Thread):
> def __init__(self, i):
> Thread.__init__(self)
> self.foo = i
> def run(self):
> print (self, self.foo)
>  
>
> d= Ashish(4)
> e = copy.deepcopy(d)  <--- Exception here
>  
> d.start()
> e.start()
>  
> d.join()
> e.join()
>  
> But I am getting this error:
>  
>   
> Traceback (most recent call last):
>   File "D:\Profiles\ntb837\Desktop\threadprob.py", line 13, in

> e = copy.deepcopy(d)
>   File "C:\Python31\lib\copy.py", line 173, in deepcopy
> y = _reconstruct(x, rv, 1, memo)
>   File "C:\Python31\lib\copy.py", line 295, in _reconstruct
> state = deepcopy(state, memo)
>   File "C:\Python31\lib\copy.py", line 146, in deepcopy
> y = copier(x, memo)
>   File "C:\Python31\lib\copy.py", line 235, in _deepcopy_dict
> y[deepcopy(key, memo)] = deepcopy(value, memo)
>   File "C:\Python31\lib\copy.py", line 173, in deepcopy
> y = _reconstruct(x, rv, 1, memo)
>   File "C:\Python31\lib\copy.py", line 295, in _reconstruct
> state = deepcopy(state, memo)
>   File "C:\Python31\lib\copy.py", line 146, in deepcopy
> y = copier(x, memo)
>   File "C:\Python31\lib\copy.py", line 235, in _deepcopy_dict
> y[deepcopy(key, memo)] = deepcopy(value, memo)
>   File "C:\Python31\lib\copy.py", line 173, in deepcopy
> y = _reconstruct(x, rv, 1, memo)
>   File "C:\Python31\lib\copy.py", line 280, in _reconstruct
> y = callable(*args)
>   File "C:\Python31\lib\copyreg.py", line 88, in __newobj__
> return cls.__new__(cls, *args)
> TypeError: object.__new__(_thread.lock) is not safe, use
> _thread.lock.__new__()
>  
>  
> Could someone please help me find a solution?
>  
> Regards,
> Ashish Vyas
>  
>
>   
Is there some reason you need to copy such an object?  In general, you
can get into trouble doing deep copies of structures which involve OS
data, because not all such data can be safely copied.  Sometimes such
copies just quietly malfunction, but this time you were fortunate enough
to get a runtime error.

What is your use-case?  Perhaps there's some other approach that would
accomplish the real task.


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


deepcopy of class inherited from Thread

2009-10-12 Thread VYAS ASHISH M-NTB837
Dear All
 
I am running this piece of code:
 
from threading import Thread
import copy
 
class Ashish(Thread):
def __init__(self, i):
Thread.__init__(self)
self.foo = i
def run(self):
print (self, self.foo)
 

d= Ashish(4)
e = copy.deepcopy(d)  <--- Exception here
 
d.start()
e.start()
 
d.join()
e.join()
 
But I am getting this error:
 
>>> 
Traceback (most recent call last):
  File "D:\Profiles\ntb837\Desktop\threadprob.py", line 13, in 
e = copy.deepcopy(d)
  File "C:\Python31\lib\copy.py", line 173, in deepcopy
y = _reconstruct(x, rv, 1, memo)
  File "C:\Python31\lib\copy.py", line 295, in _reconstruct
state = deepcopy(state, memo)
  File "C:\Python31\lib\copy.py", line 146, in deepcopy
y = copier(x, memo)
  File "C:\Python31\lib\copy.py", line 235, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "C:\Python31\lib\copy.py", line 173, in deepcopy
y = _reconstruct(x, rv, 1, memo)
  File "C:\Python31\lib\copy.py", line 295, in _reconstruct
state = deepcopy(state, memo)
  File "C:\Python31\lib\copy.py", line 146, in deepcopy
y = copier(x, memo)
  File "C:\Python31\lib\copy.py", line 235, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "C:\Python31\lib\copy.py", line 173, in deepcopy
y = _reconstruct(x, rv, 1, memo)
  File "C:\Python31\lib\copy.py", line 280, in _reconstruct
y = callable(*args)
  File "C:\Python31\lib\copyreg.py", line 88, in __newobj__
return cls.__new__(cls, *args)
TypeError: object.__new__(_thread.lock) is not safe, use
_thread.lock.__new__()
 
 
Could someone please help me find a solution?
 
Regards,
Ashish Vyas
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: General: tutorial to all new python users

2009-05-22 Thread ashish
On May 22, 5:40 am, bvidinli  wrote:
> This is a good starting point i 
> think:http://pleac.sourceforge.net/pleac_python/index.html
>
> (Also a non-related subject:   for who want to do hosting freely on
> linux:www.ehcp.net(hosting control panel), also contains an
> experimental python backend)

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


python beginer

2008-04-16 Thread ashish kamble
hi,
can anyone tell me hw to start with webapplication scripting(e.g login
page..etc)
if anyone has soln for this or simple e.g  that mention above please send me

by


and have a nice day
-- 
http://mail.python.org/mailman/listinfo/python-list

hw to program on python

2008-04-15 Thread ashish
hi ,
python experts i want some help from u people just mail me how to
write scripts for web applications (like form coding for login page,
etc).


i m waiting for ur reply by
have a nice day!
-- 
http://mail.python.org/mailman/listinfo/python-list


Installing pcaplib

2008-01-03 Thread ashish
Hi All,

I am trying to install "pylibpcap-0.6.1" but i am getting these errors .


python ./setup.py install

.
.
.
.
.

constants.c:172: (near initialization for `pcapmodule_DLT[52]')
pcap.c: In function `init_pcap':
pcap.c:4246: structure has no member named `value'
pcap.c:4260: warning: passing arg 3 of `PyModule_AddStringConstant' 
discards qualifiers from pointer target type
error: command 'gcc' failed with exit status 1

Please tell me how to solve this problem.Do i have to install anything 
else before installing this library.

Thanks in Advance
Ashish


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


Re: why did MIT drop scheme for python in intro to computing?

2007-10-10 Thread Ashish Hanwadikar
"Grant Edwards" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On 2007-10-09, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>> Does scheme have a gui library?
>
> Yes.  It had a far, far better Tk binding than Python.
>
>  http://kaolin.unice.fr/STk/
>
> I've used both for real-world applications, and STk was _miles_
> ahead of tkinter.  It was a real, native binding to the Tk
> library rather than something stuck together with TCL.  GUI
> widgets were real Scheme objects that acted the way one
> expected them to, rather than wrapped TCL objects.
>
> However, Tk has been largely abandoned in favor of a native
> GTK+ binding
>
>  http://www.stklos.org/
>
> -- 
> Grant Edwards   grante Yow!  You should all 
> JUMP
>  at   UP AND DOWN for TWO 
> HOURS
>   visi.comwhile I decide on a NEW
>   CAREER!!
I couldn't find any documentation on stklos (other than a few examples) 
regarding its gtk+ binding. Could you please point me to appropriate link?
thanks in advance,
Ashish K Hanwadikar
http://ashish.typepad.com/ 

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


Python service gets interrupted function call

2007-10-10 Thread ashish
Hi All,
I wanted to know how to handle events like 'logoff' in the main thread
so that any process which is being run by svcDoRun method of service
does not get 'interrupted function call' exception.

I am posting a very simple service program , and i want to know that
is there a way to handle such interrupts without explicitly calling
try except block over blocking calls.

Here is the example which is getting interrupted exception at logoff.
===
import os, time, sys
import win32serviceutil, win32service
import pywintypes, win32con, winerror
# Use "import *" to keep this looking as much as a "normal" service
# as possible.  Real code shouldn't do this.
from win32event import *
from win32file import *
from win32pipe import *
from win32api import *
from ntsecuritycon import *

import servicemanager

import traceback
import thread, time

class TrialService(win32serviceutil.ServiceFramework):
_svc_name_ = "TrialService"
_svc_display_name_ = "TrialService"
_svc_description_ = "TrialService"
_exe_name_ = "C:/Python24/Lib/site-packages/win32/
pythonservice.exe"

def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
self.hWaitStop = CreateEvent(None, 0, 0, None)
self.overlapped = pywintypes.OVERLAPPED()
self.overlapped.hEvent = CreateEvent(None,0,0,None)

def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
SetEvent(self.hWaitStop)

def SvcDoRun(self):
time.sleep(1000)

def ctrl_handler(ctrl_type):
return True

if __name__ =='__main__':
SetConsoleCtrlHandler(ctrl_handler, True)
win32serviceutil.HandleCommandLine(TrialService)



In actual call i just want to call my app in place of time.sleep but
my app will have blocking code segments.
Any help will be greatly appreciated .
Thanks
Ashish

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


HTTPS request

2007-09-05 Thread ashish
Hi ,

I want to send HTTPs put request to the server .Can any one help me how 
to do that .

I am using this code

import httplib
from group import *

class HTTPS:


def __init__(self,ip,port=443):

self.ip=ip
self.port=port

self.conn = httplib.HTTPSConnection(str(self.ip))

def send_request(self,method,uri,data=None,headers=None):


self.conn.request(method,uri,data,headers)

 if __name__=="__main__"

http_obj=HTTPS('10.51.26.203')
headers={"Content-type": "application/auth-policy+xml","Accept": 
"text/plain"}
data="some xml doc"
http_obj.send_request('PUT',uri,data,headers=headers)


But it dumps core where ever i run this.Please tell me where i am going 
wrong.

Regards
Ashish

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


Xml parser

2007-05-25 Thread ashish
Hi All,

I want to know weather is there any api available in python for parsing 
xml(XML parser)

Regards
Ashish

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


GUI to python scripts

2007-05-22 Thread ashish
Hi All,

I need one help ,i started learning python few months back and i am 
comfortable with python now ,My intrest is, i want to genrate python 
scripts from GUI i.e. My GUI should be having macros or function of my 
intrest ,so if i select them it should generate corressponding python 
script for that.Can any one tell from where i will get such API or GUI 
application which will generate python scripts.

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