User Authentication

2011-06-22 Thread Anurag
Hi All,

I am working on application which needs to do a authentication against
LDAP, if LDAP not installed then local system account (administrator
user in windows and root user in Linux). This should work on both
Windows and Linux.

Which library I should use for that.

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


Re: User Authentication

2011-06-22 Thread Anurag
On Jun 22, 7:01 pm, Adam Tauno Williams 
wrote:
> On Wed, 2011-06-22 at 06:34 -0700, Anurag wrote:
> > Hi All,
>
> > I am working on application which needs to do a authentication against
> > LDAP, if LDAP not installed then local system account (administrator
> > user in windows and root user in Linux). This should work on both
> > Windows and Linux.
>
> See python-ldap

I looked into python-ldap, it supports ldap authentication. But I
didn't find anything that support local system account authentication
when no LDAP both in windows and Linux.

Ond more thing, somebody suggested me to use PAM. Is it a good choice
and whether it supports both Windows and Linux? Please let me know
which is best to use.

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


Re: User Authentication

2011-06-23 Thread Anurag
My application is a web based application for both windows and Linux.
The web part is developed using Django. So if Python does not support
it then any support for local sytem account authentication in Django?

I am looking for a common library for both Linux and Windows. Any help
will be Gr8

Regards,
Anurag

On Jun 23, 12:52 pm, Tim Golden  wrote:
> On 23/06/2011 06:02, Anurag wrote:
>
> > On Jun 22, 7:01 pm, Adam Tauno Williams
> > wrote:
> >> On Wed, 2011-06-22 at 06:34 -0700, Anurag wrote:
> >>> Hi All,
>
> >>> I am working on application which needs to do a authentication against
> >>> LDAP, if LDAP not installed then local system account (administrator
> >>> user in windows and root user in Linux). This should work on both
> >>> Windows and Linux.
>
> >> See python-ldap
>
> > I looked into python-ldap, it supports ldap authentication. But I
> > didn't find anything that support local system account authentication
> > when no LDAP both in windows and Linux.
>
> If you want local system authentication on Windows, you're going
> to need something like this:
>
> http://timgolden.me.uk/python/win32_how_do_i/check-a-users-credential...
>
> > Ond more thing, somebody suggested me to use PAM. Is it a good choice
> > and whether it supports both Windows and Linux? Please let me know
> > which is best to use.
>
> I can't speak for Linux, but I can guarantee that PAM won't
> take you anywhere on Windows :)
>
> TJG

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


Help with Python Multiprocessing

2014-11-13 Thread Anurag
I am having trouble understanding the Multiprocessing module.
I need to run three different files 'Worker1' , 'Worker2', 'Worker3' all at 
once. Currently I am doing this :

from multiprocessing import Process

import Worker1.py
import Worker2.py
import Worker3.py



p1 = Process(target=Worker1.py) 
p1.start()
p2 = Process(target=Worker2.py)
p2.start()
p3 = Process(target=Worker3.py)
p3.start()

But this will only start the 'Worker1'. How do I execute all the three files at 
once?

Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with Python Multiprocessing

2014-11-13 Thread Anurag
On Thursday, November 13, 2014 1:07:56 PM UTC-5, Anurag wrote:
> I am having trouble understanding the Multiprocessing module.
> I need to run three different files 'Worker1' , 'Worker2', 'Worker3' all at 
> once. Currently I am doing this :
> 
> from multiprocessing import Process
> 
> import Worker1.py
> import Worker2.py
> import Worker3.py
> 
> 
> 
> p1 = Process(target=Worker1.py) 
> p1.start()
> p2 = Process(target=Worker2.py)
> p2.start()
> p3 = Process(target=Worker3.py)
> p3.start()
> 
> But this will only start the 'Worker1'. How do I execute all the three files 
> at once?
> 
> Thanks

I am using Python 2.7 and each of my 'Worker' has a never ending loop that runs 
continuously.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with Python Multiprocessing

2014-11-13 Thread Anurag
On Thursday, November 13, 2014 2:22:29 PM UTC-5, Gary Herron wrote:
> On 11/13/2014 10:07 AM, Anurag wrote:
> > I am having trouble understanding the Multiprocessing module.
> > I need to run three different files 'Worker1' , 'Worker2', 'Worker3' all at 
> > once. Currently I am doing this :
> >
> > from multiprocessing import Process
> >
> > import Worker1.py
> > import Worker2.py
> > import Worker3.py
> >
> >
> >
> > p1 = Process(target=Worker1.py)
> > p1.start()
> > p2 = Process(target=Worker2.py)
> > p2.start()
> > p3 = Process(target=Worker3.py)
> > p3.start()
> >
> > But this will only start the 'Worker1'. How do I execute all the three 
> > files at once?
> >
> > Thanks
> 
> I doubt that is your actual code.  Python imports do not include .py 
> extension.  Please show us your actual code.  (Use cut and paste 
> please.)  And then take the time to tell us how you determine only the 
> first is started.  Then we can probably help.
> 
> As an aside: To be sure, one could make the above imports work by having 
> files named py.py and __init__.py in a directory named Worker1 (and the 
> same for directories Worker2 and Worker3).   I think it's more likely 
> that you miss-typed the above code.
> 
> Gary Herron

That is the actual code I am using in a file named 'ex.py'. 
My Worker files are also named with a '.py' extension.
When I run my 'ex.py' through a command prompt, the 'Worker1.py' is executed in 
the same command prompt and starts an infinite loop. It never gets to the 
'Worker2.py' part.
But I want my Workers to be executed in different command prompts.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with Python Multiprocessing

2014-11-13 Thread Anurag
On Thursday, November 13, 2014 2:18:50 PM UTC-5, [email protected] wrote:
> On Thursday, November 13, 2014 10:07:56 AM UTC-8, Anurag wrote:
> > I am having trouble understanding the Multiprocessing module.
> > I need to run three different files 'Worker1' , 'Worker2', 'Worker3' all at 
> > once. Currently I am doing this :
> > 
> > from multiprocessing import Process
> > 
> > import Worker1.py
> > import Worker2.py
> > import Worker3.py
> > 
> > 
> > 
> > p1 = Process(target=Worker1.py) 
> > p1.start()
> > p2 = Process(target=Worker2.py)
> > p2.start()
> > p3 = Process(target=Worker3.py)
> > p3.start()
> > 
> > But this will only start the 'Worker1'. How do I execute all the three 
> > files at once?
> > 
> > Thanks
> 
> Do your WorkerX.py files have a main() function or anything like that?  If 
> not, they should.  Then, you'd set the targets to WorkerX.main.

My Worker files have three different functions
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with Python Multiprocessing

2014-11-23 Thread Anurag
Hey Socha,
Your solution works. But then, all my 3 workers are running in a single command 
window. How do I make them run in three different command windows?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting rid of bitwise operators in Python 3?

2007-09-26 Thread Anurag
On Sep 22, 8:44 am, Carl Banks <[EMAIL PROTECTED]> wrote:
> Anyone with me here?  (I know the deadline for P3 PEPs has passed; this
> is just talk.)
>
> Not many people are bit-fiddling these days.  One of the main uses of bit
> fields is flags, but that's not often done in Python because of keyword
> arguments and dicts, which are lot more versatile.  Another major use,
> talking to hardware, is not something oft done in Python either.
>
Actually I think many people are not using many operators now
days..lets remove them all
e.g. I searched one of my downloder script and it doesn't have '+'
operator
lets remove it!

-Anurag

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


marshal bug?

2007-09-27 Thread Anurag
I have been chasing a problem in my code since hours and it bolis down
to this
import marshal
marshal.dumps(str(123)) != marshal.dumps(str("123"))

Can someone please tell me why?
when
str(123) == str("123")

or are they different?

it also means that
if s = str(123)
marshal.dumps(s) != marshal.dumps(marshal.loads(marshal.dumps(s)))

rgds
Anurag

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


Re: marshal bug?

2007-09-28 Thread Anurag
Thanks for the reply.

It seems problem is due to
"""
Any string in Python can be "interned" or not, the difference being
how/where the value is stored internally.  The marshal module includes
such information in its output.  What you are doing is probably
considered a misuse of the marshal module.  I'd suggest using the
pickle
(or cPickle) modules instead.
"""
as mentioned by Gary Herron

Now is there a easy way to by pass it (hack around it)
I tried various options but all fail e.g.
i= 123; marshal.dumps("%d"%123) != marshal.dumps("%d"%i)

So maybe I have to change all my code to use pickle, which also
consumes for memory per string.


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


tarfile...bug?

2007-10-09 Thread Anurag
Hi,

I am trying to use tarfile module to list contents of a 'gz' file but
it seems to hang for large files and CPU usage goes 100%.
though 'tar -tvf' on same file list contents in couple of secs.

Here is a test script which can show the problem; I am using python
Python 2.4.3


import tarfile

bigFilePath = "/tmp/bigFile"
bigFileTGZ = "/tmp/big.tar.gz"

# create a big file
print "Creating big file...",bigFilePath
f = open(bigFilePath,"w")
for i in xrange(100):
f.write("anurag"*1024*1024)
f.close()

#create a tarfile from big file
print "pack to...",bigFileTGZ
tar = tarfile.open(bigFileTGZ, "w:gz")
tar.add(bigFilePath,"bigFile")
tar.close()

print "unpack...",bigFileTGZ
# now try to list contents of tar
tar  = tarfile.open(bigFileTGZ, "r")
tar.list() #hangs


rgds
Anurag

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


Re: tarfile...bug?

2007-10-09 Thread Anurag
Hi,

Have any one faced such problem, I assume it must be common if it can
be replicated so easily , or something wrong with my system

Also if I use tar.members instead of tar.getmembers() it works
so what is the diff. between tar.members and tar.getmembers()

rgds
Anurag

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


Re: Iteration for Factorials

2007-10-30 Thread Anurag
What about this no map, reduce, mutiplication or even addition
Its truly interative and You will need to interate till infinity if
you want correct answer ;)

def factorial(N):
"""
Increase I ...and go on increasing...
"""
import random

myNumer = range(N)
count = 0
I = 1 #10**(N+1)
for i in range(I):
bucket = range(N)
number = []
for i in range(N):
k = bucket[ random.randrange(0,len(bucket))]
bucket.remove(k)
number.append(k)

if number == myNumer:
count+=1

return int(I*1.0/count+.5)

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


Re: MySQL with Python

2012-10-15 Thread Anurag Chourasia
Yes you can. There are libraries available in python to make this happen.

Read this for a starter

http://dev.mysql.com/usingmysql/python/

