ldap search and Tuple

2017-04-11 Thread Alejandro Decchi
Dear,
I am writing to ask you which is the most profitable way, to get the last
uidNumber.
With ldap search create a tuple with a lot of values as follows:

('dc=xxx,dc=xxx,dc=xx', {'uid': ['pepe'], 'objectClass': ['inetOrgPerson',
'mailUser', 'shadowAccount', 'amavisAccount', 'shell', 'wiki'],'uidNumber':
['']}]

I hope you can guide me and suggest any method.

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


Bug!

2015-08-21 Thread Miguel Alejandro Fernandez
hello, python3.5rc1 when trying to install , the installer did not show the 
button to start installing , to click in the middle he started ; after 
installing I thought that everything would work fine but I could never run it, 
telling me ' this is not a valid Win32 application '

*use a computer with WindowsXP-- 
https://mail.python.org/mailman/listinfo/python-list


Package data distribution and installation

2010-10-17 Thread Alejandro Dubrovsky
I've got a script that is an executable and it reads template files that 
should be packaged with the script.  How do I tell the script where to 
find the templates?

In distutils, there's a package_data option, but that installs the 
templates under the /usr/lib/pythonX.XX/...  directory, which seems like 
the wrong directory in the unix hierarchy.  Traditionally, this kind of 
data goes under /usr/share. There's also the data_files option, but that 
can be overridden on the install command line with --install-data 
directory, and the scripts/modules don't get informed (or do they? if so, 
how?)

Googling around, people seem to write big install scripts to get around 
this, subclassing from distutils/setuptools and "manually" replacing 
certain tags in their modules with the final data directory.  Is that the 
only way to do this properly?  Is there a pre-packaged solution not in 
Python's library that takes care of it, maybe similarly to the auto-tools 
config.h.in substitution?  If so, could someone point me to it?

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


Re: Need help from someone that have PIL installed

2010-08-07 Thread alejandro

>
> Is the file, which you claim is UTF-8 encoded, actually UTF-8 encoded?
> If you're not sure, explicitly tell your text editor to save the file as
> UTF-8, and then try again.
I feel like an idiot... haven't used Python for some time... my editor was 
set for utf-8 on PHP projects and other... but somehow i forgot to set for 
py files too... thanks both of you! 


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


Re: Need help from someone that have PIL installed

2010-08-06 Thread alejandro

>
> Make sure that
>
> # encoding:utf-8
>
> is the first line of your script, details and fineprint here:
>
> http://www.python.org/dev/peps/pep-0263/
>
> Peter

Tryed that...
What was the output of my script on your computer? 


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


Re: Need help from someone that have PIL installed

2010-08-06 Thread alejandro

> # the last tuple is the background color
> img = Image.new("RGBA",(300, 50), (0, 0, 0, 0))
Thank you for this

> # I think that the PIL can cope with unicode, so add a u-prefix here:
> text = u"proba test ¾æèð¹"
> draw.text((20,8), text ,font=arial, fill="red")

Nope i gives:
SyntaxError: (unicode error) 'utf8' codec can't decode byte 0x9e in position 
0: unexpected code byte

and without the encoding :
SyntaxError: Non-ASCII character '\x9e' in file C:\Documents and 
Settings\Perc\My Documents\NetBeansProjects\venus_header\src\venus_header.py 
on line 16, but no encoding declared; see 
http://www.python.org/peps/pep-0263.html for details 


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


Need help from someone that have PIL installed

2010-08-06 Thread alejandro
Can please someone run this little script that should output characters like 
¾æè¹ð in an image.
If it does it correctly can you tell me what OS, python version & PIL 
version you have?
Or better if someone can tell me why this is not working properly on my PC? 
(Win XP, PIL 1.1.6., Python 2.6...)
I don't recive any error it's just that the characters outputed in the image 
are not characters... more like symbols...

# encoding:utf-8

from PIL import Image
import ImageDraw
import ImageFont


img = Image.new("RGBA",(250,40))

#--- making the image transparent
pixdata = img.load()

for y in xrange(img.size[1]):
for x in xrange(img.size[0]):
if pixdata[x, y] == (255, 255, 255, 255):
pixdata[x, y] = (255, 255, 255, 0)

#- drawing text
draw = ImageDraw.Draw(img)
arial = ImageFont.truetype("arial.ttf",32)  # needs path to font, my font 
was in the same folder as the script
string = "proba test ¾æèð¹"
draw.text((20,8),string ,font=arial, fill="red")

# write
img.save("img2.png", "PNG")


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


Re: Printing plain text with exact positioning on Windows

2010-01-05 Thread alejandro

Did you mean borderless printing?
Every printer needs his margins, some more some less. Some printers have the 
ability to do borderless printing but usualy they can do it only on special 
or photo paper. So you can adjust the pdf as you wish, even with no margins, 
and then try to find under printer options "borderless printing". That is 
why I didn't understand :-)) it is a printer thing not pdf! 


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


Re: Printing plain text with exact positioning on Windows

2010-01-04 Thread alejandro
I think the easyest way for printing text is with ReportLab. Just few lines 
of code and you have a nice pdf...


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


Re: mechanize module problem

2010-01-04 Thread alejandro
resolved! don't know why or how but it is...
just restared eclipse for the fourth time

"alejandro"  wrote in message 
news:hhu38i$h2...@ss408.t-com.hr...
> When I inport it wia python command line it all looks fine but if i try to 
> run it from eclipse it gives me an error that there is no package 
> mechanize. Have anybody had this situation?
> win XP
> python26
>
> 


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


mechanize module problem

2010-01-04 Thread alejandro
When I inport it wia python command line it all looks fine but if i try to 
run it from eclipse it gives me an error that there is no package mechanize. 
Have anybody had this situation?
win XP
python26


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


Re: Printing plain text with exact positioning on Windows

2010-01-04 Thread alejandro
Don't remember much.. but maybe you could play with canvas?
I think i don't undertand(i am a croatian so english is not my mother 
language). If you have the need that the pdf and the printer setup have lets 
say the same paper size, sorry but can't help.
If you want lets say different printer margins for different documents/pages 
just calculate them.
A4 is 210x297mm and you have need for a margin of 10mm..
width = 210 - margin
height = 297 - margin
now for positioning use the variables instead the absolute positioning..

