Re: RPC from Java to Python

2007-06-07 חוט Ori Peleg

Friends using SOAP to connect between Java, .NET and Python reported great
results with ZSI , as long as you're
using WSDL - which is easy to generate if the server is in Java. Without
WSDL, I had a bad compatibility experience.

I agree with all the people that recommended XML-RPC. I like it a lot, but
I've never used it with Java.

On 6/7/07, Ronnie Maor <[EMAIL PROTECTED]> wrote:


Does anyone have experience with RPC from Java to Python?
Trying to get this to work over either XML-RPC or SOAP (prefer SOAP) but
am having slow start due to lack of experience with any of relevant parts
:-(
Specific packages to use, tips, and especially working example code would
be very very appreciated

thanks
Ronnie




Re: curses drives me mad!

2007-05-07 חוט Ori Peleg

Hi Maxim!

I'm not a curses expert and I don't know why this is happening, but maybe
these suggestions will help:

  1. Have you read the tutorial Curses Programming with
Python?
  I found it very helpful.
  2. Try using curses.addstr to print text (including colors) instead of
  'print' or 'sys.std*'. Examples are in the tutorial.
  3. curses.wrapper is nice, takes care of initscr and friends.
  4. Check out the Python curses demos,
hereor in a
Python source tarball.
  5. Bli Kesher, you can get the color codes from terminfo without
  running 'tput' (but you don't need them when using curses.addstr):
  curses.setupterm() # not needed if you call curses.initscr()
  curses.tparm(curses.tigetstr('setaf'), 0) # same as commands.getoutput('tput
  setaf 0')

Hope I helped,
Ori.

On 5/7/07, Maxim Veksler <[EMAIL PROTECTED]> wrote:


Shalom people,

I'm new on this list, and to python in general.
Fun with python to us.

I'm attaching my sanity checking script (which in the mean time doing
it's job perfectly - getting me insanse :)

The lines for error don't print with CR/LF but only with LF; I
susspect curses is to blame but I have no experience with it and
haven't found what proper switches/flags/objects I need to pass to it
to make it work like expected.

Current output
"""
./ColorReport.py
Check directory "/bin" exists
  [OK]Check directory
"/usr" exists
  [OK]Check directory "/opt/hq4ever"
exists
 Failed directory existance test
Do
you have my-core rpm installed
Check directory "/opt/hq4ever" exists
[FAIL]
"""

expected output
"""
./ColorReport.py
Check directory "/bin" exists
  [OK]
Check directory "/usr" exists
  [OK]
Check directory "/opt/hq4ever" exists
Failed directory existence test
Do you have my-core rpm installed
Check directory "/opt/hq4ever" exists
  [FAIL]

the code

"""
#!/usr/bin/python -u

class ColorTerm:
def __init__(self, Mono = False):
pass

def __get_tput_color_value__(colorcode):
from commands import getoutput
return getoutput('tput setaf ' + colorcode)

BLACK_FG =  __get_tput_color_value__('0')
RED_FG =__get_tput_color_value__('1')
GREEN_FG =  __get_tput_color_value__('2')
YELLOW_FG = __get_tput_color_value__('3')
BLUE_FG =   __get_tput_color_value__('4')
MAGENTA_FG =__get_tput_color_value__('5')
CYAN_FG =   __get_tput_color_value__('6')
WHITE_FG =  __get_tput_color_value__('7')

def black(self, msg):
return self.BLACK_FG + msg + self.BLACK_FG

def red(self, msg):
return self.RED_FG + msg + self.BLACK_FG

def green(self, msg):
return self.GREEN_FG + msg + self.BLACK_FG

def yellow(self, msg):
return self.YELLOW_FG + msg + self.BLACK_FG

def blue(self, msg):
return self.BLUE_FG + msg + self.BLACK_FG

def magenta(self, msg):
return self.MAGENTA_FG + msg + self.BLACK_FG

def cyan(self, msg):
return self.CYAN_FG + msg + self.BLACK_FG

def white(self, msg):
return self.WHITE_FG + msg + self.BLACK_FG

class StatusWriter(ColorTerm):
import curses

def __init__(self, report_type = None):
pass

def initstyle_message(self, printed_msg, status = True):
screen = self.curses.initscr(); self.curses.endwin()
if status:
status_msg = '[' + self.green('OK') + ']'
status_msg_len = len('['+'OK'+']')
else:
status_msg = '[' + self.red('FAIL') + ']'
status_msg_len = len('['+'FAIL'+']')

__spaces_count = ( screen.getmaxyx()[1] -
(len(printed_msg)+status_msg_len)  )
#print ''
#print len(printed_msg)
#print __spaces_count
#print len(status_msg)
#print '=', len(printed_msg)+__spaces_count+len(status_msg)
return printed_msg + ' '*__spaces_count + status_msg

def initstyle_skip_message(self, msg):
screen = self.curses.initscr(); self.curses.endwin()
status_msg = '[' + self.yellow('SKIP') + ']'

__spaces_count = ( screen.getmaxyx()[1] -
(len(msg)+len(status_msg)) )
return msg + ' '*__spaces_count + status_msg

class SanityCheck():
cc = StatusWriter()

def __init__(self, test_name, depends = []):
self.status = None
self.test_name = test_name
self.depends = depends
pass

def directory_exists(self, dirpath):
import os.path
import sys

usr_output_info = 'Check directory "' + dirpath + '" exists'
sys.stdout.write(usr_output_info)

if os.path.exists(dirpath):
 

Re: using python for significant tasks

2007-04-16 חוט Ori Peleg

Hi Eli!

[profiler with mixed Python/C code]
I miss this too.
I use an inconvenient workaround - I profile with a Python profiler, then
profile the Python executable running the code with a C profiler.

[Boo]
It really looks nice! Its performance should be checked closely, though - I
thought the same about Groovy - that if you write simple code with full
static typing, it should compile to fairly efficient Java byte code. But it
doesn't :)

IronPython has full access to the .NET libraries too, and Microsoft created
a standard way to define interfaces (so you can write a DLL in Python) - so
I guess (just guess) that in an IronPython project interfaces aren't a
problem.

Regards,
orip.

On 4/17/07, Eli Golovinsky < [EMAIL PROTECTED]> wrote:


Go to www.zoozla.com.

It's a media uploader I've developed for my own startup. It's not public
yet, but drop your email there and you should get a download link shortly.
It shows you what you can do with Python and wxPython in terms of GUI and
web automation.

I found Python lacking in two main aspects. When your project grows beyond
a certain size, you begin to feel the need for more clear-cut boundaries
between modules and layers which is usually accomplished with interfaces.
Python has no built-in facilities for that and although there are several
libraries that do that, you should really know what you are doing. It may
become a serious problem if a large  team (more than 3 developers) is
working on your project. The other problem that I encountered is the lack of
a decent profiler for performance tuning. There are libraries to do that
too, but they don't seem to take into account the time spent in C modules
which makes them pretty much useless for wxPython work.

If you don't need cross platform support and your platform is Windows, I'd
probably try to stick to .NET as it is becoming the native API for Windows.
There's a cool language called Boo ( http://boo.codehaus.org/) that has
Python like syntax, compiles to pure (and presumably quick) MSIL and has
complete access to all the .NET libraries. I has some of the nice features
that make things productive for Python and I think it might be worth a look.


On 4/16/07, Ronnie Maor < [EMAIL PROTECTED]> wrote:
>
> I just joined a new startup and trying to build a case for using python
> as the main programming language. Performance shouldn't be a problem for
> this application, and the main considerations are quick development cycle
> and maintainability.
> It would really help if I could give examples of companies that use
> python as a significant part of their main application / business logic.
> Can anyone give such examples? preferably from your companies, other
> israeli companies you know, or well known and successful non-israeli
> companies?
>
> Omri Reuter - does python play such a role in egloo or is it a glue for
> logic in another language?
> Ori Peleg - IIRC you mentioned rewriting the ORM for your company in
> python?
>
> Another thing:
> Before I raised the python idea, the leading thoughts were C# (windows
> dependency isn't a problem). My thoughts were on using IronPython with C#
> (for extensions, and using .NET libraries), and I think python would be more
> powerful as the framework language, with C# in specific areas instead of the
> other way around.
> One risk is that IronPytnon is relatively new. Anyone have experience
> with it? know how stable it is?
> anyone think using IronPython or python in general for such a purpose is
> a bad idea?
>
> your comments much appreciated
> Ronnie
>
>



--
gooli.org


Re: using python for significant tasks

2007-04-16 חוט Ori Peleg

Yes, you should program in Python! (or a similar agile language) :-)

My main points:

  - Python is excellent for refactoring (beats C++ and, yes, Java too)
  - Don't move an inch with unit and system tests
  - These tests are much easier to write in Python
  - Compiler-checked interfaces aren't that important
  - After a few serious successes, Python is a very serious contender in
  my company.

Now to our application's story:
We ported a large application core to Python (original was in C++ - we wrote
it too).
Our motivation was maintainability - we were sure we could reduce that
hulking core to a smaller and simpler creature. This really did happen, to
the point that the project never went into maintenance mode - it suddenly
became useful for things we didn't predict :)

We got performance benefits as well (yes, we were surprised). The reasons
were straightforward - we had many more options when refactoring the code,
and separated a lot of logic neatly (for example extracted DB caching to a
decorator - "AOP" in a language that needs a new term :-)

The gains we ended up getting could have been achieved in C++, obviously,
but they only became apparent after refactoring with Python.

We also wrote a quick sample client/server application with Twisted, which
was later modified in 2 weeks by someone different and transformed into an
excellent production application, that's still working flawlessly after 6
months with no maintenance. All this with about 300 lines of simple,
practically stupid, "I understand this code the first time I see it" code
(actually, this is probably the reason for the quality).

Now, every time someone says "client/server" people think about Python and
Twisted, and even a large legacy network client is being replaced with a
small Twisted client soon.

How come Python is so amazing for refactoring?
First, you need really good tests. I don't miss the compiler when I have
really good tests.
The good side is that to develop at good quality and speed you need really
good tests in any language, so you're not losing anything.
These tests are also so much easier to write in Python - we get more and
better tests, and spend less time writing them. (Whatever language you use
for the system, you should probably test in a language like Python).

Once these tests are in place, refactoring in Python with a good text editor
and some basic tools is so much smoother than C++ or Java, even with
Eclipse's really cool 'Refactor' menu.
Those actions that are trivial in Eclipse ( e.g. 'Rename Method') are a
little more complicated in Python, but not by much (remember the good
tests).
On the other hand, anything that isn't in Eclipse's context menu is
absolutely horrible to do in Java, to the point that I've met many good Java
developers that don't think anything else exists at all :) In Python, I've
found it to be a snap.
And when you add all the more and less dynamic tools that can be put to good
use, I'm one happy refactorer. Decorators, bound methods, generator
expressions, and the like give me many ways to make the code simpler that
aren't nearly as accessible in Java (or barely possible in C++).

Why aren't interfaces that important? The reason I like interfaces is as
documentation that the compiler happens to check. It's convenient, but I
don't terribly miss it in the presence of (a) good documentation, and (b),
you guessed it, good tests :-D
I don't have much experience with zope.interface, so I don't know how easy
it is to use or how much of the benefit from interfaces you get.
I must say about this point that I'm comparing a full static-typing approach
(e.g. Java) to a full dynamic-typing approach (e.g. Python) - give me
dynamic typing any day. A hybrid statically- and dynamically-typed language
like Groovy could work better, I don't have the experience to say.

orip.

On 4/16/07, Ronnie Maor < [EMAIL PROTECTED]> wrote:


I just joined a new startup and trying to build a case for using python as
the main programming language. Performance shouldn't be a problem for this
application, and the main considerations are quick development cycle and
maintainability.
It would really help if I could give examples of companies that use python
as a significant part of their main application / business logic.
Can anyone give such examples? preferably from your companies, other
israeli companies you know, or well known and successful non-israeli
companies?

Omri Reuter - does python play such a role in egloo or is it a glue for
logic in another language?
Ori Peleg - IIRC you mentioned rewriting the ORM for your company in
python?

Another thing:
Before I raised the python idea, the leading thoughts were C# (windows
dependency isn't a problem). My thoughts were on using IronPython with C#
(for extensions, and using .NET libraries), and I

Re: קישור קצר יותר לויקי

2006-10-19 חוט Ori Peleg

I think it's worth it too.

On 10/19/06, Nir Soffer <[EMAIL PROTECTED]> wrote:

בעד.

On Oct 19, 2006, at 1:38 AM, Amit Aronovitch wrote:

> כיום, הקישורים לויקי הם בצורה הבאה:
>
> http://www.python.org.il/mediawiki/index.php/Some_Page
>
> שזה קצת ארוך, קשה לזכור, וגם מכיל את המילה php, מה שגורר כל מיני שאלות
> ותגובות בקרב פייתונאים מסויימים.
>
> חשבנו שקישור מהצורה
>
> http://wiki.python.org.il/Some_Page
>
> (אל תקליקו - זה אמנם עובד, אבל תקראו בהמשך)
> הוא הרבה יותר נחמד, ניתן לזכור בע"פ, ולא מכיל מילים גסות ;-).
>
> אז באדיבות אריק ושלומי סידרנו שזה יקרה.
>
> אלא מה?
> מסתבר שכאשר עובדים מול domain name אחד, לא ניתן לעקוב אחרי קישורים
> שמופיעים בדפי ויקי שנערכו מהדומיין השני, ולהפך.
>
> המסקנה - אנחנו צריכים להחליט. אם אנחנו רוצים לשנות את הקישורים, אז
> צריך לקבוע איזה יום שבו נריץ על השרת בניה מחדש של כל הדפים.
> לאחר השינוי הזה נעבור כולנו להשתמש בדומיין החדש בלבד (כולל לעדכן את כל
> הקישורים החיצוניים  אל
> הויקי שלנו).
>
> השאלה להכרעת הקהל:
>
> האם שווה להקדיש את המאמץ?


Best Regards,

Nir Soffer




Re: Some good Python-IL web-site ideas

2006-09-04 חוט Ori Peleg
In the link, plus items 13 and 15 are just the titles.

Didn't it show?
http://linuxmafia.com/faq/Linux_PR/newlug.html

Nir Soffer wrote:
> Where are 1-12, 14?
> 
> On Sep 11, 2006, at 3:04 AM, Ori Peleg wrote:
> 
>>
>>  13. Place time-sensitive and key information prominently near the top
>> of your
>> main Web page.
>>  15. Emphasise on your main page that your meeting will be free of
>> charge and
>> open to the public (if it is).
>>
>> Also notice that our main page is http://www.python.org.il/, _not_ the
>> wiki
>> page. It should be inviting and updated, so possibly we'll just want it to
>> display the Upcoming Meeting wiki page... (with existing links etc. on
>> the side?)
>>
>>
>> Anyway, food for thought.
>>
>> Cheers,
>> Ori.
> 
> 
> Best Regards,
> 
> 
> Nir Soffer
> 
> 


Some good Python-IL web-site ideas

2006-09-04 חוט Ori Peleg

 13. Place time-sensitive and key information prominently near the top of your
main Web page.
 15. Emphasise on your main page that your meeting will be free of charge and
open to the public (if it is).

Also notice that our main page is http://www.python.org.il/, _not_ the wiki
page. It should be inviting and updated, so possibly we'll just want it to
display the Upcoming Meeting wiki page... (with existing links etc. on the 
side?)


Anyway, food for thought.

Cheers,
Ori.


Re: Python-IL July Meeting

2006-07-25 חוט Ori Peleg
I thought Tomer Filiba's talk on RPyC was amazing, I can think of applications
already!

Tomer - can you put the Hebrew slides up somewhere?

Thanks!
Ori.

Ronnie Maor wrote:
> meeting is today, tuesday, 25/7 at 19:00 at kashya.
> aba hilel silver 7, beit silver, 8th floor.
> Main talk will be on RPyC (or at least that's what Ori told me to write)
> 
>  
> On 7/24/06, *Ori Avtalion* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
> 
> Is there a meeting planned for tommorow? The list is kind of silent...
> 
> Ori Peleg wrote:
> > I'm thinking of this Tuesday, 25/7. Tuesday seemed to work fine on
> previous
> > meetings. It's two days from now (or tomorrow if you're
> nitpicking), and the
> > content isn't set yet. Is anyone planning to come? I'd appreciate
> you mailing me
> > or the list if you are.
> >
> > Ronnie - can you host Tuesday evening?
> >
> > I'll update on the content tomorrow evening. If anyone wants to
> volunteer a
> > talk, demo, or mini-talk, feel free :)
> >
> > Sorry for the last-minute announcement.
> >
> > Ori.
> >
> 
> 