Regards,
Anurag
On Oct 15, 2012 10:53 AM, "রুদ্র ব্যাণার্জী"  wrote:

> Dear friends,
> I am starting a project of creating a database using mySQL(my first
> project with database).
> I went to my institute library and find that, all books are managing
> "mySQL with perl and php"
>
> I am new to python itself and gradually loving it. I mostly use it as an
> alternative of shell-script. Since learning a new language for every new
> project is not possible(its self assigned project, generally in free
> time), can I do a "mySQL with python?"
>
> if yes, can you kindly suggest a book/reference on this?
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MySQL with Python

2012-10-15 Thread Anurag Chourasia
Don't worry about what book you have (or don't have) in your
Library..And let this not dictate your technology stack.

PostgreSQL is one of the popular choice and you will never be short of
documentation...Just Google and you will find lot of helpful tutorials...

Regards,
Anurag

On Mon, Oct 15, 2012 at 10:47 AM, রুদ্র ব্যাণার্জী wrote:

> On Tue, 2012-10-16 at 01:01 +1100, Chris Angelico wrote:
> > But you may wish to consider using PostgreSQL instead.
> Thanks, as I am  very much new in database thing, I am not very aware of
> the options I have.
> But in my library, I did not found any thing on PostgreSQL.
> Though, I will google its support as well, can you kindly let me know if
> this is well documented. I can see there mailing list is quite active.
> So that may not be a problem though.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to build an application in Django which will handle Multiple servers accross network

2011-05-02 Thread Anurag Agarwal
Hi All,

Thanks for the resposes.

I think I was not able to communicate my problem very well.

Here I am not managing any network devices, what i am doing is getting
some info from various servers on netowrk. I don't know how to explain
what kind of info is needed, but for the time if you just assume that
a driver for windows and linux is already written which has command
line interface too which gets certain info about server. Now the
information returned by this driver software from each server is to be
shown at a common place. For this I am planning a web based
application that can connect to each individual server and get the
info and show it on UI.

For this to happen i need some interface to which my web based
application (to be developed in Django and Python) can connect to each
server in network and call the driver methods on that server to get
the info.

I hope now i am clear with my thoughts. Please mail me back if still I
am not clear.

The solutions I got
1. Using WMI on windows but how it will work on Linux?.
2. Pyro which supports remote objects.
3. Open NMS - it is a java based open source project, we don't have
any expertise in java... I want something that can be integrated with
python and django.
4. ZenOSS - It is for managing some IP based devices on network.. I
don't know how it will help me.


Please give me some ideas on python even it needs some development
effort.

Regards,
Anurag



On Apr 29, 5:21 pm, Adam Tauno Williams 
wrote:
> On Fri, 2011-04-29 at 13:24 +0200, Paul Kölle wrote:
> > Am 29.04.2011 12:01, schrieb Adam Tauno Williams:
> > >> 3. The web based application will be used internally in the network to
> > >> moniter servers in that network only.
> > > You mean like OpenNMS or ZenOSS?
> > >> 4. Web based application will be a real time application with a
> > >> Database.
> > > Like OpenNMS or ZenOSS?
> > How can they be realtime if they generate static images?
>
> All images are static regardless of how much they pretend not to be.
> You can refresh as much as you like.  But a graph shows a progression
> over time so there is always an interval.
>
> > >> 5. Technology I am thingking for web based application is Django and
> > >> Python as this web application can also be installed on Windows or
> > >> Linux based OS.
> > > If you want real-time monitoring you *must* build a service; a 'web app'
> > > can *not* do that.
> > Do you mean an agent?
>
> No, just use WMI over the wire.  Agents are terrible, hard to develop,
> unreliable, and everyone hates agents.  The systems already provide you
> access to the information you are talking about.
>
> > >> 6. Also please suggest which third party tool for chatrs and graphs I
> > >> should use with Django (open source + paid)
> > > ZenOSS and OpenNMS do graphs using RRD.
> > I know this is the "standard" but IMO it's totally backward these days.
> > Correlating or selecting/deselecting certain values is painful
> >(you have to write a graph def)
>
> How is it painful?  Of course you have to create a graph definition - in
> your case you are creating a graph definition BY WRITING CODE!  There
> couldn't be a more painful way to just create a graph.
>
> Have you used recent versions of ZenOSS?  Graph definitions can be
> created right in the UI.
>
> > . With  and modern JS libs like raphael
> > there are better ways to do this. Just look at google analytics.
>
> I've seen it.  I don't see how it is "better".  It's a graph.
>
> > It looks like PCP (http://oss.sgi.com/projects/pcp/features.html) will
> > gain a JSON interface shortly. That would be awesome because PCP is
> > developed by real engineers and has a proper architecture and is NOT a
> > CPU sucking monstrosity of PERL-line-noise + a few hacked-together PHP
> > frontends.
>
> I have no idea where the "PERL-line-noise + a few hacked-together PHP
> frontend" comment comes from.  RRD is written in C.  OpenNMS is Java and
> ZenOSS is Python/ZOPE.
>
> And as for "CPU sucking monstrosity" that is what everyone says... until
> they try to build a monitoring application... and thus create their own
> "CPU sucking monstrosity".  This is a case of
> those-who-refuse-to-use-are-doomed-to-reinvent.

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


Re: Parsing Python dictionary with multiple objects

2014-11-03 Thread Anurag Patibandla
json_split = {}
value = {"Status": "Submitted", "m_Controller": "Python"}
a = range(31)
del a[0]
for i in a:
json_split[i] = value
keys = json_split.keys()
order = list(keys)
q1 = int(round(len(keys)*0.2))
q2 = int(round(len(keys)*0.3))
q3 = int(round(len(keys)*0.5))
b = [q1,q2,q3]
n=0
threedicts = []
for i in b:
queues = order[n:n+i]
n = n+i
lists = [(queues[j], json_split.get(queues[j])) for j in range(len(queues))]
onedict = {}
for q in queues:
onedict[q] = json_split[q]
threedicts.append (onedict)
queue1, queue2, queue3 = threedicts
keys1 = queue1.keys()
for i in keys1:
queue1[i]['Priority'] = ['1']
keys2 = queue2.keys()
for j in keys2:
queue2[j]['Priority'] = ['2']
keys3 = queue3.keys()
for z in keys3:
queue3[z]['Priority'] = ['3']

I am trying to add a key value pair of ("Priority":"1") to queue1, 
("Priority":"2") to queue2, and ("Priority":"3") to queue3.
When I just add ("Priority":"1") to queue1, it works.
But when I run the above code, ("Priority":"3") is being added to all the 
queues.
This looks trivial and I don't understand why this is happening. Is there 
something wrong with what I am doing?
-- 
https://mail.python.org/mailman/listinfo/python-list


Problem adding a Key Value pair

2014-11-04 Thread Anurag Patibandla

I am trying to add a key value pair of ("Priority":"1") to queue1, 
("Priority":"2") to queue2, and ("Priority":"3") to queue3. 
When I just add ("Priority":"1") to queue1, it works. 
But when I run the above code, ("Priority":"3") is being added to all the 
queues. 
This looks trivial and I don't understand why this is happening. Is there 
something wrong with what I am doing?

json_split = {} 
value = {"Status": "Submitted", "m_Controller": "Python"} 
a = range(31) 
del a[0] 
for i in a: 
json_split[i] = value 
keys = json_split.keys() 
order = list(keys) 
q1 = int(round(len(keys)*0.2)) 
q2 = int(round(len(keys)*0.3)) 
q3 = int(round(len(keys)*0.5)) 
b = [q1,q2,q3] 
n=0 
threedicts = [] 
for i in b: 
queues = order[n:n+i] 
n = n+i 
lists = [(queues[j], json_split.get(queues[j])) for j in 
range(len(queues))] 
onedict = {} 
for q in queues: 
onedict[q] = json_split[q] 
threedicts.append (onedict) 
queue1, queue2, queue3 = threedicts 
keys1 = queue1.keys() 
for i in keys1: 
queue1[i]['Priority'] = ['1'] 
keys2 = queue2.keys() 
for j in keys2: 
queue2[j]['Priority'] = ['2'] 
keys3 = queue3.keys() 
for z in keys3: 
queue3[z]['Priority'] = ['3'] 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem adding a Key Value pair

2014-11-04 Thread Anurag Patibandla
On Tuesday, November 4, 2014 2:37:49 PM UTC-5, Anurag Patibandla wrote:
> I am trying to add a key value pair of ("Priority":"1") to queue1, 
> ("Priority":"2") to queue2, and ("Priority":"3") to queue3. 
> When I just add ("Priority":"1") to queue1, it works. 
> But when I run the above code, ("Priority":"3") is being added to all the 
> queues. 
> This looks trivial and I don't understand why this is happening. Is there 
> something wrong with what I am doing?
> 
> json_split = {} 
> value = {"Status": "Submitted", "m_Controller": "Python"} 
> a = range(31) 
> del a[0] 
> for i in a: 
> json_split[i] = value 
> keys = json_split.keys() 
> order = list(keys) 
> q1 = int(round(len(keys)*0.2)) 
> q2 = int(round(len(keys)*0.3)) 
> q3 = int(round(len(keys)*0.5)) 
> b = [q1,q2,q3] 
> n=0 
> threedicts = [] 
> for i in b: 
> queues = order[n:n+i] 
> n = n+i 
> lists = [(queues[j], json_split.get(queues[j])) for j in 
> range(len(queues))] 
> onedict = {} 
> for q in queues: 
> onedict[q] = json_split[q] 
> threedicts.append (onedict) 
> queue1, queue2, queue3 = threedicts 
> keys1 = queue1.keys() 
> for i in keys1: 
> queue1[i]['Priority'] = ['1'] 
> keys2 = queue2.keys() 
> for j in keys2: 
> queue2[j]['Priority'] = ['2'] 
> keys3 = queue3.keys() 
> for z in keys3: 
> queue3[z]['Priority'] = ['3']

Awesome! Thank you!!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing Python dictionary with multiple objects

2014-10-14 Thread Anurag Patibandla
On Tuesday, October 14, 2014 12:59:27 PM UTC-4, Dave Angel wrote:
> [email protected] Wrote in message:
> 
> > I have a dictionary that looks like this:
> 
> > {"1":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
> 
> > "2":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
> 
> > "3":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
> 
> > "4":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}}
> 
> > 
> 
> > Now if I have 100 objects like these and I need to split them into 3 
> > smaller dicts in a ratio 2:3:5, how could I do that?
> 
> 
> 
> I really have no idea what that means.  You have 100 dicts of
> 
>  dicts? Are the keys unique? If so, you could combine them with a
> 
>  loop of update.
> 
> 
> 
> > I tried using numpy.random.choice(), but it says it needs to be a 1-d array.
> 
> > 
> 
> 
> 
> How about random.choice?  It needs a sequence.
> 
> 
> 
> To get anything more concrete, you need to specify Python version,
> 
>   and make a clearer problem statement,  perhaps with example of
> 
>  what you expect.
> 
> 
> 
> 
> 
> -- 
> 
> DaveA