i think that reportlab has some methods that alow you to position 
text/photos from the left top corner instead the normal positioning.

Don't know if I helped you in any way...

Good luck!

"KvS"  wrote in message 
news:54eb4786-5db3-453d-971a-a4b359fc2...@f5g2000yqh.googlegroups.com...
On Jan 4, 11:58 pm, "alejandro"  wrote:
> I think the easyest way for printing text is with ReportLab. Just few 
> lines
> of code and you have a nice pdf...

Ok, thanks. In that scenario I would also need to be able to
programatically adjust the printing margins in Acrobat reader, i.e.
automate it to some extent. Is that also possible? 


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


Re: Got undefined symbol: _PyUnicodeUCS2_AsDefaultEncodedString on OpenSuSE 11.1

2009-09-25 Thread Alejandro Valdez
Hello Mark, thank you a lot for your hints, I compiled python using
the --enable-unicode=ucs4 parameter in configure and I could
successfully install setuptools (Anyway I'm a little suspicious about
my compiled binaries...).

You are right about the environment variables, I have set PYTHONPATH
and PYTHONHOME to:
PYTHONPATH=$HOME/python/lib/python2.6/site-packages
PYTHONHOME=$HOME/python

The compiler issued some warnings, two of them (related to Unicode)
called my attention:

In file included from Python/formatter_unicode.c:13:
Python/../Objects/stringlib/formatter.h: In function
‘unknown_presentation_type’:
Python/../Objects/stringlib/formatter.h:35: warning: format ‘%c’
expects type ‘int’, but argument 3 has type ‘Py_UNICODE’

Should I ignore them?




Other warning messages:

libpython2.6.a(posixmodule.o): In function `posix_tmpnam':
/home/mailstat/Python-2.6.2/./Modules/posixmodule.c:7129: warning: the
use of `tmpnam_r' is dangerous, better use `mkstemp'
libpython2.6.a(posixmodule.o): In function `posix_tempnam':
/home/mailstat/Python-2.6.2/./Modules/posixmodule.c:7084: warning: the
use of `tempnam' is dangerous, better use `mkstemp'
/home/mailstat/Python-2.6.2/Modules/_struct.c:187: warning:
‘get_ulong’ defined but not used
/home/mailstat/Python-2.6.2/Modules/_cursesmodule.c: In function
‘PyCurses_getsyx’:
/home/mailstat/Python-2.6.2/Modules/_cursesmodule.c:1766: warning:
‘y’ may be used uninitialized in this function
/home/mailstat/Python-2.6.2/Modules/_cursesmodule.c:1766: warning:
‘x’ may be used uninitialized in this function

On Fri, Sep 25, 2009 at 3:56 PM, Mark Dickinson  wrote:
> On Sep 25, 7:05 pm, Alejandro Valdez 
> wrote:
>> Hello I sent this e-mail to the python-help list but I'm not sure if
>> that list is active... so I post it again here:
>>
>> I'm trying to build Python 2.6.2 from the sources downloaded from the
>> python official site on OpenSuSE 11.1 (32 bit). After installation the
>> python command line interpreter seems to run ok, but when I try to
>> install setuptools I get:
>> [...]
>> To compile Python I executed:
>>
>> ./configure --prefix=/home/user/python
>> ./make
>> ./make install
>>
>> The compile process seems to be ok, so I'm kind of clueless :-(
>>
>> Any ideas?
>
> This is just a guess, but try configuring with:
>
> ./configure --enable-unicode=ucs4 --prefix=/home/user/python
>
> On Linux, by default, a self-compiled Python uses UCS2
> internally for its unicode support (with some support
> for UTF16).  Most Linux distributions, however, distribute
> a Python that uses UCS4 (aka UTF32) instead, so it seems
> possible that your setuptools egg is expecting to find a
> UCS4 build.
>
> Mark
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Got undefined symbol: _PyUnicodeUCS2_AsDefaultEncodedString on OpenSuSE 11.1

2009-09-25 Thread Alejandro Valdez
Hello I sent this e-mail to the python-help list but I'm not sure if
that list is active... so I post it again here:

I'm trying to build Python 2.6.2 from the sources downloaded from the
python official site on OpenSuSE 11.1 (32 bit). After installation the
python command line interpreter seems to run ok, but when I try to
install setuptools I get:

u...@linux-ba2a:~/tmp> bash setuptools-0.6c9-py2.6.egg
--install-dir=/home/user/python/lib/python2.6/site-packages/
Traceback (most recent call last):
 File "", line 1, in 
 File 
"/home/user/tmp/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py",
line 15, in 
 File "/home/user/tmp/setuptools-0.6c9-py2.6.egg/setuptools/sandbox.py",
line 1, in 
ImportError: /home/user/python/lib/python2.6/lib-dynload/operator.so:
undefined symbol: _PyUnicodeUCS2_AsDefaultEncodedString


To compile Python I executed:

./configure --prefix=/home/user/python
./make
./make install

The compile process seems to be ok, so I'm kind of clueless :-(

Any ideas?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Natural Language Processing in Python

2009-08-15 Thread Alejandro E. Ciniglio
nltk is a good start, we used it in my Computational Linguistics course 
in school.

www.nltk.org

--Alejandro

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


Is there any module for sea tides?

2009-05-31 Thread alejandro
I found some in C but could not find in Python 


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


WinAppDbg module v1.1 is out!

2009-05-15 Thread Mario Alejandro Vilas Jerez
What is WinAppDbg?
==

The WinAppDbg python module allows developers to quickly code
instrumentation
scripts in Python under a Windows environment.

It uses ctypes to wrap many Win32 API calls related to debugging, and
provides
an object-oriented abstraction layer to manipulate threads, libraries and
processes, attach your script as a debugger, trace execution, hook API
calls,
handle events in your debugee and set breakpoints of different kinds (code,
hardware and memory). Additionally it has no native code at all, making it
easier to maintain or modify than other debuggers on Windows.

The intended audience are QA engineers and software security auditors
wishing to
test / fuzz Windows applications with quickly coded Python scripts. Several
ready to use utilities are shipped and can be used for this purposes.