Re: July meeting - correction

2006-07-16 חוט Ori Peleg
Ho hum, where is the original message I sent?

Here it is copied:

---
Hi everyone,

I volunteered to replace Amit in organizing July's meeting.

I only started now. Late, I know...

I'm thinking of this Tuesday, 25/7. Tuesday seemed to work fine on previous
meetings. It's two days from now (or tomorrow if you're nitpicking), and the
content isn't set yet. Is anyone planning to come? I'd appreciate you mailing me
or the list if you are.

Ronnie - can you host Tuesday evening?

I'll update on the content tomorrow evening. If anyone wants to volunteer a
talk, demo, or mini-talk, feel free :)

Sorry for the last-minute announcement.

Ori.
---

Ori Peleg wrote:
> Tuesday 25/7 is, of course, next week and not in two days.
> 
> I'm embarrassed to even begin to explain how I got confused, so I won't :)
> 
> So no rush, a full 9 days for planning and execution. Suggestions for talks 
> are
> welcome as always. I'll even have time to update the wiki and stuff.
> 
> Breathing a sigh of relief,
> Ori.
> 


July meeting - correction

2006-07-16 חוט Ori Peleg
Tuesday 25/7 is, of course, next week and not in two days.

I'm embarrassed to even begin to explain how I got confused, so I won't :)

