python-ldap and encodings
Hi! I'm using python-ldap to create some entries on my openldap server. The problem is that some of those entries have accented characters and unicode text in general. I'm wondering if there is any example or documentation on how to add or modify ldap objects whose values contains non-ascii characters, such as accents, and so on. As far as I understand, those values should be encoded using base64, but if I do that, I don't know how to indicate in the modlist that this is the encoded value and not the value itself. Any help will be bery appreciated. Matias. -- http://mail.python.org/mailman/listinfo/python-list
Re: python-ldap and encodings
Matias wrote: Hi! I'm using python-ldap to create some entries on my openldap server. The problem is that some of those entries have accented characters and unicode text in general. I'm wondering if there is any example or documentation on how to add or modify ldap objects whose values contains non-ascii characters, such as accents, and so on. As far as I understand, those values should be encoded using base64, but if I do that, I don't know how to indicate in the modlist that this is the encoded value and not the value itself. Any help will be bery appreciated. Matias. Nevermind I was doing something really stupid.Don't ask please :-) -- http://mail.python.org/mailman/listinfo/python-list
One module per class, bad idea?
I come from a background of Java and C# where it is common practise to have one class per file in the file/project structure. As I have understood it, it is more common practice to have many classes in a Python module/file. What is the motivation behind it, would it be a bad idea to have a guideline in your project that promotes a one class per file structure (assuming most of the programmers a background similar to mine)? -- http://mail.python.org/mailman/listinfo/python-list
Delete a file from a CGI
HI!
I want to delete a file from a CGI, but I always get a Permission denied
error.
I've tryed this after creating the file (from a normal script):
os.chmod(".lock",stat.S_IMODE(stat.S_IRWXU | stat.S_IRWXO | stat.S_IRWXG))
os.chown(".lock",pwd.getpwnam("nobody")[2],pwd.getpwnam("nobody")[3])
but the CGI still can't delete the file.
I will appreciate very much your help.
Thanks a lot.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Delete a file from a CGI
Thanks for your reply.
This is the code that creates the file:
lock_file = open(".lock","w")
lock_file.write("test")
lock_file.close()
#Change permissions so that CGI can write lock file
os.chmod(".lock",stat.S_IMODE(stat.S_IRWXU | stat.S_IRWXO | stat.S_IRWXG))
This script was run as root.
Now, the code of the CGI that should delete the file:
#As you see, I can write to the file
lock_file = open(".lock","w")
lock_file.write("")
lock_file.close()
# But the following line raises a "permission denied" OSError
os.remove(".lock")
I've seen that the script is running as "nobody", but, the file is rwx by
everybody. I've also tryed changing the owner of the file to "nobody" also,
but no luck anyway.
Thanks a lot.
Steve Holden wrote:
> Matias Surdi wrote:
>> HI!
>>
>> I want to delete a file from a CGI, but I always get a Permission denied
>> error.
>>
>> I've tryed this after creating the file (from a normal script):
>>
>> os.chmod(".lock",stat.S_IMODE(stat.S_IRWXU | stat.S_IRWXO |
>> stat.S_IRWXG))
>> os.chown(".lock",pwd.getpwnam("nobody")[2],pwd.getpwnam("nobody")[3])
>>
>> but the CGI still can't delete the file.
>>
>> I will appreciate very much your help.
>>
>> Thanks a lot.
>>
>>
> How was the file created in the first place? If you don't have
> permissions to delete it you may well not have permissions to reown it
> or change its permissions either!
>
> regards
> Steve
--
http://mail.python.org/mailman/listinfo/python-list
Re: Delete a file from a CGI
Steve Holden escribió:
> Matias Surdi wrote:
>> Thanks for your reply.
>>
>> This is the code that creates the file:
>> lock_file = open(".lock","w")
>> lock_file.write("test")
>> lock_file.close()
>> #Change permissions so that CGI can write lock file
>> os.chmod(".lock",stat.S_IMODE(stat.S_IRWXU | stat.S_IRWXO |
>> stat.S_IRWXG))
>>
>> This script was run as root.
>>
>> Now, the code of the CGI that should delete the file:
>>
>> #As you see, I can write to the file
>> lock_file = open(".lock","w")
>> lock_file.write("")
>> lock_file.close()
>> # But the following line raises a "permission denied" OSError
>> os.remove(".lock")
>>
>> I've seen that the script is running as "nobody", but, the file is rwx by
>> everybody. I've also tryed changing the owner of the file to "nobody"
>> also, but no luck anyway.
>>
>> Thanks a lot.
>>
>>
>> Steve Holden wrote:
>>
>>> Matias Surdi wrote:
>>>> HI!
>>>>
>>>> I want to delete a file from a CGI, but I always get a Permission
>>>> denied error.
>>>>
>>>> I've tryed this after creating the file (from a normal script):
>>>>
>>>> os.chmod(".lock",stat.S_IMODE(stat.S_IRWXU | stat.S_IRWXO |
>>>> stat.S_IRWXG))
>>>> os.chown(".lock",pwd.getpwnam("nobody")[2],pwd.getpwnam("nobody")[3])
>>>>
>>>> but the CGI still can't delete the file.
>>>>
>>>> I will appreciate very much your help.
>>>>
>>>> Thanks a lot.
>>>>
>>>>
>>> How was the file created in the first place? If you don't have
>>> permissions to delete it you may well not have permissions to reown it
>>> or change its permissions either!
>>>
> Most likely, your problem is that to delete a file you need write
> permissions on the directory that contains it [1]. Apparently the web
> user (nobody, or apache, or whatever) doesn't have those permissions.
>
> regards
> Steve
>
> [1]: Unless the sticky bit is set on the containing directory, when
> other tests are applied instead. If this makes no sense to you, ignore it.
Hi!
I feel so s**id it's very likely to be that the problem I'll try
this next week at work.
Thanks a lot for the cold water on the face!
--
http://mail.python.org/mailman/listinfo/python-list
Getting al classes inside a package
How can I get all the clasess inside a package (including it subpackages) ? for example, I have a package with classes A and B and with a subpackage wichs has class C. How can I get a list (and a path) of the classes that exists under the root package ? Thanks a lot! -- http://mail.python.org/mailman/listinfo/python-list
Re: How does setup.py work?
dxm escribió:
> I am a new comer to python.
> I am wondering how setup.py works.
> For example, I have a directory like this:
> /
>setup.py
>mymodule.c
>
> where setup.py is:
>
> from distutils.core import setup, Extension
>
> mod = Extension('mymodule', sources = ['mymodule.c'])
>
> setup (name = 'Package',
>version = '1.0',
>description = 'This is a demo package',
>ext_modules = [mod])
>
> The correct way to install the newly created extension module is to
> type
> python setup.py install instead of executing those statements in
> python shell, isn't it ?
> My question is how additional arguments like 'build', 'install' are
> passed into python and how
> can I install it from interactively from python shell
>
Here you can read the documentation of "setuptools" , the package from
where setup.py comes.
http://peak.telecommunity.com/DevCenter/setuptools
--
http://mail.python.org/mailman/listinfo/python-list
Instrospection question
I have the following code: -- import new class A: def a(self): print "Original" def other(cad): return cad + " modified" def replace_method(method): def b(self,*args,**kwargs): result = method(*args,**kwargs) return other(result) return b a = A() setattr(a,"a",new.instancemethod(replace_method(a.a) ,a,A)) a.a() #Result should be: # Original modified -- As you can see, what I'm trying to do is "replace" a method with another one wich is the same method but with a function applied to it (in this case, a string concatenation ( +" modified")) Can anybody help me with this? -- http://mail.python.org/mailman/listinfo/python-list
Adding a HTTP header to a SOAPpy request
Hi,
Could anybody tell me which is the easier way to do a SOAP call to a web
service wich requires an http header to be present?
I can't figure it out.
Thanks a lot
Some code I'm using:
import SOAPpy
s =
SOAPpy.SOAPProxy("http://10.3.5.128:10560/SERVICES",namespace="http://ws.mysite.com";)
s.some_method()
Thanks a lot.
--
http://mail.python.org/mailman/listinfo/python-list
importing module conflict
Hi, Suppose I've a module named "urllib" and from it I need to import the urllib module from the python standart library. ¿how can I do this? The problem I found is that when I do: import urrlib The imported module is itself, and not the one from the stdlib. Any idea? Thanks a lot. -- http://mail.python.org/mailman/listinfo/python-list
Re: importing module conflict
Ben Finney escribió: > Matias Surdi <[EMAIL PROTECTED]> writes: > >> Suppose I've a module named "urllib" and from it I need to import >> the urllib module from the python standart library. > > What you want is the "absolute import" behaviour, described in PEP 328 > http://www.python.org/peps/pep-0328.html> and implemented in > Python 2.5 http://docs.python.org/whatsnew/pep-328.html>. > Thanks a lot. That was exactly what I was looking for.Excellent. -- http://mail.python.org/mailman/listinfo/python-list
mmap and shared memory
Suppose I've a process P1, which generates itself a lot of data , for example 2Mb. Then, I've a process P2 which must access P1 shared memory and, probably, modify this data. To accomplish this, I've been digging around python's mmap module, but I can't figure how to use it without files. Could anybody explain me how could this be accomplished? An example will be very appreciated. Thanks a lot for your help. -- http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED]
test -- http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED]
test -- http://mail.python.org/mailman/listinfo/python-list
Re: best set of modules for web automation without javascript
You should give a look to Selenium. It's great. http://www.openqa.org News123 wrote: Hi, I'd like to do some web automation with python 2.5 - https: - a cookiejar - some forms to be filled in what is the best set of modules. As far as I understood, there is httplib, but it seems (if I understood well) to be incoompatible with cookielib I'm a newcomer to webautomation with python and would be thankful for good suggestions. I used so far perl with LWP::UserAgent HTTP::Cookies and some module (I forgot the name) to handle parsing and filling in Forms. thanks in advance for any pointers opinions N -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: How to see the code definiton in the shell ?
Mohan Parthasarathy escribió: Hi, I am new to Python. I tried searching this but could not find an answer. In the interactive shell, I write a new function and I want to be able to see all the code that I wrote at a later time. Just typing the function name only shows >>> allmethods How do I see the actual code ? thanks mohan I think that is not possible (at least, not with the default python console and without doing introspection). Anyway, why you need to do that? Why not write down the script in a text file and run it? If you need to "run a console" inside a function so that you can inspect variables, maybe you can use: import pdb;pdb.set_trace() And that will start a debug session when gets executed. Hope that helps. -- http://mail.python.org/mailman/listinfo/python-list
Re: identifying live hosts on a network
[email protected] escribió: HI I am new to python and am having trouble coming up with a script that idenifies all the live hosts on my network. thanks Hunter I've done this in the past with the great help of nmap: # nmap -sP 192.168.0.0/23 this will find hosts "alive" from 192.168.0.1 to 192.168.1.254 From python, you can use it by saving it's output to a file and then reading or with the help of os.popen. In this case, "alive" means that the hosts with the ip being analyzed responds to ARPs. see the manpage for nmap. Matias. -- http://mail.python.org/mailman/listinfo/python-list
python ODF library?
Do yo know any good OpenDocumentFormat library for python? I'm starting a project on wich I'll have to programatically modify ODF text documments, so, after reinventing the wheel, I'd like to know if already something exists. Thanks a lot. -- http://mail.python.org/mailman/listinfo/python-list
Re: python ODF library?
Matias Surdi escribió: > Do yo know any good OpenDocumentFormat library for python? > > I'm starting a project on wich I'll have to programatically modify ODF > text documments, so, after reinventing the wheel, I'd like to know if > already something exists. > > Thanks a lot. > Found it: http://opendocumentfellowship.com/development/projects/odfpy :-) -- http://mail.python.org/mailman/listinfo/python-list
Remote mac address
Anyone knows how having the IP address of a host on the lan could I get the mac address of that hosr? p/d: Parsing the output of arp -a is not an option. Thanks a lot! -- http://mail.python.org/mailman/listinfo/python-list
Re: I just killed GIL!!!
It's april 1st again??? sturlamolden escribió: > Hello Guys... > > I just had one moment of exceptional clarity, during which realized > how I could get the GIL out of my way... It's so simple, I cannot help > wondering why nobody has thought of it before. Duh! Now I am going to > sit and and marvel at my creation for a while, and then go to bed > (it's past 2:30 a.m.) Tomorrow I will contemplate whether to sell this > little secret for big bucks, give it away for free, or just keep it to > myself... :-) > > Now you are probably thinking I reinvented the gunpowder, and are > running multiple processes. Not so. I am not running parallel > processes, like parallel python or the processing module in cheese > shop. I am running multiple THREADS. In fact, I am just using > threading.Thread. The source code is pure Python, so there is no C > magic, and I only used the stuff that's already there in the standard > library. So, I just made CPython do what everyone claim to be > impossible. One single process of CPython is using all the cpu power > of my dual-core laptop. > > > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Now what!?
Diez B. Roggisch escribió:
notbob schrieb:
Grrr
I'm following A Byte of Python and into the while loops chap. I cp/paste
while.py to a file and give 777 perms. I mv while.py to while and run
it (./while)
as a standalone script. I get errors.
Here is the script:
while.py
http://www.ibiblio.org/swaroopch/byteofpython/read/while-statement.html
When I run it as.
$ python while
.it works perfect. But, if I run it simply as.
$ ./while
.I get this:
$ ./while
number: illegal number: =
./while: line 6: running: command not found
./while: line 9: syntax error near unexpected token ('
./while: line 9: guess = int(raw_input('Enter an integer : '))'
Why does it work one way and not the other. If I run the simple hello
world
script the same way ($ ./helloworld) and it works fine. Same shebang,
same
dir, same permission, etc. I even meticulously indented everything
perfectly by hand. What am I missing?
I'm pretty sure you misse the correct shebang - the shell tries to
execute your script as shell-script, instead of invoking the interpreter.
Diez
--
http://mail.python.org/mailman/listinfo/python-list
Add #!/path/to/bin/python on the first line of your script.
Also should work with:
#!/usr/bin/env python
--
http://mail.python.org/mailman/listinfo/python-list
Re: Why is python so sad?
On Wed, Oct 14, 2009 at 2:16 PM, Chris Withers wrote: > Zac Burns wrote: > >> There are 10741 occurences of ): or :( in our source code and only 2 >> occurrences of :) or (:. Not what you would expect from a language >> named after a comedian. >> > > def ...(...): > ... > > class ...(...): > ... > > etc > > ;-) > > Chris > > Maybe we should change it to def ...(...(: ... class ...(...(: ... -- Matias, -- http://mail.python.org/mailman/listinfo/python-list
Label (or other widget) auto refresh?
Hi list... I have a question for you.. First... sorry for my english, but i speak spanish xD.. I have a little GUI made with Glade and GtkBuilder... in his gui when i click on a button i show a dialog window.. in this dialog i put a label.. this label show some value.. this value was reading from serial port. The PC is connected to a Basic Stamp (a microcontroller), the Basic Stamp write in the serial port a binary value every time when a some sensor change.. I need to show this value in the label in the dialog window at the same time when the basic stamp write to the serial port... How can i refresh the text in the label to show the change of the value every time... instantaniely? I think in a threads, but i can't get it... Thanks a lot -- Matias Hernández (Msdark) www.msdark.archlinux.cl ArchLinux-CL - WikiAdmin MSN: [email protected] Twitter : www.twitter.com/msdark Plurk : www.plurk.com/msdark Linux User: #445065 http://keys.gnupg.net/pks/lookup?op=get&search=0xEA3EEC672189419C -- http://mail.python.org/mailman/listinfo/python-list
