PIL show moves focus

2006-06-12 Thread elbertlev
Hi!

I have an application where images (jpeg) have to be annotated by an
operator. I use PIL like:

import Image
im = Image.open(Path)
im.show()
raw_input(Path + ':')


Python runs in a console window. Then show starts some application (in
my case Windows picture and FAX viewer) and the picture goes to this
application window.
Then operator enteres the annotation as prompted by raw_input. So far
so good. I understand, that the approach is very minilalistic, but
suffisient for what has to be done.

Unfortunatelly after im.show focus moves to thw Windows picture ...
and stays there until I move it back using the mouse.

Question: is there any way of returning the input focus to the console
window?

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


PAMIE save an image

2006-06-09 Thread elbertlev
Hi, all!

I'm writing a web page tester. The page is designed in such a way, that
every time it creates an image file and displays it on the page. As
soon as the file is downoladed it is deleted from the server.
Using PAMIE I can download the page (by controlling an instance of IE)
then
images = ie.imagesGet() #list of images
src = images[0].getAttribute('src') #sorce of the image

Is it possible to save the image(s) in the local file?

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


Re: Eclipse best/good or bad IDE for Python?

2005-12-01 Thread elbertlev
Eclipse is very-very slow. 3G P4 looks like 8M 86. It might be good for
Java, but not for Python. BUT THIS IS 1 OF 2 IDE'S WHICH ALLOWS
DEBUGGING OF MULTITHREADED APPLICATIONS. I prefer Eric or PythonWin.

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


Re: Eclipse best/good or bad IDE for Python?

2005-12-01 Thread elbertlev
Eclipse is very-very slow. 3G P4 looks like 8M 86. It might be good for
Java, but not for Python. BUT THIS IS 1 OF 2 IDE'S WHICH ALLOWS
DEBUGGING OF MULTITHREADED APPLICATIONS. I prefer Eric or PythonWin.

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


Re: python speed

2005-11-30 Thread elbertlev
Isaac Gouy wrote:

 Which stated Python is doing the heavy lifting with GMPY which is a
 compiled C program with a Python wrapper - but didn't seem to compare
 that to GMPY with a Java wrapper?

You are missing the main idea: Java is by design a general purpose
programming language. That's why all GMPYs and alike are written in
Java - now wrappers to C-libraries. Python, by design, is glue
language. Python program is assembly of  C extensions and buildins
wrapped in Python sintax.

IHMO real life benchmark yuo are critisizing represents real life
situation.

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


Re: Aproximative string matching

2005-11-20 Thread elbertlev
This algorithm is called soundex. Here is one implementation example.

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52213

here is another:
http://effbot.org/librarybook/soundex.htm

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


Re: ownership problem?

2005-11-20 Thread elbertlev
Yes!
Python uses auto garbage collection. As soon as the object reference
count becomes 0 it is removed from existence. So the problem typical
for C/C++: accessing pointers
to already deleted objects does not exist in Python.

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


Re: deleting registry keys and value

2005-11-19 Thread elbertlev
Looks OK to me. Just tried on my network - works with no exceptions

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


Re: A way for closing an app monitor

2005-11-16 Thread elbertlev
//So my solution (need help on this) is that I have been thinking on
letting the monitor listen for socket connection. Through this, the
main app can tell him to close when the main app closes correctly. Do
you think this is well thought? Any suggestions?

This is the only solution you have to consider. If monitor and main
app. run on the same machine - does not matter, But when they run on
different machines and maybe in different domains... One more hint:
make monitor a listener (server), namely HTTP server. In this case you
will not have problems with proxyes/firewalls etc.

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


Re: python and VisualFox dbf

2005-11-16 Thread elbertlev
A hint :) Is ADO supported?

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


Re: Python vs Ruby

2005-10-19 Thread elbertlev
Languages are very similar but Python has more cale avaliable. Much
more.

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


Re: date reformatting

2005-10-06 Thread elbertlev
setup.py install

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


Re: Parsing a Python dictionary inside a Python extension

2005-05-27 Thread elbertlev
1. Why not to simplfy the problem. You can extract values from the
dictionari in python (this is fast). Put them in a list (fast). Pass
the list to the extension, handle it and return to python. etc.

2. Use Pyrex.

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


Re: cpu usage limit

2005-05-27 Thread elbertlev
I understand, that what I suggest does not solve the problem you want,
but..

Why do you want to restrict CPU usage to 30%? In Windows I run CPU
intesive therads on IDLE priority, while interfacand/or communication
threads run on normal. This gives me best of two worlds:
1. I use 100% CPU (good) and
2. progam i responcive (very good).

