Re: Having fun with python

2007-10-03 Thread Tzury Bar Yochay
> However, one point you have shown very clearly: the second one is much > easier to tear apart and reassemble. Sure. Zen Of Python: Readbility Counts -- http://mail.python.org/mailman/listinfo/python-list

a simple tcp server sample

2007-11-07 Thread Tzury Bar Yochay
hi, the following sample (from docs.python.org) is a server that can actually serve only single client at a time. In my case I need a simple server that can serve more than one client. I couldn't find an example on how to do that and be glad to get a hint. Thanks in advance import socket HOST =

Re: a simple tcp server sample

2007-11-07 Thread Tzury Bar Yochay
> Even simpler, use Twisted: I am afraid Twisted is not the right choice in my case. I am looking for smaller, simpler and minimal server sample. -- http://mail.python.org/mailman/listinfo/python-list

Re: a simple tcp server sample

2007-11-07 Thread Tzury Bar Yochay
> See the SocketServer module, both the documentation and the source code. I firstly looked at this module and its __doc__, yet I still need an 'hello world' sample. and couldn't get it straight how can I write my own hello world sample with SocketServer objects. -- http://mail.python.org/mailm

Re: a simple tcp server sample

2007-11-07 Thread Tzury Bar Yochay
here is its: # a simple tcp server import SocketServer class EchoRequestHandler(SocketServer.BaseRequestHandler ): def setup(self): print self.client_address, 'connected!' self.request.send('hi ' + str(self.client_address) + '\n') def handle(self): while 1:

100% CPU Usage when a tcp client is disconnected

2007-11-22 Thread Tzury Bar Yochay
The following is a code I am using for a simple tcp echo server. When I run it and then connect to it (with Telnet for example) if I shout down the telnet the CPU tops 100% of usage and saty there forever. Can one tell what am I doing wrong? #code.py import SocketServer class MyServer(SocketServ

Re: 100% CPU Usage when a tcp client is disconnected

2007-11-22 Thread Tzury Bar Yochay
> data = "dummy" > while data: > ... Thanks Alot -- http://mail.python.org/mailman/listinfo/python-list

Re: 100% CPU Usage when a tcp client is disconnected

2007-11-22 Thread Tzury Bar Yochay
Thank Hrvoje as well -- http://mail.python.org/mailman/listinfo/python-list

To PEAK or not to PEAK

2008-02-24 Thread Tzury Bar Yochay
I am about to start a large-scale enterprise project next month (I insist on using Python instead Java and .NET and I am sure `they` will thank me eventually). I was wondering around making my components-and-libraries-shopping- list and came across PEAK. My paranoia is that PEAK would make me writ

encoding/decoding issue with python2.5 and pymssql

2008-03-23 Thread Tzury Bar Yochay
hi, in my table the field row_id is type of uniqueidentifier. when try to fetch the data, pymssql somehow, encodes the values in a way which yields odd results. for example: the value 'EE604EE3-4AB0-4EE7-AF4D-018124393CD7' is represent as '\xe3N`\xee\xb0J\xe7N\xafM\x01\x81$9<\xd7' the only way

Re: encoding/decoding issue with python2.5 and pymssql

2008-03-24 Thread Tzury Bar Yochay
this byte array. On Mar 24, 8:48 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Sun, 23 Mar 2008 22:33:58 -0700 (PDT), Tzury Bar Yochay > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > for example: > > the value > > 'EE604E

behavior varied between empty string '' and empty list []

2008-03-24 Thread Tzury Bar Yochay
while I can invoke methods of empty string '' right in typing (''.join(), etc.) I can't do the same with empty list example: >>> a = [1,2,3] >>> b = [].extend(a) >>> b >>> b = [] >>> b.extend(a) >>> b [1,2,3] I would not use b = a since I don't want changes on 'b' to apply on 'a' do you think t

Inheritance question