Hey DaveA,
I am using Python 2.7.
Yes. I have a dict of dicts with keys ranging from 1..100
And the value of each of these keys is another dict. What I need to do is make 
3 smaller dicts and assign the values of keys 1..100 in the ratio 2:3:5.
For example, if my original dict is 

d={"1":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
   "2":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
   "3":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
   "4":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}}
   ...
   ...
  "100":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}

I need to have three dicts d1, d2, d3 with d1 containing the values of first 20 
keys, d2 containing the values on next 30 keys and d3 containing the values of 
the next 50.
Can you please help me with this?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing Python dictionary with multiple objects

2014-10-14 Thread Anurag Patibandla
On Tuesday, October 14, 2014 5:33:01 PM UTC-4, Skip Montanaro wrote:
> Shuffle the keys, then grab the first 20 for one dictionary, the next 30 for 
> the second, and the last 50 for the third.
> 
> Skip

Could you please be more specific?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing Python dictionary with multiple objects

2014-10-14 Thread Anurag Patibandla
Thanks for the response.
Here is the code that I have tried.

from operator import itemgetter
keys = json.keys()
order = list(keys)
q1 = int(round(len(keys)*0.2))
q2 = int(round(len(keys)*0.3))
q3 = int(round(len(keys)*0.5))
b = [q1,q2,q3]
n=0
for i in b:
queues = order[n:n+i]

n = n+i
print queues

for j in range(len(queues)):
q = (queues[j], json.get(queues[j]))
print q

By this I am able to get the 3 smaller dicts I want, but can you help me assign 
them to 3 variables?
The dicts need not be ordered but it would be better if they are ordered.

Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing Python dictionary with multiple objects

2014-10-14 Thread Anurag Patibandla
'json' has my original larger dict
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Anurag Patibandla
Thanks Rustom for the advice.
I am new to Python and getting struck at some basic things. How do I assign the 
values that I am printing to 3 variables say dict1, dict2, dict3?
When I try to assign them before the print statement like this:
d1, d2, d3 =[(queues[j], json.get(queues[j])) for j in range(len(queues))]

I get an error saying 'need more than one value to unpack'
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Anurag Patibandla
First the values printed by
'[(queues[j], json.get(queues[j])) for j in range(len(queues))] '
is a list, so I tried to convert it into a dict using dict().
And then I tried doing dict[0] but there is an error which says:
'type' object has no attribute '__getitem__'

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


Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Anurag Patibandla
keys = json.keys()
order = list(keys)
q1 = int(round(len(keys)*0.2))
q2 = int(round(len(keys)*0.3))
q3 = int(round(len(keys)*0.5))
b = [q1,q2,q3]
n=0
for i in b:
queues = order[n:n+i]

n = n+i
#print queues
#print [(queues[j], json.get(queues[j])) for j in range(len(queues))] 
lists = [(queues[j], json.get(queues[j])) for j in range(len(queues))] 
#print lists
dicts = dict(lists)
print dicts
print dict[0]

Print dicts works as expected giving me the combine dictionary values. But when 
I say dict[0]. I see the error:
TypeError: 'type' object has no attribute '__getitem__'
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Anurag Patibandla
keys = json.keys()
order = list(keys)
q1 = int(round(len(keys)*0.2))
q2 = int(round(len(keys)*0.3))
q3 = int(round(len(keys)*0.5))
b = [q1,q2,q3]
n=0
for i in b:
queues = order[n:n+i]

n = n+i
lists = [(queues[j], json.get(queues[j])) for j in range(len(queues))] 

dicts = dict(lists)
print dicts
print dict[0]

print dicts works as expected. It gives me the entire dictionary. But when I do 
dicts[0], there is the following error:
'type' object has no attribute '__getitem__'
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Anurag Patibandla
On Wednesday, October 15, 2014 1:10:41 PM UTC-4, Rustom Mody wrote:
> On Wednesday, October 15, 2014 10:30:49 PM UTC+5:30, Anurag Patibandla wrote:
> 
> > keys = json.keys()
> 
> > order = list(keys)
> 
> > q1 = int(round(len(keys)*0.2))
> 
> > q2 = int(round(len(keys)*0.3))
> 
> > q3 = int(round(len(keys)*0.5))
> 
> > b = [q1,q2,q3]
> 
> > n=0
> 
> > for i in b:
> 
> > queues = order[n:n+i]
> 
> 
> 
> > n = n+i
> 
> > lists = [(queues[j], json.get(queues[j])) for j in range(len(queues))] 
> 
> 
> 
> > dicts = dict(lists)
> 
> > print dicts
> 
> > print dict[0]
> 
> 
> 
> 
> 
> > print dicts works as expected. It gives me the entire dictionary. But when 
> > I do dicts[0], there is the following error:
> 
> > 'type' object has no attribute '__getitem__'
> 
> 
> 
> Do you want dict[0] ??
> 
> I think you want dicts[0]

Sorry about that. 
dicts[0] gives me a KeyError: 0
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Anurag Patibandla
Here is my sample dict if that helps:

json = {"1": {"Status": "Submitted", "Startdate": ["01/01/2011"], "Enddate": 
["02/02/2012"], "Job_ID": 1, "m_Quantile": "80", "m_Controller": "Python", 
"m_Method": "Distributed", "Allocation_3": ["50"], "Allocation_2": ["30"], 
"Allocation_1": ["20"], "Note": "", "m_Iterations": "1000", "submit": 
["Submit"], "VaR": "", "Asset_2": ["YHOO"], "Asset_3": ["CAT"], "Asset_1": 
["AAPL"]}, "3": {"Status": "Submitted", "Startdate": ["01/01/2011"], "Enddate": 
["02/02/2012"], "Job_ID": 3, "m_Quantile": "90", "m_Controller": "Python", 
"m_Method": "Distributed", "Allocation_3": ["50"], "Allocation_2": ["30"], 
"Allocation_1": ["20"], "Note": "", "m_Iterations": "1000", "submit": 
["Submit"], "VaR": "", "Asset_2": ["YHOO"], "Asset_3": ["CAT"], "Asset_1": 
["AAPL"]}, "2": {"Status": "Submitted", "Startdate": ["01/01/2011"], "Enddate": 
["02/02/2012"], "Job_ID": 2, "m_Quantile": "80", "m_Controller": "Python", 
"m_Method": "GARCH", "Allocation_3": ["50"], "Allocation_2": ["30"], 
"Allocation_1": ["20"], "No
 te": "", "m_Iterations": "1000", "submit": ["Submit"], "VaR": "", "Asset_2": 
["YHOO"], "Asset_3": ["CAT"], "Asset_1": ["AAPL"]}, "4": {"Status": 
"Submitted", "Startdate": ["01/01/2011"], "Enddate": ["02/02/2012"], "Job_ID": 
4, "m_Quantile": "90", "m_Controller": "Python", "m_Method": "GARCH", 
"Allocation_3": ["50"], "Allocation_2": ["30"], "Allocation_1": ["20"], "Note": 
"", "m_Iterations": "1000", "submit": ["Submit"], "VaR": "", "Asset_2": 
["YHOO"], "Asset_3": ["CAT"], "Asset_1": ["AAPL"]}}
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Anurag Patibandla
On Wednesday, October 15, 2014 1:35:43 PM UTC-4, Rustom Mody wrote:
> On Wednesday, October 15, 2014 10:51:11 PM UTC+5:30, Anurag Patibandla wrote:
> 
> > Here is my sample dict if that helps:
> 
> > 
> 
> > 
> 
> > 
> 
> > json = {"1": {"Status": "Submitted", "Startdate": ["01/01/2011"], 
> > "Enddate": ["02/02/2012"], "Job_ID": 1, "m_Quantile": "80", "m_Controller": 
> > "Python", "m_Method": "Distributed", "Allocation_3": ["50"], 
> > "Allocation_2": ["30"], "Allocation_1": ["20"], "Note": "", "m_Iterations": 
> > "1000", "submit": ["Submit"], "VaR": "", "Asset_2": ["YHOO"], "Asset_3": 
> > ["CAT"], "Asset_1": ["AAPL"]}, "3": {"Status": "Submitted", "Startdate": 
> > ["01/01/2011"], "Enddate": ["02/02/2012"], "Job_ID": 3, "m_Quantile": "90", 
> > "m_Controller": "Python", "m_Method": "Distributed", "Allocation_3": 
> > ["50"], "Allocation_2": ["30"], "Allocation_1": ["20"], "Note": "", 
> > "m_Iterations": "1000", "submit": ["Submit"], "VaR": "", "Asset_2": 
> > ["YHOO"], "Asset_3": ["CAT"], "Asset_1": ["AAPL"]}, "2": {"Status": 
> > "Submitted", "Startdate": ["01/01/2011"], "Enddate": ["02/02/2012"], 
> > "Job_ID": 2, "m_Quantile": "80", "m_Controller": "Python", "m_Method": 
> > "GARCH", "Allocation_3": ["50"], "Allocation_2": ["30"], "Allocation_1": 
> > ["20"],
  "Note": "", "m_Iterations": "1000", "submit": ["Submit"], "VaR": "", 
"Asset_2": ["YHOO"], "Asset_3": ["CAT"], "Asset_1": ["AAPL"]}, "4": {"Status": 
"Submitted", "Startdate": ["01/01/2011"], "Enddate": ["02/02/2012"], "Job_ID": 
4, "m_Quantile": "90", "m_Controller": "Python", "m_Method": "GARCH", 
"Allocation_3": ["50"], "Allocation_2": ["30"], "Allocation_1": ["20"], "Note": 
"", "m_Iterations": "1000", "submit": ["Submit"], "VaR": "", "Asset_2": 
["YHOO"], "Asset_3": ["CAT"], "Asset_1": ["AAPL"]}}
> 
> 
> 
> Right
> 
> So your dict (which is dicts !) we have
> 
> >>> json.keys()
> 
> ['1', '3', '2', '4']
> 
> 
> 
> And so
> 
> 
> 
> >>> json[0]
> 
> Traceback (most recent call last):
> 
>   File "", line 1, in 
> 
> KeyError: 0
> 
> 
> 
> >>> json['0']
> 
> Traceback (most recent call last):
> 
>   File "", line 1, in 
> 
> KeyError: '0'
> 
> 
> 
> >>> json['1']
> 
> {'Status': 'Submitted', 'Startdate': ['01/01/2011'], 'Enddate': 
> ['02/02/2012'], 'Job_ID': 1, 'm_Quantile': '80', 'Allocation_3': ['50'], 
> 'm_Method': 'Distributed', 'm_Controller': 'Python', 'Allocation_2': ['30'], 
> 'Allocation_1': ['20'], 'Asset_2': ['YHOO'], 'Note': '', 'VaR': '', 'submit': 
> ['Submit'], 'm_Iterations': '1000', 'Asset_3': ['CAT'], 'Asset_1': ['AAPL']}
> 
> 
> 
> IOW 0 is not a key 
> 
> Neither is '0' (the string containing the char 0)
> 
> But the string '1' is a valid key