There is no  cross platform way to change the thread priority. But most
OS (as well as thread libraries) support setting priorities.

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


Re: Is Python suitable for a huge, enterprise size app?

2005-05-20 Thread elbertlev
Sure it does not. As well as C, unless you instaead of malloc use low
level os-dependant APIs.

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


Re: Is Python suitable for a huge, enterprise size app?

2005-05-20 Thread elbertlev
C programs also can be disassembled. Serious people do not consider
braking the machine code harder byte-code.

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


Re: Reg php equivalent Mail_mime Module in Python

2005-05-13 Thread elbertlev
Look for:
http://sourceforge.net/projects/pymaillib/

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


Re: Merging overlapping spans/ranges

2005-05-10 Thread elbertlev
The linear method:

You create an array - one bool per minute. For one day 24 * 60 entries
is enough. Spans (Start, End) are in minutes from midnight. Set array
slots in range(Start, End) to True for each input span.

Scan the array and find metaspans - contiguous sequences of False.

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


Re: Database backend?

2005-05-08 Thread elbertlev
Look for the packet called KirbyBase. Small, pythonic, text based
files...

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


Re: Newbie : checking semantics

2005-05-07 Thread elbertlev
 I am new to python and was very enthustic about its possibilities
when
 I discover that python is really what it is : just a scripting
 language.
..
 The fact that python doesn't check if the symbol ... is defined, is
really bad ...

1. For a language like Python full static checking is IMPOSSIBLE.
Consider setattr() with attribute name read from a file (f.e. names of
the columns in the database).

2. Trust me (and other Python programmers most likely would agree) this
type of error happens much more seldom then newbies (especially coming
from strongly typed languages) imagine while adjusting to the language.

3. Python advantages overpower drawbacks 10 to 1.

4. Most likely you never used Fortran :)

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


Re: database in python ?

2005-04-11 Thread elbertlev
[EMAIL PROTECTED] wrote:
 I need to build table which need searching data which needs more
 power then dictionary or list in python, can anyone help me what
 kind of database suitable for python light and easy to learn. Is
 mySQL a nice start with python ?

It depends... mySQL is fine for more or less data centric applications
with many tables.

When I need SQL search power, but the number of tables/records is small
enough  gadfly is the best bet. Contact database, CD catalog, extended
configuration data are proper examples. In such cases, gadfly is by far
faster, then normal relational databases.

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


Dialogic bindings

2005-04-11 Thread elbertlev
Hi!

Does somebody have bindings to Dialogic voice cards driver. I'm sure
some people do have them, but could not find any reference. Ideally
there sould be some framework for CT applications in Python.

Any help would be greatly appreciated.

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


Re: Threads and variable assignment

2005-04-11 Thread elbertlev
Theoretically you have to use lock, while accesing the isgood instance,
but... practically noting bad can happen IN THIS PARTICULAR CASE, if
you don't. Python uses Global Interpreter Lock. In other  words only
one thread is running at any particular moment. Thread scheduling is
preemptive, but atomic actions are not interrupted. Bollean asigment
is an atomic action.

WELCOME TO THE POWER OF MULTITHREADING :)

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


Re: Help understanding code