2008-03-25 Thread Tzury Bar Yochay
given two classes: class Foo(object): def __init__(self): self.id = 1 def getid(self): return self.id class FooSon(Foo): def __init__(self): Foo.__init__(self) self.id = 2 def getid(self): a = Foo.getid() b = self.id return

Re: Inheritance question

2008-03-25 Thread Tzury Bar Yochay
On Mar 25, 2:00 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Mar 25, 10:44 pm, Tzury Bar Yochay <[EMAIL PROTECTED]> wrote: > > > > > given two classes: > > > class Foo(object): > >     def __init__(self): > >         self.id = 1 > > >

Re: Inheritance question

2008-03-25 Thread Tzury Bar Yochay
> Rather than use Foo.bar(), use this syntax to call methods of the > super class: > > super(ParentClass, self).method() Hi Jeff, here is the nw version which cause an error class Foo(object): def __init__(self): self.id = 1 def getid(self): return self.id class FooSon(F

Re: Inheritance question

2008-03-25 Thread Tzury Bar Yochay
On Mar 25, 4:03 pm, Anthony <[EMAIL PROTECTED]> wrote: > On Mar 25, 11:44 am, Tzury Bar Yochay <[EMAIL PROTECTED]> wrote: > > > While my intention is to get 1.2 I get 2.2 > > I would like to know what would be the right way to yield the expected > > results >

Re: Inheritance question

2008-03-25 Thread Tzury Bar Yochay
Hi all, I would like to thank you all for all the suggestions. what I did was simply extending the super class data with data from its child using the id example, Foo.id = 1 is now = [1] and the FooSon does self.id.append(2) the system designer wanted inheritance+java and I wanted Python +Functi

Re: Py2exe embed my modules to libary.zip

2008-03-26 Thread Tzury Bar Yochay
> and then when my application execute code how can I set path to > d3dx module to "library.zip/d3dx.py". > I'm not sure is this properly set question. use the module zipimport http://docs.python.org/lib/module-zipimport.html -- http://mail.python.org/mailman/listinfo/python-list

chronic error with python on mac os/x 10.5

2008-03-28 Thread Tzury Bar Yochay
Although I am experiencing this problem using a specific domain library (pjsip). Googling this issue show that it is happening to many libraries in python on mac. I was wondering whether anyone solved this or alike in the past and might share what steps were taken. Note: this python lib works fine

os.environ.get('SSH_ORIGINAL_COMMAND') returns None

2008-12-15 Thread Tzury Bar Yochay
Trying to follow a technique found at bzr I did the following added to ~/.ssh/authorized_keys the command="my_parder" parameter which point to a python script file named 'my_parser' and located in / usr/local/bin (file was chmoded as 777) in that script file '/usr/local/bin/my_parser' I got the

AttributeError: 'module' object has no attribute 'DatagramHandler' (ubuntu-8.10, python 2.5.2)

2008-12-29 Thread Tzury Bar Yochay
$ ~/devel/ice/snoip/freespeech$ python Python 2.5.2 (r252:60911, Oct 5 2008, 19:24:49) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import logging >>> logging.DatagramHandler Traceback (most recent call last): File "", line 1, in AttributeErro

why does math.pow yields OverflowError (while python itself can calculate that large number)

2008-10-23 Thread Tzury Bar Yochay
What is the reason math.pow yields OverflowError while python itself can calculate these large numbers. e.g: >>> import math >>> math.pow(100, 154) 1e+308 >>> math.pow(100, 155) Traceback (most recent call last): File "", line 1, in OverflowError: math range error >>> eval(('100*'* 155)[:-1]) 1

Re: why does math.pow yields OverflowError (while python itself can calculate that large number)

2008-10-23 Thread Tzury Bar Yochay
> Because math.pow returns a float; 100 ** 155 won't fit in a float. Sure that is the reason. May I rephrase, my question: Why not returning another type as long as we can calculate it? After all, math module is likely to be used on large numbers as well. -- http://mail.python.org/mailman/listinfo

Re: How to get the time of message Received of an outlook mail in python..

2008-10-23 Thread Tzury Bar Yochay
On Oct 23, 12:04 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi,, >       How can we access the time of message received ( UTC time) of an > outlook mail in python? As far as I know the time which it displays in > the mail is not the exact time... this UTC time will be present in > MIME He

a py2exe feature for non-windows environments

2009-04-23 Thread Tzury Bar Yochay
Hi, The nicest thing I like about py2exe is its library.zip which encapsulate all the dependencies into one single file. I wonder if there a script which can do the same for linux/mac osx so one can ship a python solution as a single file (instead of starting easy_install per used library on the t

Re: a py2exe feature for non-windows environments

2009-04-23 Thread Tzury Bar Yochay
> Mac OS X:http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html Found these for linux: http://www.pyinstaller.org/ http://wiki.python.org/moin/Freeze thanks alot -- http://mail.python.org/mailman/listinfo/python-list

how to free memory allocated by a function call via ctypes

2009-05-30 Thread Tzury Bar Yochay
Hi, Suppose I have the following function char *generateMessage(char *sender, char *reciever, char *message) ; now in c I would normally do char *msg = generateMessage(sender, reciever, message); // do something free(msg); My question is how do I free the memory allocated when I call this funct

trying to use SOCK_RAW yields error "

2008-08-12 Thread Tzury Bar Yochay
I am trying to create raw socket: server = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.getprotobyname('ip')) As a result I get the following error: Traceback (most recent call last): File "tcpsrv.py", line 14, in server = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.get

Re: trying to use SOCK_RAW yields error "

2008-08-12 Thread Tzury Bar Yochay
> When using SOCK_RAW, the family should be AF_PACKET, > not AF_INET. Note that you need root privileges to do so. I changed as instructed: server = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.getprotobyname('ip')) now I am getting: Traceback (most recent call last): File "tcpsrv.