So no rush, a full 9 days for planning and execution. Suggestions for talks are
welcome as always. I'll even have time to update the wiki and stuff.

Breathing a sigh of relief,
Ori.


Python-IL July Meeting

2006-07-16 חוט Ori Peleg
Hi everyone,

I volunteered to replace Amit in organizing July's meeting.

I only started now. Late, I know...

I'm thinking of this Tuesday, 25/7. Tuesday seemed to work fine on previous
meetings. It's two days from now (or tomorrow if you're nitpicking), and the
content isn't set yet. Is anyone planning to come? I'd appreciate you mailing me
or the list if you are.

Ronnie - can you host Tuesday evening?

I'll update on the content tomorrow evening. If anyone wants to volunteer a
talk, demo, or mini-talk, feel free :)

Sorry for the last-minute announcement.

Ori.


Re: smtplib

2006-06-08 חוט Ori Peleg
Hi Eli!

Here's an idea:

It seems class smtplib.SMTP sends the message with method 'send', that calls a
socket's 'sendall' (from Python 2.4's smtplib.py)

def send(self, str):
"""Send `str' to the server."""
# .. skipping
self.sock.sendall(str)
# .. skipping

You could subclass smtplib.SMTP, and reimplement method 'send' using Socket.send
instead of Socket.sendall to send chunks, and do whatever you want then.