2005-04-10 Thread elbertlev
Reading the language tututorial would help you a lot :(

=== what is the difference between pc and pc()?

pc = getToolByName()  - returnes a refference to a method

pc is a refference to a method, pc() is a method invocation.



   numbers = {total:len(results),bytype:{},bystate:{}}
=== This is hard to understand
   num = numbers[bytype].get(ctype, 0)   where does .get
come from? and what is the string 'bytype' doing?
   numbers[bytype][ctype] = num== is this some kind
of an array? 

Read the tutorial especially portion about dictionaries!

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


Re: Best editor?

2005-04-05 Thread elbertlev
Windows: textpad
Linux: vim

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


Re: threading.Event file descriptor

2005-04-03 Thread elbertlev

Nicolas Fleury wrote:
 Hi,
 Is there any way to get the file descriptor on Unix or handle on
Windows
 associated internally with a threading.Event object?  So that it can
be
 used in a call to select or WaitForMultipleObjects.
 Thx and regards,
 Nicolas

Good idea! But...

There is no event handle used in Event object (for NT at least). Do not
know about Linux...

Unless you want to rewrite the interpreter (namelly
PyThread_allocate_lock.c) for platforms you are talking about, you
would be better of, if you create your own class (derived from Event,
and ovewritte aquire, release and wait methods).

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


Re: threading.Event file descriptor

2005-04-03 Thread elbertlev
//And there's no handle at all?

There is one (check thread_nt.h) you have to propagate HANDLE to
Pythom level. That's why, you have to change the interpreter. Do not
forget, that thread is a build-in module.

//I wouldn't want to derive from Event since my goal would be to submit
a
patch to make subprocess.Popen.wait take an optional threading.Event to
kill the process.

And that's it? Right now aquire_lock is non-interruptable, as a result
your Popen.wait is also non-interruptable, but if you pass derived
event you will be able to handle more generic cases.

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


Re: Convert the contents of a string into name of variable

2005-03-24 Thread elbertlev
TRy db_row does exactly what you want to do. Slower, but more simple:
##
#Sequence2Struct.py

class Struct:
pass

def MakeStruct(seq, names):
obj = Struct()
if len(seq) != len(names):
raise IndexError(seq and names are not the same length)
for i in range(len(names)):
obj.__dict__[names[i]] = seq[i]
return obj

def ExtractNames(t):
return [item[0] for item in t]


if __name__ == __main__:
t = (1, 2, 3)
n1 = ((A, 1), (B, 1), (C, 2))
n = ExtractNames(n1)
print n
s = MakeStruct(t, n)
print s, s.A, s.B, s.C
n = (A, B)
s1 = MakeStruct(t, n)
##

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


Re: Anonymus functions revisited

2005-03-22 Thread elbertlev
Please do not change the syntax. Better focus on the library.

1. There are already 3 constructs right now for this problem.
2. List comprehensions are used mostly in examples. At least I came to
such conclusion reading the standard library modules.

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


Re: Checking if port is in use.

2005-03-19 Thread elbertlev
How about this?

try:
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,1)
s.bind((HOST, PORT))
except socket.error, e:
if e
print address already in use

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


Re: {SPAM} start a python application as a win NT service

2005-03-14 Thread elbertlev
 I'm using windows 2003 small business server and I want to install my
python programm as a NT (it's just an old name) service. Does anybody
know how to do this?

1. you need win32 extensions installed;
2. you need py2exe (optional if you want to install the service on the
machine with no Python)
3. an example can be found in
\Python23\Lib\site-packages\win32\Demos\service

Good luck

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


Re: Speeding up CGIHTTPServer (Tim Roberts)

2005-03-08 Thread elbertlev
Starting a process on WIN98 is VERY slow. (On NT much faster the second
time). If you really want to use WIN98, modify CGIHTTPServer.py in such
a way, that branch

#Other O.S. -- execute script in this process

is executed.

This way CGIHTTPServer is as fast as it gets. At least not slower then
ISAPI in JScript or VBScript and faster then Apache cgi.

If you need the modified module, I can send you one for 2.3.

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


Re: namespace collisions

2005-02-17 Thread elbertlev

John Lenton wrote:
 On Thu, Feb 17, 2005 at 06:20:36PM +, Will McGugan wrote:
  Hi,
 
  I'm accumulating a number of small functions, which I have sensibly
put
  in a single file called 'util.py'. But it occurs to me that with
such a
  generic name it could cause problems with other modules not written
by
  myself. Whats the best way of handling this? If I put it in a
common
  location in my Python path, should I call it willsutil.py?

local.util

 is probably a convention worth starting :)

 or you could go with

WilMcGugan.util

 but ThatGetsOldFast.


 --
 John Lenton ([EMAIL PROTECTED]) -- Random fortune:
 All my friends are getting married,
 Yes, they're all growing old,
 They're all staying home on the weekend,
 They're all doing what they're told.

I call modules like x_utils.py, where prefix x is assigned to a
particular pakage. In this case import statements look like:

import Company.repotrtools.e_excel as e_excel

or

from Company.repotrtools.e_excel import e_writer, e_reader

generally this are classes, not functions.

Newer had namespace collisions (yet :)

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


Where is WSAEnumNetworkEvents???

2005-02-02 Thread elbertlev
I was trying to write an asyncronous TCP server for win32 using
WSAEventSelect (which lives if win32file). Such events require
WaitForMultipleObjects (which lives if win32event) and
WSAEnumNetworkEvents WHICH IS NOT EXPOSED. This makes WSAEventSelect
useless. Does somebody know how to add the WSAEnumNetworkEvents and
WSANetwotkEvents structure win32file?
 
Maybe I'm missing something?

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


py-xmlrpc postpone question

2005-01-31 Thread elbertlev
Hi!
I'm trying to use py-xmlrpc. All works fine (and very fast) in
one-threaded case, but I really have to serve many clients.