Yes, but I can't just do 'json['1']', at the end of the code I need to do a 
'dicts['1']', or 'dicts['2']', to get the smaller dicts which still gives me a 
'KeyError: 1'
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Anurag Patibandla
On Wednesday, October 15, 2014 1:41:13 PM UTC-4, Dave Angel wrote:
> Anurag Patibandla  Wrote in message:
> 
> > Thanks for the response.
> 
> > Here is the code that I have tried.
> 
> > 
> 
> > from operator import itemgetter
> 
> > keys = json.keys()
> 
> > order = list(keys)
> 
> > q1 = int(round(len(keys)*0.2))
> 
> > q2 = int(round(len(keys)*0.3))
> 
> > q3 = int(round(len(keys)*0.5))
> 
> > b = [q1,q2,q3]
> 
> > n=0
> 
> 
> 
> threedicts = []
> 
> 
> 
> > for i in b:
> 
> > queues = order[n:n+i]
> 
> > 
> 
> > n = n+i
> 
> > print queues
> 
> > 
> 
> > for j in range(len(queues)):
> 
> > q = (queues[j], json.get(queues[j]))
> 
> > print q
> 
> > 
> 
> 
> 
>onedict = {}
> 
>for q in queues:
> 
>onedict[q] = json[q]
> 
>threedicts.append (onedict)
> 
>dict1, dictw, dict3 = threedicts 
> 
>
> 
> > By this I am able to get the 3 smaller dicts I want, but can you help me 
> > assign them to 3 variables?
> 
> > The dicts need not be ordered but it would be better if they are ordered.
> 
> > 
> 
> 
> 
> dicts are not ordered. If you want the items in a particular
> 
>  order, you have to do that after extraction from the dict. There
> 
>  is a related type called collections.OrderedDict, which
> 
>  'remembers' the order things were added.
> 
> 
> 
> -- 
> 
> DaveA

Thanks DaveA!
This works perfectly!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: webapp development in pure python

2011-10-25 Thread Anurag Chourasia
Have you considered Django ?

http://www.djangoproject.com/ <https://www.djangoproject.com/>

Regards,
Anurag

On Tue, Oct 25, 2011 at 7:20 PM, Laszlo Nagy  wrote:

>
>  Hi,
>
> Anyone knows a framework for webapp development? I'm not talking about
> javascript/html compilers and ajax frameworks. I need something that does
> not require javascript knowledge, just pure Python. (So qooxdoo is not
> really an option, because it cannot be programmed in Python. You cannot even
> put out a window on the center of the screen without using javascript code,
> and you really have to be a javascript expert to write useful applications
> with qooxdoo.)
>
> What I need is a programmable GUI with windows, event handlers and
> extensible widgets, for creating applications that use http/https and a web
> browser for rendering.
>
> Is there something like this already available?
>
> Thanks,
>
>   Laszlo
>
>
>
> --
> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


using subprocess module in Python CGI

2008-12-22 Thread ANURAG BAGARIA
Hello,

I am a Python Newbie and would like to call a short python script via
browser using a CGI script, but initially I am trying to call the same
python script directly through python command line. The script intends to
perform a few command line in a pipe and I have written the script (a short
one) as follows.

#!/usr/bin/python

import cgi, string, os, sys, cgitb, commands, subprocess
import posixpath, macpath
#file = "x.tar.gz"
#comd = "tar -xf %s" % (file)
#os.system(comd)
#commands.getoutput('tar -xf x.tar.gz | cd demo; cp README ../')
comd = [\
"tar -xf x.tar.gz", \
"cd demo", \
"cp README ../", \
  ]
outFile = os.path.join(os.curdir, "output.log")
outptr = file(outFile, "w")
errFile = os.path.join(os.curdir, "error.log")
errptr = file(errFile, "w")
retval = subprocess.call(comd, 0, None, None, outptr, errptr)
errptr.close()
outptr.close()
if not retval == 0:
errptr = file(errFile, "r")
errData = errptr.read()
errptr.close()
raise Exception("Error executing command: " + repr(errData))


but after trying to execute this independently, I get the following error
which I am unable to interpret :

Traceback (most recent call last):
  File "process.py", line 18, in 
retval = subprocess.call(comd, 0, None, None, outptr, errptr)
  File "/usr/lib/python2.5/subprocess.py", line 443, in call
return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.5/subprocess.py", line 593, in __init__
errread, errwrite)
  File "/usr/lib/python2.5/subprocess.py", line 1135, in _execute_child
raise child_exception


Could someone suggest where am I going wrong and if corrected, what is the
probability of this script being compatible with being called through the
browser. Thanking you people in advance.

Regards.

-- 
I just want to LIVE while I'm alive.


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


Re: using subprocess module in Python CGI

2008-12-23 Thread ANURAG BAGARIA
Thank you for the prompt response.

Yeah, I missed out one line at the end of the error, the whole of which is:

Traceback (most recent call last):
  File "process.py", line 18, in 
retval = subprocess.call(comd, 0, None, None, outptr, errptr)
  File "/usr/lib/python2.5/subprocess.py", line 443, in call
return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.5/subprocess.py", line 593, in __init__
errread, errwrite)
  File "/usr/lib/python2.5/subprocess.py", line 1135, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

Looking forward to any kind of help or suggestion in this regard.
Thanks.

On Tue, Dec 23, 2008 at 7:00 AM, Chris Rebert  wrote:

> On Mon, Dec 22, 2008 at 2:02 AM, ANURAG BAGARIA
>  wrote:
> > Hello,
> >
> > I am a Python Newbie and would like to call a short python script via
> > browser using a CGI script, but initially I am trying to call the same
> > python script directly through python command line. The script intends to
> > perform a few command line in a pipe and I have written the script (a
> short
> > one) as follows.
> >
> > #!/usr/bin/python
> >
> > import cgi, string, os, sys, cgitb, commands, subprocess
> > import posixpath, macpath
> > #file = "x.tar.gz"
> > #comd = "tar -xf %s" % (file)
> > #os.system(comd)
> > #commands.getoutput('tar -xf x.tar.gz | cd demo; cp README ../')
> > comd = [\
> > "tar -xf x.tar.gz", \
> > "cd demo", \
> > "cp README ../", \
> >   ]
> > outFile = os.path.join(os.curdir, "output.log")
> > outptr = file(outFile, "w")
> > errFile = os.path.join(os.curdir, "error.log")
> > errptr = file(errFile, "w")
> > retval = subprocess.call(comd, 0, None, None, outptr, errptr)
> > errptr.close()
> > outptr.close()
> > if not retval == 0:
> > errptr = file(errFile, "r")
> > errData = errptr.read()
> > errptr.close()
> > raise Exception("Error executing command: " + repr(errData))
> >
> >
> > but after trying to execute this independently, I get the following error
> > which I am unable to interpret :
> >
> > Traceback (most recent call last):
> >   File "process.py", line 18, in 
> > retval = subprocess.call(comd, 0, None, None, outptr, errptr)
> >   File "/usr/lib/python2.5/subprocess.py", line 443, in call
> > return Popen(*popenargs, **kwargs).wait()
> >   File "/usr/lib/python2.5/subprocess.py", line 593, in __init__
> > errread, errwrite)
> >   File "/usr/lib/python2.5/subprocess.py", line 1135, in _execute_child
> > raise child_exception
>
> There should be at least one more line in this traceback, and that
> line is the most important one.
> People will need that line to help you with your problem.
>
> Cheers,
> Chris
>
> --
> Follow the path of the Iguana...
> http://rebertia.com
>



-- 
I just want to LIVE while I'm alive.


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


Re: using subprocess module in Python CGI

2009-01-08 Thread ANURAG BAGARIA
Dear Matt,

Thank you for your answer.
This script is just a kind of test script so as to actually get it started
on doing any simple job. The actual process would be much more complicated
where in I would like to extract the tar file and search for a file with
certain extension and this file would be given as input to another program
installed on the server. Later on I would also like to use process.wait() so
that I can get a status of the job execution and completion from the server
and this information can be displayed to the users on the web-page where
they submit their jobs. As to what I understand subprocess.call() would be
the best in that case. Please correct, if I am wrong.

The whole process is like a user submitting a tar file via the web-browser
with some data and getting back the processed results in the form of a new
tar file after performing a few operations on the files submitted as input
tar file.

Thanking you once again for your valuable time.
Regards.

On Wed, Dec 24, 2008 at 1:54 AM, Matt Nordhoff
wrote:

> ANURAG BAGARIA wrote:
> > Hello,
> >
> > I am a Python Newbie and would like to call a short python script via
> > browser using a CGI script, but initially I am trying to call the same
> > python script directly through python command line. The script intends
> > to perform a few command line in a pipe and I have written the script (a
> > short one) as follows.
> >
> > #!/usr/bin/python
> >
> > import cgi, string, os, sys, cgitb, commands, subprocess
> > import posixpath, macpath
> > #file = "x.tar.gz"
> > #comd = "tar -xf %s" % (file)
> > #os.system(comd)
> > #commands.getoutput('tar -xf x.tar.gz | cd demo; cp README ../')
> > comd = [\
> > "tar -xf x.tar.gz", \
> > "cd demo", \
> > "cp README ../", \
> >   ]
>
> That's not how subprocess.call() works. You're trying to run an
> executable called "tar -xf x.tar.gz", passing it the arguments "cd demo"
> and "cp README ../".
>
> > outFile = os.path.join(os.curdir, "output.log")
> > outptr = file(outFile, "w")
> > errFile = os.path.join(os.curdir, "error.log")
> > errptr = file(errFile, "w")
> > retval = subprocess.call(comd, 0, None, None, outptr, errptr)
> > errptr.close()
> > outptr.close()
> > if not retval == 0:
> > errptr = file(errFile, "r")
> > errData = errptr.read()
> > errptr.close()
> > raise Exception("Error executing command: " + repr(errData))
> >
> >
> > but after trying to execute this independently, I get the following
> > error which I am unable to interpret :
> >
> > Traceback (most recent call last):
> >   File "process.py", line 18, in 
> > retval = subprocess.call(comd, 0, None, None, outptr, errptr)
> >   File "/usr/lib/python2.5/subprocess.py", line 443, in call
> > return Popen(*popenargs, **kwargs).wait()
> >   File "/usr/lib/python2.5/subprocess.py", line 593, in __init__
> > errread, errwrite)
> >   File "/usr/lib/python2.5/subprocess.py", line 1135, in _execute_child
> > raise child_exception
> >
> >
> > Could someone suggest where am I going wrong and if corrected, what is
> > the probability of this script being compatible with being called
> > through the browser. Thanking you people in advance.
>
> Well, you'd need to output something, but otherwise, sure, why not?
>
> print "Content-Type: text/html"
> print
> print "..."
>
> > Regards.
>
> Why do you even need to use subprocess to do this? All it's doing is
> extracting the README file from a tarball, right? You can use the
> tarfile module for that.
>
> <http://docs.python.org/library/tarfile.html>
> --
>



-- 
I just want to LIVE while I'm alive.


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


Error Starting Python(Django) App using Apache+Mod_Wsgi

2010-11-22 Thread Anurag Chourasia
All,

I have a problem in starting my Python(Django) App using Apache and Mod_Wsgi

I am using Django 1.2.3 and Python 2.6.6 running on Apache 2.2.17 with
Mod_Wsgi 3.3

When I try to access the app from Web Browser, I am getting these
errors.

[Mon Nov 22 09:45:25 2010] [notice] Apache/2.2.17 (Unix) mod_wsgi/3.3
Python/2.6.6 configured -- resuming normal operations

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191] mod_wsgi
(pid=1273874): Target WSGI script '/u01/home/apli/wm/app/gdd/pyserver/
apache/django.wsgi' cannot be loaded as Python module.

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191] mod_wsgi
(pid=1273874): Exception occurred processing WSGI script '/u01/home/
apli/wm/app/gdd/pyserver/apache/django.wsgi'.

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191] Traceback
(most recent call last):

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191]   File "/u01/
home/apli/wm/app/gdd/pyserver/apache/django.wsgi", line 19, in


[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191] import
django.core.handlers.wsgi

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191]   File "/usr/
local/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line
1, in 

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191] from
threading import Lock

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191]   File "/usr/
local/lib/python2.6/threading.py", line 13, in 

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191] from
functools import wraps

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191]   File "/usr/
local/lib/python2.6/functools.py", line 10, in 

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191] from
_functools import partial, reduce

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191] ImportError:
rtld: 0712-001 Symbol PyArg_UnpackTuple was referenced

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191]   from
module /usr/local/lib/python2.6/lib-dynload/_functools.so(), but a
runtime definition


[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191]   of the
symbol was not found.

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191] rtld:
0712-001 Symbol PyCallable_Check was referenced

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191]   from
module /usr/local/lib/python2.6/lib-dynload/_functools.so(), but a
runtime definition

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191]   of the
symbol was not found.

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191] rtld:
0712-001 Symbol PyDict_Copy was referenced


[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191]   from
module /usr/local/lib/python2.6/lib-dynload/_functools.so(), but a
runtime definition

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191]   of the
symbol was not found.

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191] rtld:
0712-001 Symbol PyDict_Merge was referenced

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191]   from
module /usr/local/lib/python2.6/lib-dynload/_functools.so(), but a
runtime definition

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191]   of the
symbol was not found.

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191] rtld:
0712-001 Symbol PyDict_New was referenced

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191]   from
module /usr/local/lib/python2.6/lib-dynload/_functools.so(), but a
runtime definition

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191]   of the
symbol was not found.

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191] rtld:
0712-001 Symbol PyErr_Occurred was referenced

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191]   from
module /usr/local/lib/python2.6/lib-dynload/_functools.so(), but a
runtime definition

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191]   of the
symbol was not found.

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191] rtld:
0712-001 Symbol PyErr_SetString was referenced

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191]   from
module /usr/local/lib/python2.6/lib-dynload/_functools.so(), but a
runtime definition

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191]   of the
symbol was not found.

[Mon Nov 22 09:45:43 2010] [error] [client 108.10.0.191] \t0509-021
Additional errors occurred but are not reported.


I assume that those missing runtime definitions are supposed to be in
the Python executable. Doing an nm on the first missing symbol reveals
that it does exist.

root [zibal]% nm  /usr/local/bin/python | grep -i PyArg_UnpackTuple
.PyArg_UnpackTuple   T   268683204 524
PyArg_UnpackTupleD   537073500
PyArg_UnpackTupled   537073500  12
PyArg_UnpackTuple:F-1 - 224

Please guide.

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


collect2: library libpython2.6 not found while building extensions (--enable-shared)

2010-11-24 Thread Anurag Chourasia
All,

When I configure python to enable shared libraries, none of the extensions
are getting built during the make step due to this error.

building 'cStringIO' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall
-Wstrict-prototypes -I. -I/u01/home/apli/wm/GDD/Python-2.6.6/./Include -I.
-IInclude -I./Include -I/opt/freeware/include
-I/opt/freeware/include/readline -I/opt/freeware/include/ncurses
-I/usr/local/include -I/u01/home/apli/wm/GDD/Python-2.6.6/Include
-I/u01/home/apli/wm/GDD/Python-2.6.6 -c
/u01/home/apli/wm/GDD/Python-2.6.6/Modules/cStringIO.c -o
build/temp.aix-5.3-2.6/u01/home/apli/wm/GDD/Python-2.6.6/Modules/cStringIO.o
./Modules/ld_so_aix gcc -pthread -bI:Modules/python.exp
build/temp.aix-5.3-2.6/u01/home/apli/wm/GDD/Python-2.6.6/Modules/cStringIO.o
-L/usr/local/lib *-lpython2.6* -o build/lib.aix-5.3-2.6/cStringIO.so
*collect2: library libpython2.6 not found*

building 'cPickle' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall
-Wstrict-prototypes -I. -I/u01/home/apli/wm/GDD/Python-2.6.6/./Include -I.
-IInclude -I./Include -I/opt/freeware/include
-I/opt/freeware/include/readline -I/opt/freeware/include/ncurses
-I/usr/local/include -I/u01/home/apli/wm/GDD/Python-2.6.6/Include
-I/u01/home/apli/wm/GDD/Python-2.6.6 -c
/u01/home/apli/wm/GDD/Python-2.6.6/Modules/cPickle.c -o
build/temp.aix-5.3-2.6/u01/home/apli/wm/GDD/Python-2.6.6/Modules/cPickle.o
./Modules/ld_so_aix gcc -pthread -bI:Modules/python.exp
build/temp.aix-5.3-2.6/u01/home/apli/wm/GDD/Python-2.6.6/Modules/cPickle.o
-L/usr/local/lib *-lpython2.6* -o build/lib.aix-5.3-2.6/cPickle.so
*collect2: library libpython2.6 not found*

This is on AIX 5.3, GCC 4.2, Python 2.6.6

I can confirm that there is a libpython2.6.a file in the top level directory
from where I am doing the configure/make etc

Here are the options supplied to the configure command

./configure --enable-shared --disable-ipv6 --with-gcc=gcc CPPFLAGS="-I
/opt/freeware/include -I /opt/freeware/include/readline -I
/opt/freeware/include/ncurses"

Please guide me in getting past this error.

Thanks for your help on this.

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


AIX 5.3 - Enabling Shared Library Support Vs Extensions

2010-11-25 Thread Anurag Chourasia
All,

When I configure python to enable shared libraries, none of the
extensions are getting built during the make step due to this error.

building 'cStringIO' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall
-Wstrict-prototypes -I. -I/u01/home/apli/wm/GDD/Python-2.6.6/./Include -I.
-IInclude -I./Include -I/opt/freeware/include
-I/opt/freeware/include/readline -I/opt/freeware/include/ncurses
-I/usr/local/include -I/u01/home/apli/wm/GDD/Python-2.6.6/Include
-I/u01/home/apli/wm/GDD/Python-2.6.6 -c
/u01/home/apli/wm/GDD/Python-2.6.6/Modules/cStringIO.c -o
build/temp.aix-5.3-2.6/u01/home/apli/wm/GDD/Python-2.6.6/Modules/cStringIO.o
./Modules/ld_so_aix gcc -pthread -bI:Modules/python.exp
build/temp.aix-5.3-2.6/u01/home/apli/wm/GDD/Python-2.6.6/Modules/cStringIO.o
-L/usr/local/lib *-lpython2.6* -o build/lib.aix-5.3-2.6/cStringIO.so
*collect2: library libpython2.6 not found*

building 'cPickle' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall
-Wstrict-prototypes -I. -I/u01/home/apli/wm/GDD/Python-2.6.6/./Include -I.
-IInclude -I./Include -I/opt/freeware/include
-I/opt/freeware/include/readline -I/opt/freeware/include/ncurses
-I/usr/local/include -I/u01/home/apli/wm/GDD/Python-2.6.6/Include
-I/u01/home/apli/wm/GDD/Python-2.6.6 -c
/u01/home/apli/wm/GDD/Python-2.6.6/Modules/cPickle.c -o
build/temp.aix-5.3-2.6/u01/home/apli/wm/GDD/Python-2.6.6/Modules/cPickle.o
./Modules/ld_so_aix gcc -pthread -bI:Modules/python.exp
build/temp.aix-5.3-2.6/u01/home/apli/wm/GDD/Python-2.6.6/Modules/cPickle.o
-L/usr/local/lib *-lpython2.6* -o build/lib.aix-5.3-2.6/cPickle.so
*collect2: library libpython2.6 not found*

This is on AIX 5.3, GCC 4.2, Python 2.6.6

I can confirm that there is a libpython2.6.a file in the top level
directory from where I am doing the configure/make etc

Here are the options supplied to the configure command

./configure --enable-shared --disable-ipv6 --with-gcc=gcc CPPFLAGS="-I
/opt/freeware/include -I /opt/freeware/include/readline -I
/opt/freeware/include/ncurses"

Please guide me in getting past this error.