For example, you could call a callback with the bytes sent:

def send(self, str, chunk_size=512, callback=lambda bytes_sent: None):
"""Send `str' to the server."""
# .. skipping
bytes_sent = 0
while bytes_sent < len(str):
chunk = str[bytes_sent:bytes_sent+chunk_size]
bytes_sent += self.sock.send(chunk)
callback(bytes_sent)
# .. skipping

I haven't tested it, but it seems about right.

Ori.

Eli Golovinsky wrote:
> I am sending large email messages (with MIME parts) using this recipe :
> 
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/473810
> 
> 
> But I can't find any way to monitor the progress (i.e. how many bytes
> have been delivered until now) of  the sending.
> 
> 
> Anybody has an idea how I can accomplish that?
> 
> 
> 
> 


Re: פגישת מאי

2006-05-13 חוט Ori Peleg
2 and 3 sound great!!!

Ronnie Maor wrote:
> topics I can talk about:
> 1) cartesian multiplication in two lines:
> def mult(*seqs):
>   def mult2(A,b): return [ a+[i] for a in A for i in b ]
>   return reduce(mult2,seqs,[[]])
>  
> 2) sqlalchemy (ORM) and simple application (bugzilla status reporting
> framework ~100LOC)
> 3) twill (web browsing automation) and simple application (bugzilla mass
> update - ~50LOC)
>  
> Let me know if you want me to do 2 or 3 - if so, I'll bring my laptop
>  
> On 5/11/06, *Amit Aronovitch* <[EMAIL PROTECTED]
> > wrote:
> 
> הי,
> 
> תאריך פגישת מאי: יום ב', 29/5/06 (לא סופי)
> 
> ברמת גן (כנראה).
> 
> לפרטים:
> 
> http://www.python.org.il/mediawiki/index.php/Upcoming_Meeting
> 
> 


