hex notation funtion

2005-01-18 Thread tertius
Hi,
Is there a builtin function that will enable me to display the hex 
notation of a given binary string? (example below)

many thanks
Tertius

()  02 11 00 00 46 5A 1A 82  02 11 00 39 36 39 33 39 
FZ.96939

0016(0010)  36 39 33 00 0A 30 33 37  34 34 39 35 38 25 DD 01 
693..03744958%..
--
http://mail.python.org/mailman/listinfo/python-list


Re: hex notation funtion

2005-01-18 Thread tertius
tertius wrote:
Hi,
Is there a builtin function that will enable me to display the hex 
notation of a given binary string? (example below)

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


Re: HTML expect in python

2005-07-16 Thread tertius
WGW wrote:
> I would like to automate some simple browser navigating using python. 
> Ideally, I would like a package like pyexpect, but that can handle a 
> browser in much the same way as pyexpect handles a terminal (tall 
> order!). In short, I want a macro language for a browser (I know about 
> the commercial packages such as Easy Bee and Internet macros, but I want 
>  more programmability and less cost!)
> 
>

http://pamie.sourceforge.net/


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


Re: exec function

2005-02-12 Thread tertius
[EMAIL PROTECTED] wrote:
I'm a newbie to pthyon and I am creating an app with wxPython.
I have 7 tables (more on the way... they are feed from a database) that
need to be formatted in a certain way (DataTable() does this) and I am
just looking for a cleaner way to pass all of the Grids (grid_1,
grid_2, etc) through the same function.
I am currently doing this (ugly, but it works):
for i in tables.keys():
if datadict.has_key(i):
 t = tables.get(i)
 d = datadict.get(i)
 r = rowdata.get(i)
 exec('self.frame.%s.SetTable(DataTable(d, r[0]), True)' % t)
It works (slowly) and I have read that exec is very slow and bad
form...Can any one give me any pointers to clean this mess up?
frame = a wx.Frame (another file which is imported).
Thanks,
Scott
def getUniqueCustomer(self,idcustomer): #,cols = "*"):
sql = """select * from customer where idcustomer=%d"""%(idcustomer)
self.db.sql_exec(sql)
if self.db.crsr.rowcount == 0:
return None
cols = list([i[0] for i in self.db.crsr.description])
vals = self.db.sql_fetchone()
return  dict(zip(cols,vals))
--
http://mail.python.org/mailman/listinfo/python-list


date diff calc

2004-11-29 Thread tertius
Hi,
Is there a more pythonic way to write or do a date difference 
calculation? I have as input two date fields in the form '-MM-DD'

TIA
Terius

from datetime import date
bdl = '2004-11-25'.split('-')
edl = '2004-11-30'.split('-')
bd = date(int(bdl[0]),  int(bdl[1]),  int(bdl[2]))
ed = date(int(edl[0]),  int(edl[1]),  int(edl[2]))
print ed , '-', bd , '=', (ed-bd).days
--
http://mail.python.org/mailman/listinfo/python-list


Re: date diff calc

2004-11-29 Thread tertius
Diez B. Roggisch wrote:
 >
I can't imagine what could possibly be easier than subtracting two dates -
in fact, most times one has to jump through much more hoops to achieve
these results, e.g. in java.
I'll try that.
Thanks,
T
--
http://mail.python.org/mailman/listinfo/python-list


Re: Recording Video with Python

2005-04-09 Thread tertius
[EMAIL PROTECTED] wrote:
Is there a video module so that I can write a Linux Python script to
record video coming over USB video cams?
http://videocapture.sourceforge.net/
HTH
T
--
http://mail.python.org/mailman/listinfo/python-list


RE: Good use for Jython

2005-03-16 Thread Tertius Cronje
> Other than being used to wrap Java classes, what other real use is
> there for Jython being that Python has many other GUI toolkits
> available? Also, these toolkits like Tkinter are so much better for
> client usage (and faster) than Swing, so what would be the advantage
> for using Jython? or Is Jython really just so that Java developers can
> write Java code faster?
> 

Just as many on this list, my favorite development
tool/language/environment is Python. However as nice as it is, there are
many frameworks and business applications that is written and packaged
in Java (i.e. X25 comms Libraries, log4J *before* python brought out
logging) _OR_ has a Java remote interface that must be accessed (EJB
/JMS / RMI etc...) _OR_ has a library you prefer to use of over the
python implementation (not a lot of those).

Jython allows one to use these packages using ones language of choice :)

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


Static parameter count

2005-03-17 Thread Tertius Cronje
Hi all,
This does not feel Pythonic. Is there a better way to do the same?

Many TIA
T


  # L = [1,2,3,4,5,6, etc]
  # L can contain 'n' elements
# fmt is made up to each particular specification