Thanks for your help on this.

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


Re: AIX 5.3 - Enabling Shared Library Support Vs Extensions

2010-11-27 Thread Anurag Chourasia
Hi Stefan,

I followed your suggestion and configured LDFLAGS but the make step fails
for another error now.

My configuration options are as follows

./configure --enable-shared --disable-ipv6 --with-gcc=gcc CPPFLAGS="-I
/opt/freeware/include -I /opt/freeware/include/readline -I
/opt/freeware/include/ncurses" LDFLAGS="-L. -L/usr/local/lib"

Below is the transcript from the make step.
++
running build
running build_ext
ldd: /lib/libreadline.a: File is an archive.
INFO: Can't locate Tcl/Tk libs and/or headers
building '_struct' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall
-Wstrict-prototypes -I. -I/u01/home/apli/wm/GDD/Python-2.6.6/./Include -I.
-IInclude -I./Include -I/opt/freeware/include
-I/opt/freeware/include/readline -I/opt/freeware/include/ncurses
-I/usr/local/include -I/u01/home/apli/wm/GDD/Python-2.6.6/Include
-I/u01/home/apli/wm/GDD/Python-2.6.6 -c
/u01/home/apli/wm/GDD/Python-2.6.6/Modules/_struct.c -o
build/temp.aix-5.3-2.6/u01/home/apli/wm/GDD/Python-2.6.6/Modules/_struct.o
./Modules/ld_so_aix gcc -pthread -bI:Modules/python.exp -L. -L/usr/local/lib
build/temp.aix-5.3-2.6/u01/home/apli/wm/GDD/Python-2.6.6/Modules/_struct.o
-L. -L/usr/local/lib -lpython2.6 -o build/lib.aix-5.3-2.6/_struct.so
*Fatal Python error: Interpreter not initialized (version mismatch?)*
*make: 1254-059 The signal code from the last command is 6.*
++

The last command that i see above (ld_so_aix) seems to have completed as the
file _struct.so exists after this command and hence I am not sure which step
is failing.

There is no other Python version on my machine.

Please guide.

On Thu, Nov 25, 2010 at 3:41 PM, Stefan Krah wrote:

> Anurag Chourasia  wrote:
> > When I configure python to enable shared libraries, none of the
> extensions are getting built during the make step due to this error.
> >
> > building 'cStringIO' extension
> > gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall
> > -Wstrict-prototypes -I. -I/u01/home/apli/wm/GDD/Python-2.6.6/./Include
> -I.
> > -IInclude -I./Include -I/opt/freeware/include
> > -I/opt/freeware/include/readline -I/opt/freeware/include/ncurses
> > -I/usr/local/include -I/u01/home/apli/wm/GDD/Python-2.6.6/Include
> > -I/u01/home/apli/wm/GDD/Python-2.6.6 -c
> > /u01/home/apli/wm/GDD/Python-2.6.6/Modules/cStringIO.c -o
> >
> build/temp.aix-5.3-2.6/u01/home/apli/wm/GDD/Python-2.6.6/Modules/cStringIO.o
> > ./Modules/ld_so_aix gcc -pthread -bI:Modules/python.exp
> >
> build/temp.aix-5.3-2.6/u01/home/apli/wm/GDD/Python-2.6.6/Modules/cStringIO.o
> > -L/usr/local/lib *-lpython2.6* -o build/lib.aix-5.3-2.6/cStringIO.so
>   
>
> Try these flags: -L. -L/usr/local/lib
>
>
> If this solves the problem and the issue is also present in Python-2.7,
> you should report a bug at http://bugs.python.org/ .
>
>
> Stefan Krah
>
>
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Python make fails with error "Fatal Python error: Interpreter not initialized (version mismatch?)"

2010-11-27 Thread Anurag Chourasia
Hi All,

During the make step of python, I am encountering a weird error. This is on
AIX 5.3 using gcc as the compiler.

My configuration options are as follows

./configure --enable-shared --disable-ipv6 --with-gcc=gcc CPPFLAGS="-I
/opt/freeware/include -I /opt/freeware/include/readline -I
/opt/freeware/include/ncurses" LDFLAGS="-L. -L/usr/local/lib"


Below is the transcript from the make step.
++
running build
running build_ext
ldd: /lib/libreadline.a: File is an archive.
INFO: Can't locate Tcl/Tk libs and/or headers
building '_struct' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall
-Wstrict-prototypes -I. -I/u01/home/apli/wm/GDD/Python-2.6.6/./Include -I.
-IInclude -I./Include -I/opt/freeware/include
-I/opt/freeware/include/readline -I/opt/freeware/include/ncurses
-I/usr/local/include -I/u01/home/apli/wm/GDD/Python-2.6.6/Include
-I/u01/home/apli/wm/GDD/Python-2.6.6 -c
/u01/home/apli/wm/GDD/Python-2.6.6/Modules/_struct.c -o
build/temp.aix-5.3-2.6/u01/home/apli/wm/GDD/Python-2.6.6/Modules/_struct.o
./Modules/ld_so_aix gcc -pthread -bI:Modules/python.exp -L. -L/usr/local/lib
build/temp.aix-5.3-2.6/u01/home/apli/wm/GDD/Python-2.6.6/Modules/_struct.o
-L. -L/usr/local/lib -lpython2.6 -o build/lib.aix-5.3-2.6/_struct.so
*Fatal Python error: Interpreter not initialized (version mismatch?)*
*make: 1254-059 The signal code from the last command is 6.*
++

The last command that i see above (ld_so_aix) seems to have completed as the
file _struct.so exists after this command and hence I am not sure which step
is failing.

There is no other Python version on my machine.

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


***locale.Error: unsupported locale setting***

2010-12-09 Thread Anurag Chourasia
Hi All,

When i try to set a locale manually, i get this error.

>>> import locale
>>> locale.setlocale(locale.LC_ALL, 'es_cl.iso88591')
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python2.7/locale.py", line 531, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting

On my OS, when i run the locale -a command, i get this output
-
*locale -a*
C
POSIX
en_US
en_US.8859-15
en_US.ISO8859-1
-
Does this means that on my machine, Python will be able to make use of above
listed locales?

*If yes then how can i possibly use the locale.setformat (or anything else
for that matter) to group numbers using '.' as the thousands separator?*

If i use the locale en_US then ',' is the thousands separator.

>>> import locale
>>> locale.setlocale(locale.LC_ALL, 'en_US')
'en_US'
>>> locale.format("%d", 1255000, grouping=True)
'1,255,000'

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


**** httplib.InvalidURL: nonnumeric port ****

2010-12-20 Thread Anurag Chourasia
All,

When i try to open a URL of the form
http://joule:8041/DteEnLinea/ws/EnvioGuia.jws, I am getting an error as
below complaining for some non-numeric port.