As advertised, py-xmlrpc supports non-blocking calls (via select).

When request is received the handler is called with proper parameters.
As I understood from reading the source, if rpc call can't be executed
immediately (or takes long time) respond can be postponed by raising
postpone exception and when respond is ready, calling queueResponse() .


I wanted to have a pool of worker threads listening on a queue. In the
lengthy command handlers, post data on the queue and raise postpone.
Threads from the pool respond by calling queueResponse() when rpc is
done.

Server trace tells me that postpone was received, but client reacts as
if socket was closed (got EOS while reading). I tryed to supress
default error handling on the client side by returning from OnErr()
xmlrpc.ONERR_KEEP_WORK, but this kills the interpreter!
What am I doing wrong?

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


Re: smtplib bug with Windows XP

2005-01-24 Thread elbertlev

 Try manually, but think about these options: a firewall that
 has suddenly been enabled, an SMTP server that now requires
 authentication, some kind of proxy like what virus scanners
 use (though why they would intercept outgoing mail I don't
 know)...
 
 -Peter

I bet it was the firewall on XP.

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


Re: encryption/decryption help

2005-01-12 Thread elbertlev
For the problem described pycrypto is the best solution. Blowfish is
simple and secure.  The method you want to use is called security by
obscurity. But chances are very high that the homebrewed scheme you
will invent will not stand any serious crytoatack.

First of all: both sides (sender and receiver) have to agree on the
session key used.  And this is the most dangerous exchange. Sure you
can hard coded the key on both sides, but periodically you have to
change them.

I was facing similar problem: had to secure legacy Inet server. I
started with stunnel (worked great, but was a little bit sluggish).
Then I figured out how to implement IPSEC (both sides were W2K) and
this was the safiest solution. Sorry but it does not involve Python :(

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


pyXLwriter and jython

2005-01-12 Thread elbertlev
Hi!

I was using pyXLwriter in C-python, but recently had to code in jython.
Tried to port pyXLwriter to jython and it does not work. Did somebody
uset this module with jython?

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


Re: File locking is impossible in Windows? SOLUTION

2005-01-02 Thread elbertlev
Sure it will do if one of the processes needs read access only.

Scenario when you need shared rw acces with locking:
In the file you have records say 30 bytes long, 2 processes are
reading/writing these records by: lock-read-unlock or lock-write-unlock
. Both processes have to open the file with rw access. But the third
process can overwrite the locked file! Actually the common method to
prevent file from been overwritten is: lock the region outside the
file. Such feacure is added to lock/unlock namely for this purpose.

You found the bug in WIN32.

PS.

When you copy the file (say c:\b) over file with locked region say
(c:\a), the length of the file c:\b becomes the length of c:\a, and the
content of c:\a is all zeroes. By the way, I would understand the logic
if copy copyes bytes outside locked regions but preserves all locks.

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


Re: File locking is impossible in Windows?

2004-12-22 Thread elbertlev
I just have written the program in C, which does the same. It behaves
almost the way you described.

Tthe copy command gives such diagnostic:

The process cannot access the file because
another process has locked a portion of the file.
0 file(s) copied.

BUT THE FILE IS ACTUALLY OVERWRITTEN..

I'm posting this question on MS newsgroup
microsoft.public.win32.programmer.kernel

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


Re: File locking is impossible in Windows? SOLUTION

2004-12-22 Thread elbertlev
Sure it will do if one of the processes needs read access only.

Scenario when you need shared rw acces with locking:
In the file you have records say 30 bytes long, 2 processes are
reading/writing these records by: lock-read-unlock or lock-write-unlock
. Both processes have to open the file with rw access and the third
process can overwrite the locked file. Actually the common method to
prevent file from been overwritten is: lock the region outside the
file. Such feacure is added to lock/unlock namely for this purpose.

You found the bug in WIN32.

In fact the file locked and overwritten hav ALL BYTES ZERO and the
length of the copyed file.

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


Re: better lambda support in the future?

2004-12-17 Thread elbertlev
Lambda functions will become obsolette in the nearest future. This is
the PLAN.

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


Re: looking for blocking on read of a real file (not socket or pipe)

2004-12-14 Thread elbertlev
I doubt that the recipe you recomended will work at all in the case of
different processes. To do this right file has to be open in shared
mode (by both programs). Python does not support shared access.
In the case of one program, but different threads probably this will
work.

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


Re: M2Crypto for 2.4

2004-12-02 Thread elbertlev
//I will do it in the next day or two.

Me too!

Remember, this is a programmer and a manager
telling you his plan. :) But, if I do not, nobody in my department will
:(

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