Current features also include disassembling x86 native code (using the open
source diStorm project, see http://ragestorm.net/distorm/), debugging
multiple
processes simultaneously and produce a detailed log of application crashes,
useful for fuzzing and automated testing.


Where can I find WinAppDbg?
===

The WinAppDbg project is currently hosted at Sourceforge, and can be found
at:

http://winappdbg.sourceforge.net/

It's also hosted at the Python Package Index (PyPi):

http://pypi.python.org/pypi/winappdbg/1.1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: stuck with PyOBEX

2009-05-05 Thread alejandro
Ejla! I have sent you a mail (in case you check it often like me :-))

"David Boddie"  wrote in message 
news:gtkhdr$ob...@get-news01.get.basefarm.net...
> On Sunday 03 May 2009 10:33, alejandro wrote:
>
>> Yes!
>>
>>> I'll send you an updated version to try if you would like to test it.
>
> My mails to you keep getting returned, so I've put it here:
>
> http://www.boddie.org.uk/david/Projects/Python/PyOBEX/Software/PyOBEX-0.21.zip
>
> Please let me know if it works on Windows, and feel free to get in touch 
> if
> you have any problems.
>
> David 


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


Re: stuck with PyOBEX

2009-05-03 Thread alejandro
Yes!

> I haven't tried to run it under Windows. I just assumed that 
> BluetoothSocket
> would have the same API on both Linux and Windows.
>
> Looking around, it seems that this is something we can work around:
>
> http://svn.navi.cx/misc/trunk/laserprop/client/BluetoothConduit.py
>
> I'll send you an updated version to try if you would like to test it.
>
> David 


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


Re: stuck with PyOBEX

2009-05-02 Thread alejandro
I am having problems with connect() it says that it doesn't have sendall 
atribute.

Error:

Traceback (most recent call last):
  File "novi_pokusaj.py", line 25, in 
client.connect()
  File "C:\Python25\lib\PyOBEX\client.py", line 356, in connect
return Client.connect(self, header_list = [headers.Target(uuid)])
  File "C:\Python25\lib\PyOBEX\client.py", line 127, in connect
response = self._send_headers(request, header_list, max_length)
  File "C:\Python25\lib\PyOBEX\client.py", line 81, in _send_headers
self.socket.sendall(request.encode())
AttributeError: BluetoothSocket instance has no attribute 'sendall'>>> Exit 
Code: 1


Did you manage to run it under windows? 


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


Re: stuck with PyOBEX

2009-04-28 Thread alejandro
So I should connect trough pybluez and send with obex??

"David Boddie"  wrote in message 
news:gt80qd$mb...@get-news01.get.basefarm.net...
> On Tuesday 28 April 2009 18:34, Diez B. Roggisch wrote:
>
>>> This module asks the socket module for AF_BLUETOOTH... in the socket
>>> module there is no such thing as AF_BLUETOOTH. Could it be that the
>>> person that made PyOBEX modified his socket module and forgot to give 
>>> his
>>> socket module? Or am I missing something? Maybe AF_BLUETOOTH stands for
>>> something that a programmer would know but I am a beginner so...
>>>
>>> Is there a OBEX module for Python on windows?
>>
>> AF_BLUETOOTH seems to be specific to *nix-systems. At least under debian
>> and ubuntu, I've got it defined.
>
> Yes, it appears to be compiled into the socket module if the relevant
> Bluetooth library (libbluetooth) and header file (bluetooth.h) were
> available when Python was built.
>
>> So it seems it is not supported under windows - you should consider the
>> author if that's a mistake, or by design.
>
> By design, though a previous, unreleased version used the bluetooth module
> provided by PyBluez (http://code.google.com/p/pybluez/) which contains its
> own BluetoothSocket class before I released that the socket module could
> also support Bluetooth sockets.
>
> I guess I could change the package to use BluetoothSocket if Bluetooth
> support isn't provided by the user's socket module.
>
> David 


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


Re: stuck with PyOBEX

2009-04-28 Thread alejandro
The problem with Pybluez is that the module serves only to get the 
addresses, ports, protocols... that the device uses but can't send or recive 
files. So I am stuck again :-(
Maybe I should use dll-s and again another thing to learn... :-) 


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


Re: stuck with PyOBEX

2009-04-28 Thread alejandro
Can you tell me what is it? Maybe I can search it and pass it in another 
way... if it is an address or protocol name

> AF_BLUETOOTH seems to be specific to *nix-systems. At least under debian 
> and
> ubuntu, I've got it defined.
>
> So it seems it is not supported under windows - you should consider the
> author if that's a mistake, or by design.
>
> Diez 


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


stuck with PyOBEX

2009-04-28 Thread alejandro
So I installed the module and tryed to make it work but...
It gave me:

Traceback (most recent call last):
  File "first.py", line 24, in 
client2.connect()
  File "C:\Python25\lib\PyOBEX\client.py", line 359, in connect
return Client.connect(self, header_list = [headers.Target(uuid)])
  File "C:\Python25\lib\PyOBEX\client.py", line 119, in connect
self.socket = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM,
AttributeError: 'module' object has no attribute 'AF_BLUETOOTH'>>> Exit 
Code: 1


This module asks the socket module for AF_BLUETOOTH... in the socket module 
there is no such thing as AF_BLUETOOTH. Could it be that the person that 
made PyOBEX modified his socket module and forgot to give his socket module? 
Or am I missing something? Maybe AF_BLUETOOTH stands for something that a 
programmer would know but I am a beginner so...

Is there a OBEX module for Python on windows?


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


Python winappdbg module v1.0 is out!

2009-04-21 Thread Mario Alejandro Vilas Jerez
What is winappdbg?
==

The winappdbg python module allows developers to quickly code
instrumentation scripts in Python under a Windows environment.

It uses ctypes to wrap many Win32 API calls related to debugging, and
provides an object-oriented abstraction layer to manipulate threads,
libraries and processes, attach your script as a debugger, trace
execution, hook API calls, handle events in your debugee and set
breakpoints of different kinds (code, hardware and memory).
Additionally it has no native code at all, making it easier to
maintain or modify than other debuggers on Windows.

The intended audience are QA engineers and software security auditors
wishing to test / fuzz Windows applications with quickly coded Python
scripts. Several ready to use utilities are shipped and can be used
for this purposes.

Current features also include disassembling x86 native code (using the
open source diStorm project, see http://ragestorm.net/distorm/),
debugging multiple processes simultaneously and produce a detailed log
of application crashes, useful for fuzzing and automated testing.


Where can I find winappdbg?
===

The winappdbg project is currently hosted at Sourceforge, and can be found at:

    http://winappdbg.sourceforge.net/
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to create an unclosed dialog in wxPython?

2009-04-18 Thread alejandro
Don't press alt+f4?

"??"  wrote in message 
news:719e6773-bad0-46ff-9842-a7ade2ced...@f41g2000pra.googlegroups.com...
> In wxPython, after I create a wx.Frame, I want to create a modeless
> and unclosed dialog. Here is my step:
>
> app = wx.PySimpleApp()
> f = wx.Frame(None, -1, "Test")
> d = wx.Dialog(f, -1, "Test Dialog", style = wx.CAPTION)
> f.Show()
> d.Show()
> app.MainLoop()
>
> As you see, I create a dialog with wx.CAPTION style. And than, there
> is no close button in this dialog. It seems unclosed dialog, but in
> fact, if you enter Alt+F4 in this dialog, it will close. How could I
> do?
> 


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


Re: show PDF in wxPython?

2009-04-15 Thread alejandro
Thank you both! 


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


show PDF in wxPython?

2009-04-14 Thread alejandro
I would like to import a pdf in a wxPython widget, but didn't find any 
solution. The imported PDF should work like if it were open in IE or 
Mozilla... Sugestions? Solutions?



P.S.
I would like to thank Dennis Lee Bieber for the help about parallel ports... 
I forgot to do it :-( 


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


Re: Anyone mannaged to access parallel port on windows xp?

2009-04-07 Thread alejandro
Now it doesn't throw exceptions but it doesn't work. I tryed to connect a 
LED light to the port and it wan't glow. Do you know a way to check if the 
port work?


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


Re: Anyone mannaged to access parallel port on windows xp?

2009-04-07 Thread alejandro
Yes that module is the one to blame for my headache! :-))

> Have you tried http://pyserial.wiki.sourceforge.net/pyParallel ?
>
> Cheers,
> Daniel
>
> -- 
> Psss, psss, put it down! - http://www.cafepress.com/putitdown 


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


Re: Anyone mannaged to access parallel port on windows xp?

2009-04-07 Thread alejandro
I have a PC at work and at home. I wanted to write the errors it throws out 
when i try to use the module but now it work on this PC(the one at work). I 
don't get it?!?! I tryed so many things and now I can't remember what I have 
done :-))) This is worse than before!
I will post the errors when i get home.
Thanks for the reply! 


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