wm (wmosds) [zibal] - /u01/home/apli/wm/app/gdd :>python
Python 2.4.1 (#2, May 30 2005, 09:40:30) [C] on aix5
Type "help", "copyright", "credits" or "license" for more information.
>>> import httplib, mimetypes
>>> h = httplib.HTTP('http://joule:8041/DteEnLinea/ws/EnvioGuia.jws')
Traceback (most recent call last):
  File "", line 1, in ?
  File "/u01/home/apli/wm/python241/lib/python2.4/httplib.py", line 1093, in
__init__
self._setup(self._connection_class(host, port, strict))
  File "/u01/home/apli/wm/python241/lib/python2.4/httplib.py", line 582, in
__init__
self._set_hostport(host, port)
  File "/u01/home/apli/wm/python241/lib/python2.4/httplib.py", line 594, in
_set_hostport
raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
httplib.InvalidURL: nonnumeric port: '8041/DteEnLinea/ws/EnvioGuia.jws'

How could we avoid this problem?

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


Sending XML to a WEB Service and Getting Response Back

2010-12-20 Thread Anurag Chourasia
Dear Python Mates,

I have a requirement to send a XML Data to a WEB Service whose URL is of the
form http://joule:8041/DteEnLinea/ws/EnvioGuia.jws

I also have to read back the response returned as a result of sending this
data to this WebService.

This web service implements the following operations:
   sendNCR

This web service has no callbacks.

I have pasted the complete WSDL for this WEB Service below my email.

I would appreciate if someone could guide me with sample code using a Python
Library suitable to fulfill this requirement of mine.

Regards,
Anurag



http://www.openuri.org/2002/04/soap/conversation/"; xmlns:cw="
http://www.openuri.org/2002/04/wsdl/conversation/"; xmlns:http="
http://schemas.xmlsoap.org/wsdl/http/"; xmlns:jms="
http://www.openuri.org/2002/04/wsdl/jms/"; xmlns:mime="
http://schemas.xmlsoap.org/wsdl/mime/"; xmlns:s="
http://www.w3.org/2001/XMLSchema"; xmlns:s0="http://www.openuri.org/";
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; xmlns:soapenc="
http://schemas.xmlsoap.org/soap/encoding/"; xmlns:wsdl="
http://schemas.xmlsoap.org/wsdl/"; targetNamespace="http://www.openuri.org/";>
  
http://www.w3.org/2001/XMLSchema";
elementFormDefault="qualified" targetNamespace="http://www.openuri.org/";>
  

  

  

  
  

  

  

  
  


  
  

  
  

  
  

  
  

  
  

  
  

  
  

  
  

  
  

  
  

  
  

  
  

  
  
http://schemas.xmlsoap.org/soap/http";
style="document"/>

  http://www.openuri.org/sendNCR";
style="document"/>
  

  
  

  

  
  


  
  

  
  

  

  
  


  
  

  
  

  

  
  

  http://joule:8041/DteEnLinea/ws/EnvioGuia.jws
"/>


  http://joule:8041/DteEnLinea/ws/EnvioGuia.jws
"/>


  http://joule:8041/DteEnLinea/ws/EnvioGuia.jws
"/>

  

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


Re: **** httplib.InvalidURL: nonnumeric port ****

2010-12-20 Thread Anurag Chourasia
Hi Kevin,

Thanks for the response.

I tried with HTTPConnection but the same problem.

>>> h1 = httplib.HTTPConnection('
http://joule:8041/DteEnLinea/ws/EnvioGuia.jws')
Traceback (most recent call last):
  File "", line 1, in ?
  File "/u01/home/apli/wm/python241/lib/python2.4/httplib.py", line 582, in
__init__
self._set_hostport(host, port)
  File "/u01/home/apli/wm/python241/lib/python2.4/httplib.py", line 594, in
_set_hostport
raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
httplib.InvalidURL: nonnumeric port: '8041/DteEnLinea/ws/EnvioGuia.jws'

Do i need to use some other library to be able to send XML Data (and get a
response back) to this Kind of Web Service address i.e.
http://joule:8041/DteEnLinea/ws/EnvioGuia.jws ?

Regards,
Anurag

On Tue, Dec 21, 2010 at 12:42 AM, Kev Dwyer  wrote:

> On Tue, 21 Dec 2010 00:01:44 +0530, Anurag Chourasia wrote:
>
> >>> import httplib
> >>> help(httplib.HTTP)
> Help on class HTTP in module httplib:
>
> class HTTP
>  |  Compatibility class with httplib.py from 1.5.
>  |
>  |  Methods defined here:
>  |
>  |  __init__(self, host='', port=None, strict=None)
>
> The constructor doesn't take a complete URL as an argument.
>
> Also, shouldn't you be using httplib.HTTPConnection?  The docs
>  state that httplib.HTTP is for backward compatibility only.
>
> Kev
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sending XML to a WEB Service and Getting Response Back

2010-12-21 Thread Anurag Chourasia
Thanks for the response all.

I tried exploring suds (which seems to be the current) and i hit
problems right away. I will now try urllib or httplib.

I have asked for help in the suds forum. Hope somebody replies.

When i try to create a client, the error is as follows.

>>> from suds.client import Client
>>> url = 'http://10.251.4.33:8041/DteEnLinea/ws/EnvioGuia.jws'
>>> client = Client(url)

Traceback (most recent call last):
  File "", line 1, in 
  File "suds/client.py", line 112, in __init__
self.wsdl = reader.open(url)
  File "suds/reader.py", line 152, in open
d = self.fn(url, self.options)
  File "suds/wsdl.py", line 136, in __init__
d = reader.open(url)
  File "suds/reader.py", line 79, in open
d = self.download(url)
  File "suds/reader.py", line 101, in download
return sax.parse(string=content)
  File "suds/sax/parser.py", line 136, in parse
sax.parse(source)
  File "/usr/local/lib/python2.7/xml/sax/expatreader.py", line 107, in parse
xmlreader.IncrementalParser.parse(self, source)
  File "/usr/local/lib/python2.7/xml/sax/xmlreader.py", line 123, in parse
self.feed(buffer)
  File "/usr/local/lib/python2.7/xml/sax/expatreader.py", line 211, in feed
self._err_handler.fatalError(exc)
  File "/usr/local/lib/python2.7/xml/sax/handler.py", line 38, in fatalError
raise exception
xml.sax._exceptions.SAXParseException: :1:62: syntax error
>>> [3] + Stopped (SIGTSTP)python

This seems to be a old problem passing versions.

Regards,
Anurag

On Wed, Dec 22, 2010 at 12:40 AM, John Nagle  wrote:
> On 12/20/2010 11:45 PM, Ian Kelly wrote:
>>
>> On 12/20/2010 11:34 PM, John Nagle wrote:
>>>
>>> SOAPpy is way out of date. The last update on SourceForge was in
>>> 2001.
>>
>> 2007, actually: http://sourceforge.net/projects/pywebsvcs/files/
>>
>> And there is repository activity within the past 9 months. Still, point
>> taken.
>
>   The original SOAPpy was at
>
>        http://sourceforge.net/projects/soapy/files/
>
> but was apparently abandoned in 2001. Someone else picked
> it up and moved it to
>
>        http://sourceforge.net/projects/pywebsvcs/files/SOAP.py/
>
> where it was last updated in 2005.  ZSI was last updated in
> 2007.  Users are still submitting bug reports, but nobody
> is answering.  Somebody posted "Who maintains the pywebsvcs webpage?"
> in February 2009, but no one answered them.
>
>    There's also "Python SOAP"
>
> http://sourceforge.net/projects/pythonsoap/
>
> abandoned in 2005.
>
>    The "suds" module
>
> http://sourceforge.net/projects/python-suds/
>
> was last updated in March, 2010.  That version
> will work with Python 2.6, and probably 2.7.
> There's very little project activity, but at
> least it's reasonably current.
>
>                                John Nagle
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using python ftp

2010-12-22 Thread Anurag Chourasia
Hi Matt,

I have a snippet to "upload" files (that match a particular search
pattern) to a remote server.

Variable names are self explanatory. You could tweak this a little to
"download" files instead.

from ftplib import FTP
ftp = FTP(hostname)
ftp.login(user_id,passwd)
ftp.cwd(remote_directory)
files_list=glob.glob(file_search_pattern)
for file in files_list:
try:
ftp.storlines('STOR ' + file, open(file))
except Exception, e:
print ('Failed to FTP file: %s' %(file))
ftp.close()

Regards,
Anurag

On Thu, Dec 23, 2010 at 5:33 AM, Matt Funk  wrote:
> Hi,
>
> i was wondering whether someone can point me whether the following
> already exists.
>
> I want to connect to a server , download various files (for whose name i
> want to be able to use a wildcard), and store those files in a given
> location on the hard drive. If the file already exists i do not want to
> download it.
>
> This seems fairly trivial and i would assume that there should be some
> sort of implementation that does this easily but i didn't find anything
> googling it.
>
> Otherwise i was going to do it "by hand" using ftplib:
> 1) connect to server,
> 2) change to directory on server
> 3) get listing
> 4) match the file pattern i want to the listing
> 5) check if file already exists
> 6) download file if matched and doesn't exist
>
> Can anyone offer any advice whether this already done somewhere?
>
> thanks
> matt
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python programming

2010-12-22 Thread Anurag Chourasia
Here you go.

$ python
Python 2.5.2 (r252:60911, Dec  2 2008, 09:26:14)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> A=[2,6,5]
>>> if 5 in A:
... print 'Yes'
... else:
... print 'No'
...
Yes
>>>

Regards,
Anurag

On Thu, Dec 23, 2010 at 6:52 AM, Maurice Shih wrote:

> Dear [email protected],
> Thank you for taking the time to listen to my request. I'm a beginner
> programmer and I se python 2.6. I am making a program that needs a command
> that can check if a value is in a list. For example to check whether 5 is in
> [2, 6, 5,]. Thank you for hearing my request.
> Maurice Shih
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Digitally Signing a XML Document (using SHA1+RSA or SHA1+DSA)

2010-12-27 Thread Anurag Chourasia
Hi All,

I have a requirement to digitally sign a XML Document using SHA1+RSA
or SHA1+DSA

Could someone give me a lead on a library that I can use to fulfill this
requirement?

The XML Document has values such as

-BEGIN RSA PRIVATE KEY-
MIIBOgIBAAJBANWzHfF5Bppe4JKlfZDqFUpNLrwNQqguw76g/jmeO6f4i31rDLVQ
n7sYilu65C8vN+qnEGnPB824t/A3yfMu1G0CAQMCQQCOd2lLpgRm6esMblO18WOG
3h8oCNcaydfUa1QmaX0apHlDFnI7UDXpYaHp2VL9gvtSJT5L3ZASMzxRPXJSvzcT
AiEA/16jQh18BAD4q3yk1gKw19I8OuJOYAxFYX9noCEFWUMCIQDWOiYfPtxK3A1s
AFARsDnnHTL4FbRPpiZ79vP+VgqojwIhAKo/F4Fo/VgApceobeQByzqMKCdBiZVd
g5ZU78AWA5DXAiEAjtFuv389hz1eSAA1YSAmmhN3UA54NRlu/U9NVDlccF8CIBkc
Z52oGxy/skwVwI5TBcB1YqXJTT47/6/hTAVMTwaA -END RSA PRIVATE
KEY-

-BEGIN PUBLIC KEY-
MFowDQYJKoZIhvcNAQEBBQADSQAwRgJBANWzHfF5Bppe4JKlfZDqFUpNLrwNQqgu
w76g/jmeO6f4i31rDLVQn7sYilu65C8vN+qnEGnPB824t/A3yfMu1G0CAQM= -END PUBLIC
KEY-

And the XML also has another node that has a Public Key with Modules and
Exponents etc that I apparently need to utilize.


  
1bMd8XkGml7gkqV9kOoVSk0uvA1CqC7DvqD+OZ47p/iLfWsMtVCfuxiKW7rkLy836qcQac8Hzbi38DfJ8y7UbQ==
  Aw==


I am a little thin on this concept and expecting if you could guide me to a
library/documentation that I could utilize.

Thanks a lot for your help.

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


Re: Digitally Signing a XML Document (using SHA1+RSA or SHA1+DSA)

2010-12-28 Thread Anurag Chourasia
Dear all,

I am required to use the Private Key from that XML below to generate a
digital signature.

The public key can then be used to validate the generated signature.

http://stuvel.eu/rsa does not support PKCS#1 and hence I am required to look
for alternates.

Please let me know if there is something else out there that could help meet
my requirement.

Regards,
Anurag

On Tue, Dec 28, 2010 at 6:36 AM, Adam Tauno Williams  wrote:

> On Tue, 2010-12-28 at 03:25 +0530, Anurag Chourasia wrote:
> > Hi All,
>
> > I have a requirement to digitally sign a XML Document using SHA1+RSA
> > or SHA1+DSA
> > Could someone give me a lead on a library that I can use to fulfill
> > this requirement?
>
> <http://stuvel.eu/rsa>  Never used it though.
>
> > The XML Document has values such as
> > -BEGIN RSA PRIVATE KEY-
> > MIIBOgIBAAJBANWzHfF5Bppe4JKlfZDqFUpNLrwNQqguw76g/jmeO6f4i31rDLVQ
> > n7sYilu65C8vN+qnEGnPB824t/A3yfMu1G0CAQMCQQCOd2lLpgRm6esMblO18WOG
> > 3h8oCNcaydfUa1QmaX0apHlDFnI7UDXpYaHp2VL9gvtSJT5L3ZASMzxRPXJSvzcT
> > AiEA/16jQh18BAD4q3yk1gKw19I8OuJOYAxFYX9noCEFWUMCIQDWOiYfPtxK3A1s
> > AFARsDnnHTL4FbRPpiZ79vP+VgqojwIhAKo/F4Fo/VgApceobeQByzqMKCdBiZVd
> > g5ZU78AWA5DXAiEAjtFuv389hz1eSAA1YSAmmhN3UA54NRlu/U9NVDlccF8CIBkc
> > Z52oGxy/skwVwI5TBcB1YqXJTT47/6/hTAVMTwaA -END RSA PRIVATE
> > KEY-
> > -BEGIN PUBLIC KEY-
> > MFowDQYJKoZIhvcNAQEBBQADSQAwRgJBANWzHfF5Bppe4JKlfZDqFUpNLrwNQqgu
> > w76g/jmeO6f4i31rDLVQn7sYilu65C8vN+qnEGnPB824t/A3yfMu1G0CAQM= -END
> > PUBLIC KEY-
>
> Is this any kind of standard or just something someone made up?  Is
> there a namespace for the document?
>
> It seems quite odd that the document contains a *private* key.
>
> If all you need to do is parse to document to retrieve the values that
> seems straight-forward enough.
>
> > And the XML also has another node that has a Public Key with Modules
> > and Exponents etc that I apparently need to utilize.
> > 
> >   1bMd8XkGml7gkqV9kOoVSk0uvA1CqC7DvqD
> > +OZ47p/iLfWsMtVCfuxiKW7rkLy836qcQac8Hzbi38DfJ8y7UbQ==
> >   Aw==
> > 
>
> > I am a little thin on this concept and expecting if you could guide me
> > to a library/documentation that I could utilize.
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: FTP problem