Re: Plone based website for python.org.il

2006-05-08 חוט Ori Peleg
Did I miss the mailing-list announcement of the logo contest?

Amit Aronovitch wrote:
> Hi,
> 
> Thank you for your suggestions.
> 
> We had Michael Bernstein aboard last meeting (24/4), and he gave a
> nice review of Zope, also mentioning Plone and demonstrating some
> online site management.
> 
> It all seems very nice, but unfortunately our current problem is
> generating contents, not how to manage it.
> With the little time I have, I barely manage to organize the meetings.
> Shlomi created the original static contents you show in your demo, but
> he's probably busy enough as it is with other FOSS related activity
> (plus we all know he's really a perl-monger spy ;-) ).
> 
> Apart from us there's a handful of others adding a few words on the
> wiki here and there (mainly related to the meetings and subjects for
> talks), I don't think any of them can spend enough time to redesign
> the site (e.g. - I made
> http://www.python.org.il/mediawiki/index.php/Python-IL_Logo_Contest ,
> but only one other person posted a suggetion, and only Shlomi
> expressed any opinion at all).
> 
> Of course, if you volunteer to be our site manager, I'll be thrilled.
> But please be advised that unless you come up with a new server to
> host us, there's not much chance to install Plone or Zope on the
> current one. The current host (eskimo.iglu.org.il) is a Pentium3
> serving several FOSS sites and mailing lists, and is recently
> suffering from memory problems (lately there was talk about buying
> more memory - but most probably we'd still be far from the
> server-recommendations ).
> 
>   Regards,
>  Amit
>