Hey all,
I have been trying to get my head around how to do something, but i am
missing how to pull it off.
I am reading a packet from a radio over a serial port.
i have " two bytes containing the value i need. The first byte is the
LSB, second is MSB. Both bytes are BCD-encoded, with the LSB
c
Hey all,
I have been trying to get my head around how to do something, but i am
missing how to pull it off.
I am reading a packet from a radio over a serial port.
i have " two bytes containing the value i need. The first byte is the
LSB, second is MSB. Both bytes are BCD-encoded, with the LSB
c
hello all,
i have a c function from some modbus documentation that i need to
translate into python.
it looks like this:
unsigned short CRC16(puchMsg, usDataLen)
unsigned char *puchMsg ;
unsigned short usDataLen ;
{
unsigned char uchCRCHi = 0xFF ;
unsigned char uchCRCLo = 0xFF ;
unsigne
[EMAIL PROTECTED] wrote:
> nephish:
> > one more question.
> > the functions defined above the classes that the could be called from
> > within the classes, they do not need a 'self' declaration because they
> > are not part of a class, right?
>
> Class
nephish wrote:
> [EMAIL PROTECTED] wrote:
> > nephish:
> > > is this legal ? is it pythonic?
> >
> > It's legan and pythonic. Functions are here for a purpose.
> >
> > Bye,
> > bearophile
>
> cool enough, and thanks for the quick reply
[EMAIL PROTECTED] wrote:
> nephish:
> > is this legal ? is it pythonic?
>
> It's legan and pythonic. Functions are here for a purpose.
>
> Bye,
> bearophile
cool enough, and thanks for the quick reply.
shawn
--
http://mail.python.org/mailman/listinfo/python-list
lo there all,
i have an app that runs three classes as threads in the same program.
some of them need to be able to share some functions. Can i set a
function before i define a class and have the class use it ? Kinda like
this.
def some_function(var1, var2):
do something with var1, var2
r
very helpful indeed.
i did a help([]) to see if it would give me anything for a list.
wow.
thanks a lot.
-sk
Terry Reedy wrote:
> The easy way to get one answer for buildin funcs and methods is the help
> function in the interactive interpreter (and Idle's and probably other
> imitations thereof)
yep, easy enough
thanks
-shawn
Jorge Godoy wrote:
> "nephish" <[EMAIL PROTECTED]> writes:
>
> > i have seen the join method before, mostly in this group and i want to
> > get it a little better.
> >
> > if i have a list
> >
>
i have seen the join method before, mostly in this group and i want to
get it a little better.
if i have a list
x = ['this','is','a','sentence','held','in','a','list']
how can i make it print as a single string? or make a single string out
of it ?
thanks
--
http://mail.python.org/mailman/list
N(32); # this is the serial number of
the unit
unsigned long int ESN # serial number of the communicator
unsigned long int userID
thanks again guys.. i think we're getting closer.
-sk
John Machin wrote:
> Marc 'BlackJack' Rintsch wrote:
> > In <[EMAIL PROTECTE
ok. indeed i did do '' instead of ' '.
here is an example of a message
'STX\x00\x00\x004\x00\x00\x00\xc8stateman\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00state1man\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00ENX'
tohex gave me '53 54 58 00 00 00 34 00 00 00 c8 70 6
ok, i did this print ' '.join(["%02.2x" % ord(b) for b in message])
and i got this in the text file
535458002c00ea31373538343636383535d6090d54454e58
so, yes, more of the info seems discernable now.
according to their docs, all of their va
hello there, all.
i have a difficult app that connects to a server to get information for
our database here.
this server is our access point to some equipment in the field that we
monitor.
the messages come in over a socket connection. And according to their
(very limited) documentation, are set
hey thanks for that last post, although some of it was a bit over my
head.
i think i am getting more of the differences here.
thanks again,
sk
danielx wrote:
> [EMAIL PROTECTED] wrote:
> > Hey there,
> > i have been learning python for the past few months, but i can seem to
> > get what exactly a
so a lamda needs to stay at one expression, and use more than one lamda
for more expressions ?
i think i get it.
sk
Nick Vatamaniuc wrote:
> Use it anywhere a quick definition of a function is needed that can be
> written as an expression. For example when a callback function is
> needed you cou
ok, i think i get it.
pretty cool.
thanks
-sk
Dan Bishop wrote:
> [EMAIL PROTECTED] wrote:
> > Hey there,
> > i have been learning python for the past few months, but i can seem to
> > get what exactly a lamda is for.
>
> It defines a function.
>
> f = lambda x, y: expression
>
> is equivalent to
Hey there,
i have been learning python for the past few months, but i can seem to
get what exactly a lamda is for. What would i use a lamda for that i
could not or would not use a def for ? Is there a notable difference ?
I only ask because i see it in code samples on the internet and in
books.
th
ok, yeah, thats in my book.
thanks, and no, it isn't enabled.
thanks again for everything
-sk
Grant Edwards wrote:
> On 2006-07-17, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >> If the server _application_ crashes or exits, then the OS will
> >> close the socket and recv() will return "". If
> If the server _application_ crashes or exits, then the OS will
> close the socket and recv() will return "". If somebody powers
> down the server without warning, or if the server OS crashes,
> or if the Ethernet cable between the Internet and the server is
> cut, then the socket will not be clo
oh, sorry, what i mean by dropped is that the server i am connecting to
can close the connection. If that happens, i need to know about it.
i also need to know about it if the server i am connecting to just
dies.
if recv() returns "" is that the same as NONE ?
again, sorry, i am still kinda new at
hey there, i have a question about this solution.
if i have a
message = socket.recv()
in the script, and the socket connection drops, will the
socket.recv() just wait forever for something to come across
the internet port? or will it know if the connection is dropped?
thanks.
-sk
Grant Edwards wr
cool enough, thanks !
-sk
Grant Edwards wrote:
> On 2006-07-16, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> >> If the server has closed the connection, then a recv() on the
> >> socket will return an empty string "", and a send() on the
> >> socket will raise an exception.
>
> > like this ?
are not most (or all) of these copywrite protected ?
thats why i have not pulled some of them myself,
you can get most of them used from amazon for
about $10
[EMAIL PROTECTED] wrote:
> http://cooldogebooks.blogspot.com/2006/05/python-ebooks.html
>
> Here is a cool site were you can preview python
Grant Edwards wrote:
> On 2006-07-16, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > serverhost = 'xxx.xxx.xxx.xxx'
> > serverport = 9520
> > aeris_sockobj = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> > aeris_sockobj.connect((serverhost,serverport))
> >
> > while 1:
> > do this or
lo there,
i have a simple app that connects to a socket to get info from a server
i looks like this
serverhost = 'xxx.xxx.xxx.xxx'
serverport = 9520
aeris_sockobj = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
aeris_sockobj.connect((serverhost,serverport))
while 1:
do this or that with
cool, thanks, i was running on some thinner examples i found on the
net.
--
http://mail.python.org/mailman/listinfo/python-list
ok, what i posted above had the getOne method, the whole class has a
function for getMany, update, and Insert.
none of this will be used by an end user, it kinda runs in the
background. But, if you have a good link to the docs on the API, i
would like to see it. Still kinda new at this.
thanks
-
ok, thanks everyone. The funny thing about the name conventions is, i
was just two days ago looking around on the web for the best way to go
about consistancy in variable names, class names, etc..
i have the module working now. thanks to you guys. And i think i
understand the container name | obje
yeah, i have thought of picking that one up. That one, or nutshell.
i got programming python, which was way over my head, then learning
python, which has helped me a great deal.
thanks
--
http://mail.python.org/mailman/listinfo/python-list
ok, cool, and thanks very much. That worked.
thanks for the info too.
i am still new at the OO thing, just tired of doing a copy and paste
over and over again.
thanks again
--
http://mail.python.org/mailman/listinfo/python-list
ello there. i am having a problem getting a module to work right.
i wrote a class that is going to be used in a few different scripts in
the same directory.
it looks like this:
#!/usr/bin/python
import MySQLdb
class DbConnector(object):
"""
Database Connection object.
c
way cool, i think that this will work.
thanks very much
-sk
--
http://mail.python.org/mailman/listinfo/python-list
So this opens and closes the connection every time i run the query?
thats cool. i think that would fit in well. so when i need to run the
query, i pass something like
query = "SELECT * FROM `Table` WHERE `foo` = 'bar'"
result = DB_Connector.Execute(query)
and the result would be the same as if i
This is great !
ok, i dont really have a lot of time to get into the ORMS (before your
post, this is the first i have heard of it) and my stuff is due on
Monday. he he.
but, if i am able to make a global db connection, and multiple cursors
pointing to the same connection object, how do i pull tha
hey there,
i have a huge app that connects to MySQL. There are three threads that
are continually connecting and disconnecting to the db. The problem is,
if there is an error, it faults out sometimes without closing the
connection. i connect like this.
db = MySQLdb.connect(host="localhost", user="M
yeah, he he
--
http://mail.python.org/mailman/listinfo/python-list
ok, every message starts with "ENX" and ends with "STX"
in between are several parts. the first is the message length sent as
an unsigned long int (according to the docs) this is four bytes. The
next is the message type - another 4 bytes that corrospond to a certain
chart. for example, the login is
ok, thanks for all the suggestions, gents, i clearly have more to read
on this.
i have discovered that the server will send a request for the heartbeat
ping if its almost timed out, so i use the length of the message to
determine what to do with it.
msg = sockobj.recv(1024)
if len(msg) == 158:
thanks for the info, i will likely use the first link you posted with
the async module just to get it going, but i want to learn more about
twisted for later. there is even an O'Reilly book on it i see.
thanks for the tips,
sk
--
http://mail.python.org/mailman/listinfo/python-list
hey there,
i have a script that waits for message packets from a data server over
a socket.
it goes a little like this:
while 1:
x+=1
databack = sockobj.recv(158)
if databack:
print 'caught a message %s bytes ' % len(databack)
if len(databa
i think it may be,
i am just doing a while 1: loop to just wait for whatever comes in.
thanks
--
http://mail.python.org/mailman/listinfo/python-list
lo there all !
i finally got my script to receive info on a socket. but i need to
somehow set up a loop that will continue to listen for more info
comming across the same socket.
the way it works is, i log in with a login and password, it shoots back
an acknowlagement, then i send a request for d
sounds cool, most stuff i write is strife with try - except
thanks for the tip
-sk
--
http://mail.python.org/mailman/listinfo/python-list
wow , thanks for the tips and the link.. i can at least see whats going
on here.
this project is beginning to look believable to me.
i have another question.. later , in this same class, after it goes
thru some error handling, it returns like this
return COM_SUCCESS;
but i cannot find where COM_SU
pyconstruct looks cool. i dont know if the classes are using the plain
berkely-ish code. i couldn't find anything in it that pointed to send()
recv(), & such. i found other stuff like SetSocketOpt() and so on like
this :
long CClientSocket::ConnectToServer(LPCTSTR serverAddr, UINT port)
{
ok, well enough, looked at struct and it does seem to be what i am
after. for that anyway.
thanks, guess i will just have to take the time and pull it apart.
cheers
sk
--
http://mail.python.org/mailman/listinfo/python-list
lo there all !
i have a huge delima, i have to be able to connect to a data server and
recieve info from it. The servers software guys release some visual C++
modules that one can incorporate into a visual C++ project. Which is
great, but i am developing in linux, and only am very familliar with
p
cool, thank you very much
--
http://mail.python.org/mailman/listinfo/python-list
hello there, i have recently been tasked with grabbing info to pipe
into our database from an information server. The server guys told me i
need to grab their wsdl file. Untill earlier this afternoon, i had no
idea what wsdl is. From what i gather, it is much like SOAP.
So anyway, any pythoneers ou
indeed i did not. thanks for the tip.
--
http://mail.python.org/mailman/listinfo/python-list
ok, i am stuck again.
from the docs, the byte stream is supposed to look like this:
'S' 'T' 'X' [length indicator] [message type] [message] 'E' 'N' 'X'
the length indicator it says is a four byte integer number of a value N
( N would be how long the message body is )
the message type comes f
i'm not sure, but its kinda been a pain in the hinder for a newbie like
me to find it in their docs.
thanks for all the help guys, let you know how it goes
--
http://mail.python.org/mailman/listinfo/python-list
i know that those characters exist, the docs say that the server does
not want the special "ETX" and "STX" characters, but the 3 ascii
characters "STX" and "ENX" i am not sure why.
--
http://mail.python.org/mailman/listinfo/python-list
ok, part of what i have to do is know how many bytes will be sent. in
ascii is it one byte per character ?
like "password" would be 8 bytes long?
--
http://mail.python.org/mailman/listinfo/python-list
i think like byte 1 = 'S'
byte 2 = 'T'
and byte 3 = 'X'
still new at this, and thanks for the references
-sk
--
http://mail.python.org/mailman/listinfo/python-list
Thanks guys,
No, i did not know about isdigit ?
very helpful. Thanks.
esp liked the "overloaded doohicky' bit.
thanks again.
--
http://mail.python.org/mailman/listinfo/python-list
Hello there,
i need to write a script that can transfer info back and forth with a
data server at so-and-so ip.
i have Programming Python, which covers socket programming. So thats
cool. But what i need to know how to do is make a message in ascii that
is what the server is looking for.
for examp
it isn't really that i will want to change it to an integer anyway. the
script uses a table to reference a value to a key, if the key is a
group of letters, that code tells the script to do something. if the
value is a number, it means an equipment failure. The thing is, all the
values come out as
this looks like the solution i am looking for. thanks for the education
by the way.
i have a couple of other try / except clauses. Never thought of pulling
it off like that.
thanks very much, really simple.
--
http://mail.python.org/mailman/listinfo/python-list
thanks for the reply, but wont python fail out if you try to make an
integer out of what cant be an integer?
like this :
var = int(abc)
wont this crash ?
--
http://mail.python.org/mailman/listinfo/python-list
Hello there,
i need a way to check to see if a certain value can be an integer. I
have looked at is int(), but what is comming out is a string that may
be an integer. i mean, it will be formatted as a string, but i need to
know if it is possible to be expressed as an integer.
like this
var = some
>I agree -- "to each day are sufficient the evils thereof". Many
>programmers fall into the temptation to overgeneralize and fail to
>follow the AGNI principle ("Ain't Gonna Need It"...;-).
thats funny :)
--
http://mail.python.org/mailman/listinfo/python-list
the second line was not a typo , and thanks for that.
these values may vary somewhat over time. So i may have to rewrite this
part of the script.
a string is fine for right now, because it is just going to be pumped
into a database. i can change it later if necessary.
thanks for the help gents, i
hey there,
i have looked at the string module and re.
i was looking for advice on what would be the best way to pull a value
out of a small string.
for example, i have a string
$.+.09 JAR
and all i want out of it is the +.09
likewise, i have
$-.04 TIN kt
and all i want is the -.04
what wou
um, wait. what you are doing here is easier than what i was doing after
your first post.
thanks a lot. this is going to work out ok.
thanks again.
sk
--
http://mail.python.org/mailman/listinfo/python-list
this is cool, it is only going to run about 10 times a day,
the text is not written out like foo(bar) its more like
foo blah blah blah (bar)
the thing is , every few days the structure of the textfile may change,
one of the reasons i wanted to avoid the re.
thanks for the tip,
--
http://mail.p
Hey there,
i have a text file with a bunch of values scattered throughout it.
i am needing to pull out a value that is in parenthesis right after a
certain word,
like the first time the word 'foo' is found, retrieve the values in the
next set of parenthesis (bar) and it would return 'bar'
i think
well, i think thats the case, looking at the code, there is a long
string of math functions in page, java math functions. h. i guess
i'm up that famous creek.
thanks for the info, though
shawn
--
http://mail.python.org/mailman/listinfo/python-list
thats cool, but i want to do this automatically with python.
what can i do to have urllib download the source with the numbers in
it?
ok, not necessarily urllib, whatever one is best for the occation
thanks
shawn
--
http://mail.python.org/mailman/listinfo/python-list
hey there,
i am using beautiful soup to parse a few pages (screen scraping)
easy stuff.
the issue i am having is with one particular web page that uses a
javascript to display some numbers in tables.
now if i open the file in mozilla and "save as" i get the numbers in
the source. cool. but i click
yeah, i know i am going to have to write a bunch of stuff because the
values i want to get come from several different sites. ah-well, just
wanting to know the easiest way to learn how to get started. i will
check into beautiful soup, i think i have heard it referred to before.
thanks
shawn
--
ht
hey there,
i have a small app that i am going to need to get information from a
few tables on different websites. i have looked at urllib and httplib.
the sites i need to get data from mostly have this data in tables. So
that, i think would make it easier. Anyone suggest a good starting
point for
well i know i dont want to do another thread, my program has six
running all the time.
whew. that can get nuts.
i mean, this will come to me easier later i am sure. But right now.
simple is best.
thanks for all the suggestions, gents.
right now i am just doing a varient of Steves suggestion, an
man, thats just too easy.
thanks much !
--
http://mail.python.org/mailman/listinfo/python-list
hey there all,
i have been looking for a way to run a php command line script from my
python script.
here is what i want to do:
if x = 4:
execute php4 testin.php
else:
execute php4 testout.php
and i also need the script to wait untill the php4 script is done
(which i think is the default
WE DID IT !
little more tinkering and correcting this
diff = start_time - end_time (vrs the other way around)
and its working.
so many thanks gents, a lot !
--
http://mail.python.org/mailman/listinfo/python-list
tics.append('"%s" %s' % (time.strftime(...), x))
# might need time.localtime(x) for that last term.
ok, tried this and it worked.
but the first plot is at the last plot of data
back to that math mistake i mentioned earlier.
so, thanks much, i will be back when i mess around with it some m
Ok, first off, thanks for all the help guys,
this part " set xtics ("label" pos, "label" pos, "label" pos) "
is mainly what i was confused about. the 'pos' part. i think that the
way i am writing
this leaves this out. in fact, i am pretty sure.
here is the code i am trying out.
def draw_chart(s
well, for what i tried, ticstrings just contained a list of times
formatted like
[10-21 09:15, 10-21 09:44, 10-21 09:59, and so on.]
i did write mine a little different than the example that Grant gave me
because its a little
different application of time.
i think i am having trouble knowing e
ok, i am stuck a bit here with this line
gp('set xtics (%s)' % ','.join(ticstrings))
the error code says that it is looking for a closing parenthesis.
that and i am kinda new enough not to really get what %s is all about.
i know it formats a string.
can you simply pass a list to 'set xtics' ?
i
this is great, because the docs on gnuplots website are a bit easier
for me to grasp.
thanks so much for your time on this one. you really have helped me a
lot.
i will not get a change to work on this till monday. so i may have more
questions then. This is sure a point in the right direction.
than
ok, i have a display, and its a work in progress.
lemme get this straight. you used
gp('set term png')
is this an example of sending normal gnuplot commands?
if so, are all of the gnuplot commands available ?
thanks so much this is helping me out a lot here
--
http://mail.python.org/mailman/li
the time is DateTime.DateTime object from a mySQLdb query.
the value is a number anywhere between 0 and 15.
the datetime is formatted like 2005-10-20 08:40:34
i could strip it and make a timestamp out of it. but reading the
number of seconds since january of 1970 doesn't make a neat chart.
any su
ok, i tried something similar to what you posted.
a little simpler though.
i am running a query on a database and making a list of time, value
pairs
kinda like this
plot_points = ([time, value], [time, value], [time, value])
gnuplot complains that it needs a float for one of the values.
i can plot
ok, yeah, thats exactly what i am looking for. i will give it a go.
thanks a whole lot.
putt this off is a typo, pull this off is what i was meaning to type.
this is cool.
--
http://mail.python.org/mailman/listinfo/python-list
i have thought about doing this, just a little different. i was going
to list the value pairs.
take the start time and end time and plot 100 empty plots between them.
add the value pairs, sort by time, and then draw it. The only thing is
it get kinda complicated when the times change a lot. they co
how ?
i have tried to use unix timestamps, and i have also tried with
DateTime objects
do i need to use a scale that isn't linear (default in most) ?
how do i putt this off ?
thanks btw.
sk
--
http://mail.python.org/mailman/listinfo/python-list
Hey there,
i have tried about every graphing package for python i can get to work
on my system. gnuplot, pychart, biggles, gdchart, etc.. (cant get
matplot to work)
so far, they all are working ok. I need to make an x y chart for some
data that comes in from sensors at different times durring the d
thanks for all the help,
got it working ok now, connecting once, sending many.
thanks for the link too.
cheers,
sk
--
http://mail.python.org/mailman/listinfo/python-list
cool. so this line
server = smtplib.SMTP(localhost)
is when i connect ?
i had my syntax wrong anyway, i was using server.close()
instead of server.quit()
thanks much
--
http://mail.python.org/mailman/listinfo/python-list
Hey there,
i am using the smtplib module in python 2.3
my question is, this works:
server = smtplib.SMTP(localhost)
then server.sendmail(to address, from address, message)
what i want to know is, how does the connection work?
when i do server.sendmail, does it connect then ? or did it connec
cool, thanks
-shawn
--
http://mail.python.org/mailman/listinfo/python-list
Hey there pythoneers
i have another question about time, specifically, the mxDateTime
module.
i have been able to get a RelativeDateTimeDiff between two times,
it gives me a difference between two DateTimes in the form of +3days
+2hours etc...
so, if i have a date that is 6 days and 6 hours from
hey,
a little update.
i got the pychart working
the examples did not include the necessary #!/usr/bin/python
its like being a literary critic forgetting how to spell his name.
thanks for your help getting the deb package going.
i should be all good now.
sk
--
http://mail.python.org/mailman/list
sorry about that, i got a message in my inbox that said that the post
was rejected
so i tried it from my email client.
wont happen again.
shawn
--
http://mail.python.org/mailman/listinfo/python-list
Hey there,
i am doing a plotting application.
i am using mxRelativeDateTimeDiff to get how much time is between
date x and date y
now what i need to do is divide that time by 20 to get 20 even time
slots
for plotting on a graph.
For example, if the difference between them is 20 hours, i need 20
Hey there,
i am doing a plotting application.
i am using mxRelativeDateTimeDiff to get how much time is between
date x and date y
now what i need to do is divide that time by 20 to get 20 even time
slots
for plotting on a graph.
For example, if the difference between them is 20 hours, i need 20
p
oh wait.
never mind , i figgured it out!
thanks anyway
--
http://mail.python.org/mailman/listinfo/python-list
heres the deal.
i am working on a threading gui. pygtk
in one class (main) is all the gui stuff,
but in another class that is a thread, i am reading serial input.
what i want to be able to do is take what read in the thread and
print it in a textview in the gui class.
here is what i have:
class
1 - 100 of 151 matches
Mail list logo