Re: Problem with sqlite

2008-03-29 Thread Tzury Bar Yochay
after executing insert do conection.commit() -- http://mail.python.org/mailman/listinfo/python-list

Re: Phyton module for Windows Event Viewer?

2008-05-03 Thread Tzury Bar Yochay
> Can someone point me in the right direction? I'm looking for a module > to monitor the Windows Event Viewer. http://docs.python.org/lib/module-logging.html NTEventLogHandler is the one you should use. happy pythoning -- http://mail.python.org/mailman/listinfo/python-list

Simple UDP server

2008-09-10 Thread Tzury Bar Yochay
concurrent connections? I have no intention of using Twisted or alike since I am looking for making it as lightweight as possible Thanks in advance, Tzury Bar Yochay # begin of snippet from socket import * # Create socket and bind to address UDPSock = socket(AF_INET,SOCK_DGRAM) UDPSock.bind(('&#

Re: Simple UDP server

2008-09-10 Thread Tzury Bar Yochay
On Sep 10, 9:55 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Tzury Bar Yochay wrote: > > Would the one below will be capable of holding 30 concurrent > > connections? > > UDP is a connectionless datagram protocol, so that question doesn't > really m

Re: Simple UDP server

2008-09-10 Thread Tzury Bar Yochay
> Transmitting large binary data over UDP? That makes only sense for few > applications like video and audio streaming. UDP does neither guarantee > that your data is received nor it's received in order. For example the > packages A, B, C, D might be received as A, D, B (no C). > > Can your protoco

writeable buffer and struct.pack_into and struct.unpck_from

2008-09-20 Thread Tzury Bar Yochay
Hi, I can't find in the documentation the way to use these two functions. can someone share a simple code that utilize these two functions? -- http://mail.python.org/mailman/listinfo/python-list

Re: writeable buffer and struct.pack_into and struct.unpck_from

2008-09-20 Thread Tzury Bar Yochay
Thanks Gabriel, I was missing the information how to create a writable buffer. -- http://mail.python.org/mailman/listinfo/python-list