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

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

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

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

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

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

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

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: 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

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: 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

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

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: 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.

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: 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

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

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

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

Re: Inheritance question

2008-03-25 Thread Tzury Bar Yochay
+Functional Programming i guess we will meet somewhere in the middle thanks again tzury -- http://mail.python.org/mailman/listinfo/python-list

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
> 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, 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 > > >

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

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

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

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

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

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

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

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: 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:

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
> 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

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: 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

Having fun with python

2007-10-03 Thread Tzury
def loadResMap(self): self.resMap = [] [[self.resMap.append(str('A2' + sim[0] + '/r' + str(x))) for x in range(1, eval(sim[1])+1)] for sim in [x.split(':') for x in quickViews.smsResList.v.split(",")]] ''' # Confuse

Re: ctypes windll question

2007-08-14 Thread Tzury
I discovered pywin32-210.win32-py2.5 package which does all the work for me. Open Software world is a great place to live by On Aug 14, 12:45 pm, Tzury <[EMAIL PROTECTED]> wrote: > I followed the tutorial about ctypes and I still cannot figure out how > to call a method of a cals

ctypes windll question

2007-08-14 Thread Tzury
I followed the tutorial about ctypes and I still cannot figure out how to call a method of a calss within the dll. For example: a dll named 'foo' contain a class named 'bar' which expose a method named 'baz'. if I either do: mydll = windll.foo mycls = mydll.bar or mycls = windll.foo.bar or myc

ctypes, windll question

2007-08-14 Thread Tzury
I followed the tutorial about ctypes and I still cannot figure out how to call a method of a calss within the dll. For example: a dll named 'foo' contain a class named 'bar' which expose a method named 'baz'. if I either do: mydll = windll.foo mycls = mydll.bar or mycls = windll.foo.bar or myc

Re: MaildirMessage

2007-07-14 Thread Tzury
> What do you actually think > > ... for m in msg: > ... print m > > should do? Why do you believe that what you think it should do would be > a natural choice? I needed to know how to extract particular parts of a message, such as the message 'body', 'subject', 'author', etc. I co

Re: MaildirMessage

2007-07-13 Thread Tzury
ewbie to say so. I found inspect.getmembers(msg) as a good solution to map the message properties. 10x, Tzury -- http://mail.python.org/mailman/listinfo/python-list

MaildirMessage

2007-07-12 Thread Tzury
I am getting the following error when trying to iterate in a message in a Maildir directory. please help. >>> from mailbox import Maildir, MaildirMessage >>> mbox = Maildir('path/to/mailbox', create = False, factory = MaildirMessage) >>> for msg in mbox: ... for m in msg: ... print

Re: Comparing UTF-8 into USC-2 and vice versa (newbie :-) )

2007-06-17 Thread Tzury
Yet, 'utf_16_be' is not 'ucs-2'. How would I get ucs-2 encoding and decoding functionality with python? -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparing UTF-8 into USC-2 and vice versa (newbie :-) )

2007-06-17 Thread Tzury
On Jun 17, 10:48 am, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > > I recently rewrote a .net application in python. > > The application is basically gets streams via TCP socket and handle > > operations against an existing database. > > The Database is SQLite3 (Encoded as UTF-8). > > The Network

Re: Comparing UTF-8 into USC-2 and vice versa (newbie :-) )

2007-06-17 Thread Tzury
On Jun 17, 10:48 am, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > > I recently rewrote a .net application in python. > > The application is basically gets streams via TCP socket and handle > > operations against an existing database. > > The Database is SQLite3 (Encoded as UTF-8). > > The Network

Comparing UTF-8 into USC-2 and vice versa (newbie :-) )

2007-06-17 Thread Tzury
I recently rewrote a .net application in python. The application is basically gets streams via TCP socket and handle operations against an existing database. The Database is SQLite3 (Encoded as UTF-8). The Networks streams are encoded as UCS-2. Since in UCS-2, 'A' = '0041' and when I check with t

Setting System Date And Time

2007-03-13 Thread Tzury
Is it possible to modify the Systems' Date and Time with python? -- http://mail.python.org/mailman/listinfo/python-list

How to query a unicode data from sqlite database

2007-03-03 Thread Tzury
Can anyone tell the technique of composing a WHERE clause that refer to a unicode data. e.g. "WHERE FirstName = ABCD" where ABCD is the unicoded first name in the form that sqlite will match with its records. -- http://mail.python.org/mailman/listinfo/python-list

querying unicode data (sqlite) with python

2007-03-01 Thread Tzury
Given an sqlite db that stores the strings data such as names, etc. encoded in Unicode. How do I write a sql query statement with 'LIKE' or '=' operators and insert the Unicoded name. for example: in table MY_TABLE, in column COL01 there is a value "¿Habla español?" within python I represent thi

Re: Python, Embedded linux and web development

2007-02-27 Thread Tzury
On Feb 27, 2:27 pm, "Paul Boddie" <[EMAIL PROTECTED]> wrote: > On 27 Feb, 13:12, "Tzury" <[EMAIL PROTECTED]> wrote: > > > > > c) small web application that will be used as front end to configure > > the system (flat files and sqlite3 db ar

Python, Embedded linux and web development

2007-02-27 Thread Tzury
Regarding the platform described below, can anyone suggest from his experience what would be the best library choice to develop the following application. a) application that deals with data transformed via TCP sockets. b) reading and writing to and from sqlite3 (include Unicode manipulations). c)