if len(L) == 0:
return ''
elif len(L) == 1:
return struct.pack(fmt,L[0] )
elif len(L) == 2:
return struct.pack(fmt,L[0] , L[1])
elif len(L) == 3:
return struct.pack(fmt,L[0] , L[1], L[2])
elif len(L) == 4:
return struct.pack(fmt,L[0] , L[1], L[2], L[3])
elif len(L) == 5:
return struct.pack(fmt,L[0] , L[1], L[2], L[3], L[4])
elif len(L) == 6:
return struct.pack(fmt,L[0] , L[1], L[2], L[3], L[4], L[5])

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


RE: Static parameter count

2005-03-17 Thread Tertius Cronje
> > elif len(L) == 5:
> > return struct.pack(fmt,L[0] , L[1], L[2], L[3], L[4])
> > elif len(L) == 6:
> > return struct.pack(fmt,L[0] , L[1], L[2], L[3], L[4],
L[5])
> >
> > # etc... etc... etc ...
> 
> return struct.pack(fmt, *L)
> 
> Should do the trick
> 
> ola
> 

Many thanks! It *did* the trick!

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


inter threading info

2005-03-23 Thread Tertius Cronje
Hi All,

Q: Is it possible for a thread on SocketServer.ThreadingTCPServer to get
the socket info of *other* open thread/s and use that info to send data
to the accepting client?

I wrote a socketserver using SocketServer.ThreadingTCPServer. A client
is connected to the server and expects multiple request/responses. (Not
sure about the terminology but the client connects and then stay
connected for a while.)

I need to create a client that can connect to server and then determine
how many other clients are connected, what the socket info is
(ifile/ofile) and then send and receive specific data to those clients. 

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


RE: inter threading info

2005-03-23 Thread Tertius Cronje

> -Original Message-
> From: [EMAIL PROTECTED]
>
[mailto:[EMAIL PROTECTED]
On
> Behalf Of Daniel Dittmar
> Sent: Wednesday, March 23, 2005 4:46 PM
> To: [email protected]
> Subject: Re: inter threading info
> 
> Tertius Cronje wrote:
> 
> > Q: Is it possible for a thread on SocketServer.ThreadingTCPServer to
get
> > the socket info of *other* open thread/s and use that info to send
data
> > to the accepting client?
> 
> A specific socket can be used from every thread of a process. Just
make
> sure that you synchronize everything.
> 
> > I need to create a client that can connect to server and then
determine
> > how many other clients are connected, what the socket info is
> 
> When you accept a socket client, a new socket is created, so you
cannot
> determine how many clients are connected to a socket. You have to
create
> a data structure where you insert info about accepted connections and
> delete the info when a connection is closed.

I was thinking of a dict or list _global_ to the
StreamRequestHandler.handle() method. That way I can pass the info on
with every new connection where the server will have access to it.

> 
> > (ifile/ofile) and then send and receive specific data to those
clients.
> 
> ifile/ofile are local to the server process so you cannot use them to
> send data from one client to another client. You have to send the data
> to the server first with a special tag, the server has to use that tag
> and send the data to the designated other client.

That's what I had in mind thanks. The server needs to keep track of all
the connected clients. 

> 
> It sounds a bit as if you want to build some kind of chat server and
now
> you want to add private channels.
>
Sounds like it but isn't. I'm busy developing a test/mock harness for a
financial switch. Currently it caters only for messages from the client
to the harness and then back. I need to add functionality that when an
_external_ message arrives, the switch can determine which client it
needs to send the data to.

Many thanks
Tertius
--
http://mail.python.org/mailman/listinfo/python-list


hex string into binary format?

2005-03-31 Thread Tertius Cronje
Hi, 

How do I get a hexvalued string to a format recognized for binary
calculation?


import binascii
s1 = '1C46BE3D9F6AA820'
s2 = '8667B5236D89CD46'

i1 = binascii.unhexlify(s1)
i2 = binascii.unhexlify(s2)
x = i1 ^i2

TypeError: unsupported operand type(s) for ^: 'str' and 'str'

Many TIA
T
--
http://mail.python.org/mailman/listinfo/python-list


RE: Generating RTF with Python

2005-03-31 Thread Tertius Cronje
I'll use http://www.tug.org/ or a smaller solution
http://lout.sourceforge.net/ together with one of many Python template
solutions to generate to generate reports.

HTH
T

> -Original Message-
> From: [EMAIL PROTECTED]
>
[mailto:[EMAIL PROTECTED]
On
> Behalf Of Andreas Jung
> Sent: Thursday, March 31, 2005 4:02 PM
> To: [email protected]
> Subject: Generating RTF with Python
> 
> Hi,
> 
> does anyone know of a high-level solution to produce RTF from Python
> (something similar to
> Reportlab for producing PDF)?
> 
> Thanks,
> Andreas
--
http://mail.python.org/mailman/listinfo/python-list