2011-01-14 Thread Anurag Chourasia
Please make the below change to get past this problem

Change

*ftp.*indexftp.barcap.com

to

indexftp.barcap.com

Regards,
Anurag

On Fri, Jan 14, 2011 at 5:25 PM, Thomas Philips  wrote:

> I'm using ftplib for the first time, and am having trouble getting it
> to work. I type
>
> >>> from ftplib import FTP
> >>> ftp = FTP('ftp.indexftp.barcap.com', 'A Valid Username', ' A Valid
> Password')
>
> where I have suppressed the user name and password, and I get
>
> Traceback (most recent call last):
>  File "", line 1, in 
>ftp = FTP('ftp.indexftp.barcap.com')
>  File "C:\Python26\lib\ftplib.py", line 116, in __init__
>self.connect(host)
>  File "C:\Python26\lib\ftplib.py", line 131, in connect
>self.sock = socket.create_connection((self.host, self.port),
> self.timeout)
>  File "C:\Python26\lib\socket.py", line 498, in create_connection
>for res in getaddrinfo(host, port, 0, SOCK_STREAM):
> gaierror: [Errno 11001] getaddrinfo failed
>
> I have tried this on two different computers and on two different
> versions of Python (2.6 and 2.7). I get the same error both times, and
> have no understanding of what the problem might be. Any assistance
> would be greatly appreciated.
>
> Sincerely
>
> Thomas Philips
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Connecting to remote Oracle db via Python

2011-02-17 Thread Anurag Chourasia
Could you try by using a connecting string in the standard format as below?

Connection_String =
'scott/tiger@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.5.1.12(PORT=1521)))(CONNECT_DATA=(SID=PR10)))'

db = cx_Oracle.connect(Connection_String)

Regards,
Anurag

On Thu, Feb 17, 2011 at 4:10 PM, pstatham  wrote:
> Hi Guys,
>
> I've installed the cx_Oracle module for Python and I'm trying to
> connect to my remote Oracle db. Like so (username, password and ip
> below aren't real don't worry)
>
>>>> uid = "scott"
>>>> pwd = "tiger"
>>>> service = "10.5.1.12:1521:PR10"
>>>> db = cx_Oracle.connect(uid + "/" + pwd + "@" + service)
>
> This however gives me the following error:
>
> Traceback (most recent call last):
>  File "", line 1, in 
> cx_Oracle.DatabaseError: ORA-12545: Connect failed because target host
> or object
>  does not exist
>
> I've also tried the following (jdbc string which works fine for java)
>
>>>> service = "jdbc:oracle:thin:@10.5.1.12:1521:PR10"
>>>> db = cx_Oracle.connect(uid + "/" + pwd + "@" + service)
> Traceback (most recent call last):
>  File "", line 1, in 
> cx_Oracle.DatabaseError: ORA-12154: TNS:could not resolve the connect
> identifier
>  specified
>
> I'm not sure what's going on because I know that the ip, port and
> service name. are correct? And as I said I can connect to it via JDBC
> in Java.
>
> Any ideas?
>
> Thanks,
> Paul
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Connecting to remote Oracle db via Python

2011-02-17 Thread Anurag Chourasia
Try this please and it should work.

Connection_String =
'scott/tiger@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.5.1.12)(PORT=1521)))(CONNECT_DATA=(SID=PR10)))'

db = cx_Oracle.connect(Connection_String)

I'm sorry i missed a bracket there.

Regards,
Anurag


On Thu, Feb 17, 2011 at 8:18 PM, Paul Statham  wrote:
> Doesn't seem to work
>
> -Original Message-
> From: Anurag Chourasia [mailto:[email protected]]
> Sent: 17 February 2011 14:41
> To: Paul Statham
> Cc: [email protected]
> Subject: Re: Connecting to remote Oracle db via Python
>
> Could you try by using a connecting string in the standard format as below?
>
> Connection_String =
> 'scott/tiger@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.5.1.12(PORT=1521)))(CONNECT_DATA=(SID=PR10)))'
>
> db = cx_Oracle.connect(Connection_String)
>
> Regards,
> Anurag
>
> On Thu, Feb 17, 2011 at 4:10 PM, pstatham  wrote:
>> Hi Guys,
>>
>> I've installed the cx_Oracle module for Python and I'm trying to
>> connect to my remote Oracle db. Like so (username, password and ip
>> below aren't real don't worry)
>>
>>>>> uid = "scott"
>>>>> pwd = "tiger"
>>>>> service = "10.5.1.12:1521:PR10"
>>>>> db = cx_Oracle.connect(uid + "/" + pwd + "@" + service)
>>
>> This however gives me the following error:
>>
>> Traceback (most recent call last):
>>  File "", line 1, in 
>> cx_Oracle.DatabaseError: ORA-12545: Connect failed because target host
>> or object
>>  does not exist
>>
>> I've also tried the following (jdbc string which works fine for java)
>>
>>>>> service = "jdbc:oracle:thin:@10.5.1.12:1521:PR10"
>>>>> db = cx_Oracle.connect(uid + "/" + pwd + "@" + service)
>> Traceback (most recent call last):
>>  File "", line 1, in 
>> cx_Oracle.DatabaseError: ORA-12154: TNS:could not resolve the connect
>> identifier
>>  specified
>>
>> I'm not sure what's going on because I know that the ip, port and
>> service name. are correct? And as I said I can connect to it via JDBC
>> in Java.
>>
>> Any ideas?
>>
>> Thanks,
>> Paul
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Connecting to remote Oracle db via Python

2011-02-17 Thread Anurag Chourasia
Apart from that, you could also use a shorter format which is a
correction over what you were trying with earlier.

Here..

uid = "scott"
pwd = "tiger"
service = "//10.5.1.12:1521/PR10"
db = cx_Oracle.connect(uid + "/" + pwd + "@" + service)

Please let us know how it goes.

Regards,
Anurag

On Thu, Feb 17, 2011 at 8:28 PM, Anurag Chourasia
 wrote:
> Try this please and it should work.
>
> Connection_String =
> 'scott/tiger@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.5.1.12)(PORT=1521)))(CONNECT_DATA=(SID=PR10)))'
>
> db = cx_Oracle.connect(Connection_String)
>
> I'm sorry i missed a bracket there.
>
> Regards,
> Anurag
>
>
> On Thu, Feb 17, 2011 at 8:18 PM, Paul Statham  wrote:
>> Doesn't seem to work
>>
>> -Original Message-
>> From: Anurag Chourasia [mailto:[email protected]]
>> Sent: 17 February 2011 14:41
>> To: Paul Statham
>> Cc: [email protected]
>> Subject: Re: Connecting to remote Oracle db via Python
>>
>> Could you try by using a connecting string in the standard format as below?
>>
>> Connection_String =
>> 'scott/tiger@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.5.1.12(PORT=1521)))(CONNECT_DATA=(SID=PR10)))'
>>
>> db = cx_Oracle.connect(Connection_String)
>>
>> Regards,
>> Anurag
>>
>> On Thu, Feb 17, 2011 at 4:10 PM, pstatham  wrote:
>>> Hi Guys,
>>>
>>> I've installed the cx_Oracle module for Python and I'm trying to
>>> connect to my remote Oracle db. Like so (username, password and ip
>>> below aren't real don't worry)
>>>
>>>>>> uid = "scott"
>>>>>> pwd = "tiger"
>>>>>> service = "10.5.1.12:1521:PR10"
>>>>>> db = cx_Oracle.connect(uid + "/" + pwd + "@" + service)
>>>
>>> This however gives me the following error:
>>>
>>> Traceback (most recent call last):
>>>  File "", line 1, in 
>>> cx_Oracle.DatabaseError: ORA-12545: Connect failed because target host
>>> or object
>>>  does not exist
>>>
>>> I've also tried the following (jdbc string which works fine for java)
>>>
>>>>>> service = "jdbc:oracle:thin:@10.5.1.12:1521:PR10"
>>>>>> db = cx_Oracle.connect(uid + "/" + pwd + "@" + service)
>>> Traceback (most recent call last):
>>>  File "", line 1, in 
>>> cx_Oracle.DatabaseError: ORA-12154: TNS:could not resolve the connect
>>> identifier
>>>  specified
>>>
>>> I'm not sure what's going on because I know that the ip, port and
>>> service name. are correct? And as I said I can connect to it via JDBC
>>> in Java.
>>>
>>> Any ideas?
>>>
>>> Thanks,
>>> Paul
>>> --
>>> http://mail.python.org/mailman/listinfo/python-list
>>>
>>
>>
>>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


How to build an application in Django which will handle Multiple servers accross network

2011-04-28 Thread Anurag (anu) Agarwal
Hi All,

I want to build an application for one of my client which has
following features

1. Client has some driver software which can be installed on Windows
and Linux based systems. This driver software is fetching some
operating system details using kernel level programming.
2. Now a new web based application is required to moniter these
servers remotly. This application will talk to these servers and get
the data (not sure how data will be fetched from driver software) then
show it on UI.
3. The web based application will be used internally in the network to
moniter servers in that network only.
4. Web based application will be a real time application with a
Database.
5. Technology I am thingking for web based application is Django and
Python as this web application can also be installed on Windows or
Linux based OS.
6. Also please suggest which third party tool for chatrs and graphs I
should use with Django (open source + paid)

If you guys can help me in desiging a very high level Architecture of
this application.

Thanks for reading so long. Please help me in this. If I am not clear
on something then please write back.

Thanks & Regards,
Anurag
-- 
http://mail.python.org/mailman/listinfo/python-list