Anyone mannaged to access parallel port on windows xp?

2009-04-06 Thread alejandro
I have a switch  that I should connect to the parallel port, but had no luck 
with it. Tha guy that made it for me told me that it would be easyer to 
connect via parallel instead the USB
So did anyone have success? I only get suckess!! :-))
tryed giveio.sys but it doesn't wort (can't figure out what is it) 


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


control device via USB or Parallel

2009-03-27 Thread alejandro
Some guy will make switches that can be controlled via USB or parallel, he 
told me that I can chose which connection I want. So, are there any modules 
for Python that will allow me to control some switches via USB or parallel? 


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


Re: control device via USB or Parallel

2009-03-26 Thread alejandro
I just cant install it. Here is 1 in the morning.
Do I have to do all that it says on the webpage?
http://libusb-win32.sourceforge.net/


"miki"  wrote in message 
news:3580d70f-3b11-4a56-abeb-9284b4012...@f1g2000prb.googlegroups.com...
On Mar 26, 3:43 pm, "alejandro"  wrote:
> Some guy will make switches that can be controlled via USB or parallel, he
> told me that I can chose which connection I want. So, are there any 
> modules
> for Python that will allow me to control some switches via USB or 
> parallel?

For parallel port there is pyparallel, however IMO their time is gone
and you should go with pyusb.

HTH,
--
Miki 
http://pythonwise.blogspot.com 


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


Is there any library for COREL or ILLUSTRATOR?

2009-03-19 Thread alejandro
I need to import cdr files to python and just make some calculations 
(surface size of some objects, perimeters..)
Don't need to show them or manipulate with them... 


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


wxPython text alignment again

2009-03-09 Thread alejandro
I managed to align the text to the right but when I change it with a 
function it gets messy
What is wrong now?


class OpcijeFolija(wx.Dialog):
def __init__(self, parent, id, title):
wx.Dialog.__init__(self,parent, id, title, size=(300,300))
foli=cPickle.load(file("folije.data"))
sizer = wx.GridBagSizer(5, 9)
#-- dropdown

self.combo = wx.ComboBox(self, 10, pos=(20,20), size=(150,-1), 
choices=foli,style=wx.CB_READONLY)
self.Bind(wx.EVT_COMBOBOX, self.OnSelect, id=10)

#--text
sizer.Add(wx.StaticText(self,-1,'Sirina role'),(2,1),(1,1))
sizer.Add(wx.StaticText(self,-1,'Naziv folije'),(3,1),(1,1))
sizer.Add(wx.StaticText(self,-1,'Cijena po duznom 
metru'),(4,1),(1,1))
#--text izmjenjivi
self.sirina = wx.StaticText(self,-1,'something')
sizer.Add((self.sirina),(2,4),(1,1),wx.ALIGN_RIGHT)
self.ime = wx.StaticText(self,-1,'someth')
sizer.Add((self.ime),(3,4),(1,1),wx.ALIGN_RIGHT)
self.cina = wx.StaticText(self,-1,'som')
sizer.Add((self.cina),(4,4),(1,1),wx.ALIGN_RIGHT)
self.SetSizer(sizer)
#self.Centre()

#-- botuni
wx.Button(self,1,'Novi unos',(20,200), size=(80,20))
wx.Button(self, 2,'Izbrisi',(110,200), size=(80,20))
wx.Button(self, 3, 'Zatvori',(200,200),size=(80,20))
self.Bind(wx.EVT_BUTTON, self.OnClose, id=3)

def OnClose(self, event):
self.Close()

def OnSelect(self, event):
redBr = self.combo.GetCurrentSelection()
sirinaFajl = cPickle.load(file("sirina.data"))
imeFajl = cPickle.load(file("folije.data"))
cijenaDuzinaFajl = cPickle.load(file("duzina.data"))

self.sirina.SetLabel(str(sirinaFajl[redBr]))
self.ime.SetLabel(str(imeFajl[redBr]))
self.cina.SetLabel(str(cijenaDuzinaFajl[redBr])) 


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


Re: Problem with text alignment

2009-03-04 Thread alejandro

>> self.sirina = wx.StaticText(self,-1,'Some text that\n will be alignet 
>> \nat the right',(200,50),style=wx.ALIGN_RIGHT)
#- this would be an example, the reason I didnt understand 
is that I used just one line of text





I understand now. Can I align it on the right withot using sizers? 


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


Problem with text alignment

2009-03-04 Thread alejandro

I can't align the text on the right in my wxDialog.
Everything else works fine


self.sirina = wx.StaticText(self,-1,'',(200,50),style=wx.ALIGN_RIGHT)



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


Re: Problem with text alignment

2009-03-04 Thread alejandro
Here is the whole dialog:

class OpcijeFolija(wx.Dialog):
def __init__(self, parent, id, title):
wx.Dialog.__init__(self,parent, id, title, size=(300,300))
foli=cPickle.load(file("folije.data"))
#-- dropdown
self.combo = wx.ComboBox(self, 10, pos=(20,20), size=(150,-1),
choices=foli,style=wx.CB_READONLY)
self.Bind(wx.EVT_COMBOBOX, self.OnSelect, id=10)

#--text
wx.StaticText(self,-1,'Sirina role',(20,50))
wx.StaticText(self,-1,'Naziv folije',(20,80))
wx.StaticText(self,-1,'Cijena po duznom metru',(20,110))
#--text izmjenjivi
self.sirina =
wx.StaticText(self,-1,'',(200,50),style=wx.ALIGN_RIGHT)
self.ime = wx.StaticText(self,-1,'',(200,80),style=wx.ALIGN_RIGHT)
self.cina = wx.StaticText(self,-1,'',(200,110),style=wx.ALIGN_RIGHT)

self.Centre()

#-- botuni
wx.Button(self,1,'Novi unos',(20,200), size=(80,20))
wx.Button(self, 2,'Izbrisi',(110,200), size=(80,20))
wx.Button(self, 3, 'Zatvori',(200,200),size=(80,20))
self.Bind(wx.EVT_BUTTON, self.OnClose, id=3)

def OnClose(self, event):
self.Close()

def OnSelect(self, event):
redBr = self.combo.GetCurrentSelection()
sirinaFajl = cPickle.load(file("sirina.data"))
imeFajl = cPickle.load(file("folije.data"))
cijenaDuzinaFajl = cPickle.load(file("duzina.data"))

self.sirina.SetLabel(str(sirinaFajl[redBr]))
self.ime.SetLabel(str(imeFajl[redBr]))
self.cina.SetLabel(str(cijenaDuzinaFajl[redBr]))



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


Re: wxPython and Croatian characters

2009-02-16 Thread alejandro
Provjeri da si nisi stavio ansii kada si instalirao wx.python.
Mozes probat ubacit iznad svega u fajlu komentar u kojem pise da je fajl u 
UTF-8 i onda bi ti trebalo sljakat. Nadem sutra pa ti posaljem 


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


Re: Get thread pid

2009-02-02 Thread Alejandro
On Feb 2, 3:01 am, Ove Svensson  wrote:
> If you find a way to get to the real TID, that will be specific to
> your architecture.
>
> If htop (or any other application) returns a TID, that is either
> artificial or architecture specific.

Right know I only need the TID for debugging under Linux. I will keep
this information in mind though.

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


Re: Get thread pid

2009-02-01 Thread Alejandro
On Jan 30, 1:40 pm, Christian Heimes  wrote:
> May I ask why you want to get the TID?

htop shows the TID of each thread. Knowing the TID allows me to know
which thread is hogging the CPU. If there is a better way to do this,
or there is something fundamentally wrong with this approach, please
let me know.

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


Re: Get thread pid

2009-02-01 Thread Alejandro
On Jan 30, 10:10 am, Jean-Paul Calderone  wrote:
>     >>> ctypes.CDLL('libc.so.6').syscall(224)

Great! ctypes.CDLL('libc.so.6').syscall(224) does the trick. Thank
you.

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


Re: Get thread pid

2009-01-30 Thread Alejandro
On Jan 30, 9:11 am, Jean-Paul Calderone  wrote:
> [clarification about threads]

Thank you for the clarification. I will reformulate my question:

pstree and also ntop (but not top) show a number for each thread, like
for instance:

$pstree -p 9197
python(9197)€ˆ€{python}(9555)
 †€{python}(9556)
 †€{python}(9557)
 †€{python}(9558)
 †€{python}(9559)
 †€{python}(9560)
 †€{python}(9561)
 †€{python}(9562)
 †€{python}(9563)
 „€{python}(9564)

Is is possible to get the number corresponding to each thread?

The reason I am interested is because one of my thread is hogging the
CPU, and want to find which one is the culprit.

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


Re: Get thread pid

2009-01-30 Thread Alejandro
On Jan 30, 4:00 am, Ove Svensson  wrote:
> Pidis a process identifier. Threads are not processes. All your threads
> execute within the context if a single process, hence they should have
> the samepid. Threads may have athreadid but it is not the same as thepid.

According to this document (http://heather.cs.ucdavis.edu/~matloff/
Python/PyThreads.pdf), at least in Linux, threads are process:

"Here each thread really is a process, and for example will show up on
Unix systems when one runs the appropriate ps process-list command,
say ps axH. The threads manager is then the OS."

If you look at my original post, pstree does show different PIDs for
the threads.

Regards,
Alejandro.




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


Get thread pid

2009-01-29 Thread Alejandro
Hi:

I have Python program running under Linux, that create several
threads, and I want to now the corresponding PID of the threads.

In each of the threads I have

def run(self):
pid = os.getpid()
logger.critical('process ID: %s', pid)

However, the reported PID is the father number, not the PID of the new
thread. Is there a way to get the PID of the thread?

To illustrate this further, this is the output of pstree when the PID
of the main Python thread is 9197:

$pstree -p 9197
python(9197)─┬─{python}(9555)
 ├─{python}(9556)
 ├─{python}(9557)
 ├─{python}(9558)
 ├─{python}(9559)
 ├─{python}(9560)
 ├─{python}(9561)
 ├─{python}(9562)
 ├─{python}(9563)
 └─{python}(9564

I want each thread to report its PID number, in this case 9555, 9556,
etc., but with os.getpid() is get 9197.

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


Finding multiple of a decimal number in a floating point list

2008-08-18 Thread Alejandro
Hi:

I need to find the multiples of a decimal number in a floating point
list. For instance, if a have the list [0,0.01,0.02,...1], I want the
multiples of 0.2: [0, 0.2,0.4,0.6,0.8,1].

With integers this problem is easy, just test for (i%n == 0), where i
is the number I am testing, and n is the multiple. Given the finite
resolution of floating point numbers, this is more complicated for
float.

I came with this solution:

from numpy import arange
from math import modf, fabs

float_range = arange(0, 1, 0.01)
for f in float_range:
m = modf(f / 0.2)[0]
if m<1e-13 or fabs(1-m)<1e-13:
print f
# Do something else

This code works, however, I found it a little ugly. Is there a better
way to do the same?

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


exec and closures

2008-02-21 Thread Alejandro Dubrovsky
About a month ago, there was a thread on auto-assigning decorators for 
__init__.  One by André Roberge is here:
http://groups.google.com/group/comp.lang.python/browse_frm/
thread/32b421bbe6caaeed/0bcd17b1fa4fb07c?#0bcd17b1fa4fb07c

This works well for simple cases, but doesn't take keyword arguments or 
set default values.  I wrote a more extensive version implementing python 
call semantics, but it seemed awkard to be repeating something the 
compiler does already, so I tried execing a function definition on the 
fly with the right parameters that would function as the decorator.  Like 
this  (adjust the indentation variable if it throws a syntax error)

def autoassign(_init_):
import inspect
import functools

argnames, _, _, defaults = inspect.getargspec(_init_)
argnames = argnames[1:]

indentation = ''
settings = ['self.%s = %s' % (arg[1:], arg) for arg in argnames 
if arg[0] == '_']

if len(settings) <= 0:
return _init_

if defaults is None:
args = argnames[:]
else:
args = argnames[:-len(defaults)]
for key, value in zip(argnames[-len(defaults):],defaults):
args.append('%s=%s' % (key, repr(value)))

template = """def _autoassign(self, %(args)s):
%(setting)s
_init_(self, %(argnames)s)
""" % {'args' : ", ".join(args), 'setting' : "\n".join(['%s%s' % 
(indentation, setting) for setting
in settings]), 'argnames' : ', '.join(argnames)}

try:
exec template
except SyntaxError, e:
raise SyntaxError('%s. line: %s. offset %s:\n%s' % 
(e.msg, e.lineno, e.offset, template))
return _autoassign


Which creates what looked like the right template, but when instantiating 
a class that uses that (eg
class A(object):
@autoassign
def __init__(self,_a):
pass
a = A(3)

it throws a
NameError: global name '_init_' is not defined

Is there a way to bind the _init_ name at exec time?

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

How to modify the content of an email

2008-01-25 Thread alejandro . valdez
Hello, I'm trying to make a python script that take an email in (raw)
text format, and add a footer to the text (or html) body of the email.

I'm aware of the email and email.mime modules, but I can't figure out
how to identify 'the main text (or html) content' from the email, and
how to be sure that I don't incorrectly identify a txt (or html)
attach as the main content of the email.

By 'main text (or html) content' I mean the text (or html) that is
showed by a Mail User Agent when it display the email to the
recipient.

Thanks in advance.

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


Help search files

2007-07-04 Thread Alejandro Decchi

Hello Someone can help me how to search file in a directory. I need to do a
form where the user write the word to search and if the file was found the
user must could download the file making click in the link
Sorry my english
thz
Alex
-- 
http://mail.python.org/mailman/listinfo/python-list

help search file

2007-06-30 Thread Alejandro Decchi

Hello Python user.
I am a newbie with python and i am interesting to do a web apliation to
search file on the hard disk and give a link to download the file found.
Someone can give a help ???
Thz
Ale
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: wxpython: Redirect the stdout to a textctrl

2007-06-20 Thread Alejandro
On Jun 19, 5:07 pm, [EMAIL PROTECTED] wrote:
> Give this a try:
>
> 
 [good piece of code]
> 

It worked like a charm! Thanks.

I still don't understand why my initial aproach didn't work as
expected.

Regards,
Alejandro.


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


wxpython: Redirect the stdout to a textctrl

2007-06-19 Thread Alejandro
Hi:

I want to redirect stdout to a textctrl I have. From what I read in
the wxpython documentation, I can use the wxLogTextCtrl class to do
this. I am doing the following:

class MyGui(gui.MyFrame):  #gui.MyFrame generated by wxGlade
def __init__(self, *args, **kwds):
gui.MyFrame.__init__(self, *args, **kwds)
# ... code removed ...
wx.Log_SetActiveTarget(wx.LogTextCtrl(self.text_ctrl_2))
print 'foo' #to test the redirection

if __name__ == "__main__":
app = wx.App(redirect=wx.LogTextCtrl)
wx.InitAllImageHandlers()
gui = MyGui(None, -1, "")
app.SetTopWindow(gui)
gui.Show()
app.MainLoop()

However, the output instead of going to my textctrl, goes to a new
window named "xwPython: stdout/stderr".

What am I missing?

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


Re: making objects with individual attributes!

2007-03-20 Thread Alejandro
Thanks to all!!! Now it works!

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


making objects with individual attributes!

2007-03-20 Thread Alejandro
I have created a class:

class document:

titre = ''
haveWords = set()

def __init__(self, string):

self.titre = string

#

doc1 = document('doc1')
doc2 = document('doc2')

doc1.haveWords.add(1)
doc2.haveWords.add(2)


print doc1.haveWords

# i get set([1, 2])


doc1 and doc are sharing attribute haveWords!
Why ??? there's a way to assign every objetc "document" a different
"set"

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


Re: Regex Speed

2007-02-20 Thread Alejandro Dubrovsky
Steve Holden wrote:

> John Machin wrote:
> [...]
>> 
>> To help you, we need either (a) basic information or (b) crystal
>> balls.
> [...]
> 
> How on earth would having glass testicles help us help him?
> 

John, of course, meant spheres of doped single crystal silicon on which we
could simulate all the specific coding problems for which all possible
values of garrickp would have posted the message that he/she/it did, then
solve them by descending order of likelyhood till garrickp emitted a "That
solves it, thanks!" 


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


Re: Regex Speed

2007-02-20 Thread Alejandro Dubrovsky
[EMAIL PROTECTED] wrote:

> While creating a log parser for fairly large logs, we have run into an
> issue where the time to process was relatively unacceptable (upwards
> of 5 minutes for 1-2 million lines of logs). In contrast, using the
> Linux tool grep would complete the same search in a matter of seconds.
> 
> The search we used was a regex of 6 elements "or"ed together, with an
> exclusionary set of ~3 elements. Due to the size of the files, we
> decided to run these line by line, and due to the need of regex
> expressions, we could not use more traditional string find methods.

Just guessing (since I haven't tested this), switching from doing it line by
line to big chunks (whatever will fit in memory) at a time would help, but
I don't think you can get close to the speed of grep  (eg 
while True:
chunk = thefile.read(1))
if not len(chunk): break
for x in theRE.findall(chunk):
.  
)
Function calls in python are expensive.



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


Re: Inheriting str object

2007-02-06 Thread Alejandro Barroso
On 5 feb, 11:48, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> I want to have a str with custom methods, but I have this problem:
>
> class myStr(str):
> def hello(self):
> return 'hello '+self
>
> s=myStr('world')
> print s.hello() # prints 'hello world'
> s=s.upper()
> print s.hello() # expected to print 'hello WORLD', but s is no longer
> myStr, it's a regular str!
>
> What can I do?

I'm new to this list(this is my first message) and to Python also (I'm
learning these days),  so i'm afraid that this is not what you are
asking for but anyway

you can create an myStr object on the fly, something like:
s=myStr(s.upper())

Alex

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


Re: "Correct" db adapter

2007-02-01 Thread Alejandro Dubrovsky
Bruno Desthuilliers wrote:

> king kikapu a écrit :
>> Thanks for the replies.
>> 
>> I think i do not need something like ORM, but just a db-module that i
>> can "work" the database with it.
> 
> FWIW, SQLAlchemy is not an ORM, but an higher-level API for SQL
> integration. The ORM part is an optional feature built on top of this
> API. But I'm not sure SQLAlchemy supports SQL Server anyway !-)
> 
>> I just want to know if pyodbc is the "correct" solution to do so or if
>> it is another db-module that is more
>> usefull for this job.
> 
> AFAICT:
> 
> * there's an experimental MS SQL Server db-module:
> http://www.object-craft.com.au/projects/mssql/
> 
> * the Win32 extensions offers support for ADO, but then it's not db-api
> compliant
> 
> * unless you use adodbapi, but I don't know if it's still supported
> (last release is 3+ years old):
> http://adodbapi.sourceforge.net/
> 
> HTH

There's also pymssql  which works well
enough most of the time.

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


Re: How can I write code using FP

2007-01-16 Thread Alejandro Dubrovsky
kernel1983 wrote:

> In Function Program?Language can use like this:
> 
> define a function:
> f = lambda x,y:x,y
> 
> then we use f to define another function:
> f2 = f(1)
> the f2 should equal to:
> f2=lambda y:1,y
> 
> we should be able call f2 with one parameter:f2(2)
> just return 1,2
> 
> but how can I implement the characteristic in Python??I think it could
> do like this but HOW-TO?

If you are using python 2.5, then you can use functools.partial, otherwise
lookup one of the many curry implementations, like the ones found in
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52549

One found in the comments of that page by Scott David Daniels:

def curry(*args, **kwargs):
function, args = args[0], args[1:]
def result(*rest, **kwrest):
combined = kwargs.copy()
combined.update(kwrest)
return function(*args + rest, **combined)
return result


so, in your case:

f = lambda x,y: (x,y)
f2 = functools.partial(f,1)
>>> f2(3)
1,3

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


Re: urllib2 through basic auth'ed proxy

2006-04-02 Thread Alejandro Dubrovsky
John J. Lee wrote:

> [EMAIL PROTECTED] (John J. Lee) writes:
> 
>> Alejandro Dubrovsky <[EMAIL PROTECTED]> writes:
> [...Alejandro complains about non-working HTTP proxy auth in urllib2...]
> 
> [...John notes urllib2 bug...]
>> A workaround is to supply a stupid HTTPPasswordMgr that always returns
>> the proxy credentials regardless of what the handler asks it for (only
>> tested with a perhaps-broken 2.5 install, since I've broken my 2.4
>> install):
> [...snip ugly code]
>> Yuck, yuck, yuck!  I had realised the auth/proxies code in urllib2 was
>> buggy, but...  And all those hoops to jump through.
>> 
>> Also, if you're using 2.5 SVN HEAD, it seems revision 42133 broke
>> ProxyHandler in an attempt to fix the URL host:post syntax!
> [...]
> 
> In fact the following also works with Python 2.3.4:
> 
> import urllib2
> proxy_handler = urllib2.ProxyHandler({"http":
> "http://john:[EMAIL PROTECTED]:3128"}) print
> urllib2.build_opener(proxy_handler).open('http://python.org/').read()
> 
It does too.  Thanks again. (I think this version is uglier, but easier to
insert into third party code)


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


Re: urllib2 through basic auth'ed proxy

2006-03-30 Thread Alejandro Dubrovsky
John J. Lee wrote:

> FWIW, at a glance, Python 2.3.4 has neither of the bugs I mentioned,
> but the code I posted seems to work with 2.3.4.  I'm not particularly
> interested in what's wrong with 2.3.4's version or your usage of it
> (probably both), since bugfix releases for 2.3 are no longer
> happening, I believe.
> 

"ah, yes, that works" on 2.3.4.  Excellent.  (I don't see what's so ugly
about that code, but i'm mostly accustomed to my own)
Thanks,
alejandro


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


Re: pySerial: write in a blocking mode

2006-03-29 Thread Alejandro

Peter Hansen wrote:
>  Alejandro wrote:
>  >
>  > Yes. The device is very simple (I made it).
>
> Perhaps a very simple change to it would make it as convenient as the
> commercial products.  I vaguely recall (not having checked for over a
> decade) that all they do is set the outgoing DTR line whenever there is
> data being transmitted by the PC, by using something like a 555 timer
> with a very short delay (effectively watching the start bit and any zero
> bits that are transmitted).  There are probably even example circuits
> based on this or better approaches available on the net.

You are right. For instance, the 485COSR converter, from B&B
electronics, does precisely that. The schematic is in the datasheet
(http://tinyurl.com/ro6qy).

I will try this route.

Thanks for the help.

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


urllib2 through basic auth'ed proxy

2006-03-29 Thread Alejandro Dubrovsky
I see from googling around that this is a popular topic, but I haven't seen
anyone saying "ah, yes, that works", so here it goes.

How does one connect through a proxy which requires basic authorisation?
The following code, stolen from somewhere, fails with a 407:

proxy_handler = urllib2.ProxyHandler({"http" :
"http://the.proxy.address:3128"})
proxy_auth_handler = urllib2.ProxyBasicAuthHandler()
proxy_auth_handler.add_password("The name of the realm sniffed from
telnetting to the proxy and doing a
get",'the.proxy.address','theusername','thepassword')
opener = urllib2.build_opener(proxy_handler, proxy_auth_handler)
urllib2.install_opener(opener)
f = urllib2.urlopen('http://www.google.com/')


I still get a 407 if I set the realm to None, I change host to the
'http://the.proxy.address/' form or even 'http://the.proxy.address:3128'
form.

The proxy is squid.  Python version is 2.3.4 (I read that this version has a
problem in that it introduces an extra return after the authorisation, but
it isn't even getting to that bit). And yes, going through firefox,
everything works fine.

Can anyone explain me why this fails, or more importantly, code that would
work? 

Thanks,
alejandro





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


Re: pySerial: write in a blocking mode

2006-03-28 Thread Alejandro

Peter Hansen wrote:
> Alejandro wrote:
> > I'm using pySerial to talk to a RS232 to RS485 converter. In order to
> > control the converter, I need to control the DTR line to enable/disable
> > de RS485 driver.
>
> This seems a little odd to me.  We've used several RS232-RS485
> converters without needing to do that.  Maybe a more sophisticated
> device would eliminate this need?

Yes. The device is very simple (I made it).

> What you're trying to do is a hard realtime operation, and unless it's
> directly supported you could be up against an impossible task using
> Windows.  (But it seems you already knew that. :-)

I know it can be difficult/impossible. By the way, I am coding in
Linux, but want my code to be portable between Windows and Linux(!).

I will rethink the whole issue. May be I will use the time.sleep
alternative, taking a good margin to manage the uncertainty of the
delay.

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


pySerial: write in a blocking mode

2006-03-28 Thread Alejandro
Hi:

I'm using pySerial to talk to a RS232 to RS485 converter. In order to
control the converter, I need to control the DTR line to enable/disable
de RS485 driver. In particular, I need to :

write a character to the serial port
set the DTR line to level 1 _after_ the last bit of the character is
send

So I tried this (ser is the serial port object):

ser.write(x)
ser.setDTR(1)

The problem with this is that the ser.write function returns before the
character is send, and thus, the DTR line is set too soon. (I checked
this behaivour with an osciloscope).

I thought that seting the writeTimeout parameter could help, but then I
realized that the write function wait "up to this time", so it doesn't
work.

Then I tried waiting some time with time.sleep() after ser.write, but
the shortest time for time.sleep is to big, and non deterministic, so I
think this is not an option.

Does anybody know how to do a ser.write() in a blocking way?

Regards,
Alejandro.

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


Re: micro-python - is it possible?

2005-08-30 Thread Alejandro Weinstein
Evil Bastard wrote:
> Hi,
> 
> Has anyone done any serious work on producing a subset of python's
> language definition that would suit it to a tiny microcontroller
> environment?

Take a look at PyMite :

http://www.python.org/pycon/papers/pymite/

 From the abstract :

"PyMite is a flyweight Python interpreter written from scratch to 
execute on 8-bit microcontrollers as well as desktop computers..."

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


Re: Reaching the real world

2005-01-04 Thread Alejandro Weinstein
On 4 Jan 2005 at 6:55, Fuzzyman wrote:
 
> What I'd like is an electronic interface that connects to several
> relays and a python extension module to switch on and off the relays.
> I've had a quick google and can't see anything too similar to what I
> want. pyro (python robotics) seems to require expensive (relatively)
> robotic equipment.

Look at pyParallel (http://pyserial.sourceforge.net/pyparallel.html) 
to control the parallel port. From the parallel port you can control 
external devices. Please note that you will need to add a transistor 
to control a relay.

There is also pySerial, (http://pyserial.sourceforge.net/) to control 
the serial port. If you know how to use a microcontroller (AVR, PIC, 
8031, etc) you can communicate with it through the sereial port, and 
let the micro control the "real world".

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


Re: Tkinter vs wxPython

2004-12-29 Thread Alejandro Weinstein
> Sure wxGlade/Boa/etc can help speed design and layout up, but what
> happens when you want to do non standard things or just get stuck
> because some thing just isn't working.

Then you add the necesary hand crafted code to the automatic 
generated code. At least is what I did when I needed.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter vs wxPython

2004-12-28 Thread Alejandro Weinstein
> I am especially interested in terms of learning curve, documentation,
> portability across platforms Linux/Windows and anything else you care
> to add. As I know only what I have read on this forum & surfing the
> web I would really appreciate the input of those who have used both,
> or decided to use one over the other.

I was in the same shoes a time ago. I started with Tkinter since is 
the standard GUI for Python. I read some tutorials, but didn't go to 
far, and didn't like the Tkinter looks too much. Then I tried 
wxPython, and things were better. And were much better when I started 
using wxGlade.

IMO, wxPython has a softert learning curve (specially if you use 
wxGlade), is portable between unix/windows/mac, with the advantage 
over Tkinter that it has a native look. Regarding documentation, 
there is plenty of it.

I must admit that my background regarding GUIs comes from Delphi, so 
that might bias my opinion.

In case you take the Tkinter route, I founded this tutorial useful : 
http://www.bembry.org/tech/python/notes/tkinter_1.php

Regards,
Alejandro.

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


Re: Random number generation from functions

2004-11-30 Thread Alejandro López-Valencia
On Mon, 29 Nov 2004 20:51:50 GMT, "drs"
<[EMAIL PROTECTED]> wrote:

>Is there any way to generate random numbers based on arbitrary real valued
>functions? I am looking for something like random.gauss() but with natural
>log and exponential functions.

Try with CRNG, it may have what you need, or be able to adapt it to
what you want. http://www.sbc.su.se/~per/crng/

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