[Tutor] problem with socket connection

2009-12-21 Thread shawn bright
Hey all, I keep getting a connection error 111 connection refused. When i try to connect to a server at a remote ip address. I am using linux on both computers. the socket server looks like this: #!/usr/bin/python import SocketServer class MyTCPHandler(SocketServer.BaseRequestHandler): def

[Tutor] problem with socket connection

2009-12-21 Thread shawn bright
Hey all, I keep getting a connection error 111 connection refused. When i try to connect to a server at a remote ip address. I am using linux on both computers. the socket server looks like this: #!/usr/bin/python import SocketServer class MyTCPHandler(SocketServer.BaseRequestHandler): def

Re: [Tutor] how to know if process is running?

2009-07-28 Thread shawn bright
n_pattern if you > watch at the sample implementation, there is a Python example too. > > Mac. > > On Tue, 2009-07-28 at 10:45 -0500, shawn bright wrote: >> Hey all, >> >> I have an app that runs in a GUI written in pygtk. It spawns several >> threads, and r

Re: [Tutor] how to know if process is running?

2009-07-28 Thread shawn bright
Thanks for the pointers Wayne, Tino, Looks easier than i had thought. sk On Tue, Jul 28, 2009 at 11:10 AM, Tino Dai wrote: > On Tue, Jul 28, 2009 at 11:45 AM, shawn bright wrote: >> >> So, my question is, how can i write something that will know if there >> is an insta

[Tutor] how to know if process is running?

2009-07-28 Thread shawn bright
Hey all, I have an app that runs in a GUI written in pygtk. It spawns several threads, and runs all the time. It is mission critical that we can never have two instances of this running at once. So, my question is, how can i write something that will know if there is an instance of that something

Re: [Tutor] how to get variable from an external script or program

2009-05-29 Thread shawn bright
cool, thanks again sk On Fri, May 29, 2009 at 5:09 PM, Alan Gauld wrote: > > "vince spicer" wrote >> >> import commands >> output = commands.getout("ls -lah") > > There are many ways to do this in Python including os.popen, commands and > subprocess. > > But subprocess is the "officially correct

Re: [Tutor] how to get variable from an external script or program

2009-05-29 Thread shawn bright
kick butt, gents, thanks a lot sk On Fri, May 29, 2009 at 4:39 PM, W W wrote: > On Fri, May 29, 2009 at 4:27 PM, shawn bright wrote: >> >> Hey all >> >> I have a small program that when run from the command line, will >> return a certain value for an argueme

[Tutor] how to get variable from an external script or program

2009-05-29 Thread shawn bright
Hey all I have a small program that when run from the command line, will return a certain value for an arguement. Like this: > mfetchz 45 > 45j so the program is mfetchz and the argument is 45 i know i can call the program with os.system("mfetchz 45") but how do i get the return? The OS is lin

Re: [Tutor] how to run a process forever

2008-12-10 Thread shawn bright
cool thanks for the help. -shawn On Wed, Dec 10, 2008 at 1:29 PM, Steve Willoughby <[EMAIL PROTECTED]> wrote: > On Wed, Dec 10, 2008 at 01:15:18PM -0600, shawn bright wrote: >> Sorry, was not very specific in my request. >> >> say i have a script like >> >

Re: [Tutor] how to run a process forever

2008-12-10 Thread shawn bright
cesses (so I'm told). > -HTH, > Wayne > On Wed, Dec 10, 2008 at 12:28 PM, Steve Willoughby <[EMAIL PROTECTED]> > wrote: >> >> On Wed, Dec 10, 2008 at 12:23:48PM -0600, shawn bright wrote: >> > Hey gents, >> > >> > I have an interesting problem

[Tutor] how to run a process forever

2008-12-10 Thread shawn bright
Hey gents, I have an interesting problem. I need to have a python script start when a computer boots up, and i need it to run forever. I also am going to run a script by cron that will check to see if the process is running, if not, i need a python script to execute the script. What would be a go

[Tutor] best way to run several processes over and over

2008-12-05 Thread shawn bright
Hey all. I have a rather large app that uses 14 threads that all run at the same time. i use threading.Thread().start() to set them off. each one runs somthing like this def run(): while 1: do a bunch of stuff time.sleep(60) i have the option i guess of having fewer thread

[Tutor] serial port, revisited, but closer

2008-11-05 Thread shawn bright
Hey all, I am back again with the serial port stuff, i have verified that all the baud rate and settings are ok, had my unit talk directly to a serial port reader and it is looking good, however, i still am not seeming to be able to read this. I had a question that might make me a clue. if i do t

Re: [Tutor] how to read over serial port

2008-11-03 Thread shawn bright
, Nov 3, 2008 at 10:14 PM, Brian C. Lane <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > shawn bright wrote: >> Forgot some info, >> i hooked the device up and used a serial terminal and got back stuff like >> this >> !^V$G(

Re: [Tutor] how to read over serial port

2008-11-03 Thread shawn bright
, Jerry Hill <[EMAIL PROTECTED]> wrote: > On Mon, Nov 3, 2008 at 4:08 PM, shawn bright <[EMAIL PROTECTED]> wrote: >> yes, they look like this >> �� >> >> so i used your print repr(chr(ord(i))) and got this > > Note that that's the

Re: [Tutor] how to read over serial port

2008-11-03 Thread shawn bright
#x27;J' 's' '\xde' '\xc0' '\xce' '\xcc' '\x06' '\n' '\x00' '\x00' ' ' '\xaf' 'J' 's' '\xde' '\xc0' so, what do i do now? and thanks for the info

Re: [Tutor] how to read over serial port

2008-11-03 Thread shawn bright
d(i)) i get the same weird characters. should these be read some other way? thanks, shawn On Mon, Nov 3, 2008 at 8:14 AM, shawn bright <[EMAIL PROTECTED]> wrote: > Hey all, sorry, but am i supposed to be using 'rb' to read this? > thanks > > sk > > On Sun, N

Re: [Tutor] how to read over serial port

2008-11-03 Thread shawn bright
Hey all, sorry, but am i supposed to be using 'rb' to read this? thanks sk On Sun, Nov 2, 2008 at 11:50 AM, shawn bright <[EMAIL PROTECTED]> wrote: > Thanks all, > Yeah, checked the settings, and when i have the thing talk to a > program that just prints out whatever

Re: [Tutor] how to read over serial port

2008-11-02 Thread shawn bright
same problem. Just don't know how to read it. thanks shawn On Sun, Nov 2, 2008 at 9:38 AM, Brian C. Lane <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > shawn bright wrote: >> Hey there all, >> >> I have a gps device that tal

Re: [Tutor] how to read over serial port

2008-11-01 Thread shawn bright
the fields of data. thanks for any suggestions on this. shawn On Sat, Nov 1, 2008 at 11:02 PM, bob gailer <[EMAIL PROTECTED]> wrote: > shawn bright wrote: >> >> Hey there all, >> >> I have a gps device that talks to the computer over a serial port. >> i a

[Tutor] how to read over serial port

2008-11-01 Thread shawn bright
Hey there all, I have a gps device that talks to the computer over a serial port. i am using the pyserial module and getting values in. Here is my delima, i am supposed to read a message in that starts with a $ (this is all ascii). but when i do a ser.read(16) and i try to print it to a screen,

Re: [Tutor] how to see a number as two bytes

2008-10-21 Thread shawn bright
Thanks for all your help on this, gents. found what works. shawn On Mon, Oct 20, 2008 at 6:06 PM, Alan Gauld <[EMAIL PROTECTED]>wrote: > "shawn bright" <[EMAIL PROTECTED]> wrote > > i have a script that needs to send a number as two bytes. >> how would i b

Re: [Tutor] Fwd: how to see a number as two bytes

2008-10-20 Thread shawn bright
reasonable but I can't be sure. > > On Mon, Oct 20, 2008 at 11:20 AM, shawn bright <[EMAIL PROTECTED]> wrote: >> jeez, i screwed up, i ment num = 600, not 6 >> thanks >> >> On Mon, Oct 20, 2008 at 11:16 AM, Luke Paireepinart >> <[EMAIL P

Re: [Tutor] Fwd: how to see a number as two bytes

2008-10-20 Thread shawn bright
left, > 01101011 > and that is your low value. > > On Mon, Oct 20, 2008 at 11:04 AM, shawn bright <[EMAIL PROTECTED]> wrote: >> so using this, if num ==6, then i should get 2 and 88 ? >> thanks, just checking to make sure i get what you wrote. >> sha

Re: [Tutor] Fwd: how to see a number as two bytes

2008-10-20 Thread shawn bright
D]> > Date: Mon, Oct 20, 2008 at 11:00 AM > Subject: Re: [Tutor] how to see a number as two bytes > To: shawn bright <[EMAIL PROTECTED]> > > > high, low = ((num % 2**16) >> 8, num % 2**8) or something thereabouts. > > On Mon, Oct 20, 2008 at 10:47 AM, shawn br

[Tutor] how to see a number as two bytes

2008-10-20 Thread shawn bright
hey there all, i have a script that needs to send a number as two bytes. how would i be able to see a number expressed as a hi byte and a lo byte? thanks shawn ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] send and receive HTTP POST

2008-05-01 Thread shawn bright
Thanks, sorry i was late getting back to you, but gmail thought this was spam. Go figure. Anyway, SOAPpy is doing great. Thanks shawn On Wed, Apr 30, 2008 at 2:05 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > > POST /soap/SMS.asmx HTTP/1.1 > > Host: api.upsidewireless.com > > Content-Type: t

[Tutor] send and receive HTTP POST

2008-04-30 Thread shawn bright
Hey there all, I have been spending some time trying to get my head around how to send info by POST and read the result. These are examples of what i need to read and write . I think i can pull off the writing part, but how do i call it? POST /soap/SMS.asmx HTTP/1.1 Host: api.upsidewireless.com

Re: [Tutor] how to get response from os.system()

2008-03-16 Thread shawn bright
thanks all, appreciate it much. shawn On Sun, Mar 16, 2008 at 6:10 PM, Nathan McBride <[EMAIL PROTECTED]> wrote: > Yup I use the pexpect module for a lot however couldn't get 'pexpect.run' to > work with mysqldump piping to gzip > > > -Original Message- > From: Jeff Younker <[EMAIL PROT

[Tutor] how to get response from os.system()

2008-03-16 Thread shawn bright
Lo there all, I am needing to get a response back from a system command. i can do this: os.system('mailq | wc -l") if i do this in the terminal mailq | wc -l , it will spit out a number. How do i get that number as a python variable ? OK, thanks. shawn

Re: [Tutor] question about a number and bytes.

2008-01-29 Thread shawn bright
gt; The format string will depend whether you need little or big endian. > >--Michael > > > > On Jan 29, 2008 4:13 PM, shawn bright <[EMAIL PROTECTED]> wrote: > > Thanks for your reply. > > i need to do this in python because python is what scripting language

Re: [Tutor] question about a number and bytes.

2008-01-29 Thread shawn bright
Thanks for your reply. i need to do this in python because python is what scripting language our data I/O system is written in. i am writing a command out over a serial port that tells an RTU to change part of it's program. I am not sure what you mean by using it in any other python context, this i

[Tutor] question about a number and bytes.

2008-01-29 Thread shawn bright
Hello there all. I have a need to make a hi byte and lo byte out of a number. so, lets say i have a number 300, and need this number to be represented in two bytes, how do i go about that? thanks for any tips, sk ___ Tutor maillist - Tutor@python.or

Re: [Tutor] need a way to get my own ip address

2008-01-02 Thread shawn bright
nk I found on google > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/439094 > > jay > > > On Jan 2, 2008 9:00 AM, shawn bright <[EMAIL PROTECTED]> wrote: > > > It returns this > > ('hostname', [], [' 127.0.1.1']) > > i am ru

Re: [Tutor] need a way to get my own ip address

2008-01-02 Thread shawn bright
nux/Unix system? What does this > return? > > print socket.gethostname() > print socket.gethostbyaddr(socket.gethostname ()) > > j > > > On Jan 2, 2008 8:45 AM, shawn bright <[EMAIL PROTECTED]> wrote: > > > Thanks, Jay, > > in IDLE, this gave me

Re: [Tutor] need a way to get my own ip address

2008-01-02 Thread shawn bright
name())[2] > > Jay > > On Jan 2, 2008 8:25 AM, shawn bright < [EMAIL PROTECTED]> wrote: > > > Greetings, > > > > i am looking for an easy way to get my own ip address as a string from > > python. > > I am using

[Tutor] need a way to get my own ip address

2008-01-02 Thread shawn bright
Greetings, i am looking for an easy way to get my own ip address as a string from python. I am using Ubuntu Linux if that makes any difference. thanks ! shawn ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] internet access

2007-10-11 Thread shawn bright
i did something very similar to this. My daughter would stay on her instant messenger (gaim) all night if i didn't. i have a cron script that checks the hour of day, if later than x pm. does os.system("/etc/init.d/network stop") os.system("chmod a-x /etc/init.d/network") ( so that a reboot doesn't

Re: [Tutor] do i have to import modules at the start of a file?

2007-09-27 Thread shawn bright
n the admin part of the program. But the main computer at work that takes data in will need the modules to run the threads. thanks for your help on this shawn On 9/26/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > > shawn bright wrote: > > lo there all, > > > > i ha

[Tutor] do i have to import modules at the start of a file?

2007-09-26 Thread shawn bright
lo there all, i have a gui program that imports a few modules that i don't need if i am using the program remotely. The program has an admin interface and thread interface, only the admin interface is needed when i am using the program from a remote computer. all of my modules are imported at the

Re: [Tutor] how to add arguments to a command line program

2007-09-14 Thread shawn bright
Just what i was looking for, thanks shawn On 9/14/07, Alan Gauld <[EMAIL PROTECTED]> wrote: > > > "shawn bright" <[EMAIL PROTECTED]> wrote > > > i am sure i do it with sys args, but don't know how. > > > > like > > > > python

[Tutor] how to add arguments to a command line program

2007-09-14 Thread shawn bright
lo there all, i want to write a program that will be called from another program. I need to pass it one variable. i suppose i could also do this with a module, and create a new instance of whatever i want to pass it to, but all the same, how would i go about this. like if i had a program that i wa

Re: [Tutor] how to sort a dictionary by values

2007-08-08 Thread shawn bright
sorry all, i did mean greatest to least, thanks for all the help here shawn On 8/8/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > > Tiger12506 wrote: > >> Just curious: Is there a reason to use __getitem__() over itemgetter > (used > >> in the example in my reply)? > > > > __getitem__ is a method b

[Tutor] how to sort a dictionary by values

2007-08-07 Thread shawn bright
hello there all, i am wondering how to sort a dictionary that i have by values. And i also need to sort them from greatest to least like if i have a dictionary d = {'a':21.3, 'b':32.8, 'c': 12.92} how could i sort these from least to greatest so that the order would turn out b,a,c thanks shawn _

[Tutor] another question ( unrelated )

2007-07-20 Thread shawn bright
If i have a thread, of type threading.Thread that i initiate with an __init__ in the def run(self): while 1: do some stuff is there a way i can stop this thread and restart this thread from within itself ? thanks ___ Tutor maillist - Tu

Re: [Tutor] another question ( unrelated )

2007-07-20 Thread shawn bright
something is failing and how soon i could re-connect to the data server. whew ! thanks shawn On 7/20/07, Kent Johnson <[EMAIL PROTECTED]> wrote: shawn bright wrote: > If i have a thread, of type threading.Thread > that i initiate with an __init__ > in the > def run(sel

[Tutor] question about datetime object

2007-07-20 Thread shawn bright
Hello there, if i have a python datetime object, what is the easiest way to make it into epoch seconds ? thanks ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] about importing a module

2007-07-19 Thread shawn bright
change the name of the module, simple. thanks shawn On 7/19/07, Tiger12506 <[EMAIL PROTECTED]> wrote: If the module has been imported before your code is run, it will be the library module (very important if working in IDLE which importants many modules, for example). But if it has not been imp

[Tutor] about importing a module

2007-07-19 Thread shawn bright
hello there, if i have a module that is in the same directory as the file that imports it, but that module has the same name as a module in my python path, which one gets imported ? i ask because i want to do some work on the module, but dont want to mess with my stable one in site-packages. so

Re: [Tutor] How do you install EGG files

2007-07-18 Thread shawn bright
Hey thanks for this, yes, i used the easy_install method and it did work on the python 2.4, the python 2.5 failed. shawn On 7/18/07, Kent Johnson <[EMAIL PROTECTED]> wrote: Terry Carroll wrote: > On Wed, 11 Jul 2007, shawn bright wrote: > >> Hey there all, >> i got

[Tutor] storm anyone?

2007-07-11 Thread shawn bright
Hey there all, i got the news that storm was released as open source. Storm is a db orm for python. i have a downloaded package and i would like to play with it, but it does not come with any install instructions. i found the package here https://storm.canonical.com/FrontPage there is a makefile i

Re: [Tutor] help with translating a c function to a python function

2007-07-08 Thread shawn bright
Hey thanks, i finally did get a function working. i posted it on www.bitsbam.com i did guess that the puchMsg++ ment that it was iterating through the bytes of an array. And Kent and Alan helped me get through the other parts. I am glad for all this help, because this is an issue that comes up i

Re: [Tutor] back on bytes

2007-07-07 Thread shawn bright
Well, I contacted the programmer of these controls and the reason they mask the MSB on these reports is to designate what type of sensor it is. If the MSB is set, the sensor is one type, if not, another. So, knowing that i could put these together ok. To me, the speed is of no consequence like it w

[Tutor] back on bytes

2007-07-06 Thread shawn bright
hello all, i have a number 12480 i have a low byte of 192 and a high byte of 176 so i can do this IDLE 1.2.1 No Subprocess >>> (176 & 127) * 256 + 192 12480 but if i start with the 12480, how do i get the two bytes (lo and hi) that make it up? i kinda know what i am doing here,

Re: [Tutor] help with translating a c function to a python function

2007-07-05 Thread shawn bright
Thanks Alan, so do you think my translation is close? i do not know a lick of c. Nope, not one line. thanks shawn On 7/5/07, Alan Gauld <[EMAIL PROTECTED]> wrote: > > "shawn bright" <[EMAIL PROTECTED]> wrote > while (usDataLen––) > { >

Re: [Tutor] help with translating a c function to a python function

2007-07-05 Thread shawn bright
< 8 | crc_lo) whaddya think? On 7/5/07, shawn bright <[EMAIL PROTECTED]> wrote: > 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) >

[Tutor] help with translating a c function to a python function

2007-07-05 Thread shawn bright
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 ; unsi

Re: [Tutor] cyclical redundancy check

2007-07-04 Thread shawn bright
wait, sorry, thats 16 bits total, a low byte and a high byte. If that makes more sense thanks On 7/4/07, shawn bright <[EMAIL PROTECTED]> wrote: Hello there all, Does anyone know where i can find a function that does an 8 bit Cyclical Redundancy Check. I need it to verify data, and i n

[Tutor] cyclical redundancy check

2007-07-04 Thread shawn bright
Hello there all, Does anyone know where i can find a function that does an 8 bit Cyclical Redundancy Check. I need it to verify data, and i need to be able to create one given an 12 byte message. Does anyone know much about doing this in python ? thanks __

Re: [Tutor] Python IDE

2007-06-11 Thread shawn bright
you can use gedit with some plugins that make it pretty much like an ide, and its really fast. another really cool one is JEdit. That is what i used before i switched to vim to do everything. runs on everything, has what you are looking for. Eclipse with PyDev is cool, too. But a little heavy for

[Tutor] easiest way to get true/false of odd/even number

2007-05-14 Thread shawn bright
Hey there all, i know this sounds kinda easy, but i was wanting the least verbose way to get a True / False of a number being odd (not even) thanks shawn ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] easiest way to get true/false of odd/even number

2007-05-14 Thread shawn bright
nevermind, i found it. 4 %2 = 0 (even) 5 %2 = 1 (odd) pretty simple shawn On 5/14/07, shawn bright <[EMAIL PROTECTED]> wrote: Hey there all, i know this sounds kinda easy, but i was wanting the least verbose way to get a True / False of a number being odd (not even) thanks

Re: [Tutor] how to stop output to terminal

2007-05-11 Thread shawn bright
cool, thanks sk On 5/11/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote: shawn bright wrote: > lo there all, > > i have a simple thread that i want to run without piping any output to > the terminal. > like if i do an > > x = os.system("ping -c 1 www.google.com

[Tutor] how to stop output to terminal

2007-05-10 Thread shawn bright
lo there all, i have a simple thread that i want to run without piping any output to the terminal. like if i do an x = os.system("ping -c 1 www.google.com") i don't want it to show all the stuff in the terminal. can i disable that ? can i disable it for only certain lines? thanks ___

Re: [Tutor] best way to tell if i am connected to the internet

2007-05-01 Thread shawn bright
good enough, i suppose i can use a try, except to test if i am online and from that have a true / false. That is what i was looking for. I just didn't think it necessary to pull a webpage every 20 minutes. thanks shawn k On 5/1/07, Alan Gauld <[EMAIL PROTECTED]> wrote: "shawn

Re: [Tutor] best way to tell if i am connected to the internet

2007-04-30 Thread shawn bright
ok, cool. thanks sk On 4/30/07, Jalil <[EMAIL PROTECTED]> wrote: ping a host on the net if you get an echo response back you are good. better yet ping the host page you are scraping. On 4/30/07, shawn bright < [EMAIL PROTECTED]> wrote: > > hello there all, > > i am

[Tutor] best way to tell if i am connected to the internet

2007-04-30 Thread shawn bright
hello there all, i am wondering, what would be the simplest way to get a true/false am i connected to the internet ? right now i am using httplib to fetch a webpage every 20 minutes to see, but i am thinking that there is a better way, any suggestions would be encouraging thanks shawn

Re: [Tutor] how to stop a function

2007-04-24 Thread shawn bright
jeeze, thanks, sorry, stupid question. On 4/24/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > shawn bright wrote: > > now there is one function that i have a kinda nested if else > > conditions that i need to stop if necessary > > > > if value == 1: > >

[Tutor] how to stop a function

2007-04-24 Thread shawn bright
hello all, i have a gui app that uses functions to respond to gui events. like def on_start_button_clicked(self, stuff): do this or that. now there is one function that i have a kinda nested if else conditions that i need to stop if necessary if value == 1: if next_val == 4: do t

[Tutor] question about gui tool-kits

2007-04-05 Thread shawn bright
lo there all, i have been working with pygtk2 for a while now, and, though i do like the look and feel of a GTK2 app, i would like to do some stuff with wx. I know, it doesn't look as cool, but , i may have need to work on something that i can port to a windows box, and i think that wx would be a

Re: [Tutor] how to send command line args to py script

2007-03-11 Thread shawn bright
OK, will do. Looks like my future will involve more of this kind of thing. thanks shawn On 3/11/07, Dave Kuhlman <[EMAIL PROTECTED]> wrote: > On Sun, Mar 11, 2007 at 09:07:41PM -0500, shawn bright wrote: > > Well, for your first response, its great, > > thanks a lot. > &

Re: [Tutor] how to send command line args to py script

2007-03-11 Thread shawn bright
ript with the formatting "python (filename).py 1 1", not > "python (filename).py -1 -1", that'll get you negative numbers. > > shawn bright wrote: > > lo there all, > > > > i was wondering how to make a python script accept command line arguments. >

[Tutor] how to send command line args to py script

2007-03-11 Thread shawn bright
lo there all, i was wondering how to make a python script accept command line arguments. i mean, i have used python scripts from the command line in linux and passed something to it and it knows what to do. like in a function, if i want to do something like this def add_two_numbers(a, b): x

[Tutor] question about forwarding mail with poplib

2007-02-28 Thread shawn bright
Hello there all, i am poplib to retrieve mail from a pop server here on my local machine. i need to be able to forward every message i get to another email address. i looked through the poplib page on the reference online but i can't find anything there to help me out with this. Also, the message

Re: [Tutor] stumped again adding bytes

2007-02-24 Thread shawn bright
TED]> wrote: > > "shawn bright" <[EMAIL PROTECTED]> wrote > > > if i use i bitmask of 240 it will mask the most significant 4 bits > > When using bitmasks its much easier to think in hex (or octal). > there are exactly 2 hex digits per byte so you only need to

Re: [Tutor] stumped again adding bytes

2007-02-23 Thread shawn bright
whoops, meant this to the list, sorry Luke. On 2/23/07, shawn bright <[EMAIL PROTECTED]> wrote: > Thanks for your help, Luke. > i am trying to get a grasp on how all this works, which is the msb, lsb, etc.. > > if i use i bitmask of 240 it will mask the most significant 4 bits

Re: [Tutor] stumped again adding bytes

2007-02-23 Thread shawn bright
ist of the 2nd half of the 2nd byte as the most significant , i would take the second byte with my bitmask then shift it right by 4 then add the third byte to that am i getting this right like x = ((byte2 & 240) << 4) + byte 3 i think ? shawn On 2/23/07, Luke Paireepinart <[EMAIL

Re: [Tutor] stumped again adding bytes

2007-02-23 Thread shawn bright
the struct module, but can't figgure out how to do this type of thing with it. thanks shawn On 2/21/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > shawn bright wrote: > > oh, sorry, i meant how to get the 0x0A27 out of two bytes > > a = 0x27 and b = 0x8A > I don

Re: [Tutor] how to read one bit of a byte

2007-02-21 Thread shawn bright
Hey thanks for all the help guys, i am at least pulling some values that make sense. i feel more like i am on my way. thanks again shawn On 2/21/07, Alan Gauld <[EMAIL PROTECTED]> wrote: > > "Kent Johnson" <[EMAIL PROTECTED]> wrote > > This is also a good application of bitwise operations. > > >

Re: [Tutor] stumped again adding bytes

2007-02-21 Thread shawn bright
the numbers so, i guess a better question is how to get 2599 from the ord(a) and ord(b), how do i put the two bytes together to make one number? thanks for your help On 2/21/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > shawn bright wrote: > > Hey all, thanks for the help yeste

[Tutor] stumped again adding bytes

2007-02-21 Thread shawn bright
Hey all, thanks for the help yesterday on finding out if an msb is set or not. i am now kinda stumped with discovering the value of two bytes together. ok, if i have two bytes that together make a number, how do i find that number? i know that i do not add them. like byte_a = 39 byte_b = 138 to

Re: [Tutor] how to read one bit of a byte

2007-02-21 Thread shawn bright
even better, thanks much for this. shawn On 2/21/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > Luke Paireepinart wrote: > > shawn bright wrote: > >> lo there all, > >> > >> i am reading a binary file with open('myfile', 'rb'

Re: [Tutor] how to read one bit of a byte

2007-02-20 Thread shawn bright
great, thanks for this. appreciate it a lot. sk On 2/20/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote: shawn bright wrote: > lo there all, > > i am reading a binary file with open('myfile', 'rb') > > then i do a read(1) to read one byte. cool so

[Tutor] how to read one bit of a byte

2007-02-20 Thread shawn bright
lo there all, i am reading a binary file with open('myfile', 'rb') then i do a read(1) to read one byte. cool so far. but how do i read the individual bits of a byte i mean if i have a = read(1) how do i know what the msb of a is ? i need to know because i have to see if the msb is set and i

Re: [Tutor] question about importing threads

2007-02-11 Thread shawn bright
great, saves me 15 lines. thanks sk On 2/11/07, Kent Johnson <[EMAIL PROTECTED]> wrote: shawn bright wrote: > one last queston. if i have a class that i import as a module, say a > script that emails me when something goes wrong. > so i have a file called my_own_email.py an

Re: [Tutor] question about importing threads

2007-02-11 Thread shawn bright
lan G. On 12/31/06, Alan Gauld <[EMAIL PROTECTED]> wrote: > > "shawn bright" <[EMAIL PROTECTED]> wrote > > > Yes, the thing is getting to be a pain to deal with at this size, i > > am > > in-process of splitting out the classes into their own files.

Re: [Tutor] question about importing threads

2007-02-09 Thread shawn bright
nt modules that would need to use it? Or does this go along with what you wrote a while back about having classes that depend on each other ? One runs as a thread, the other responds to gui input. thanks for any tips. shawn On 12/31/06, Alan Gauld <[EMAIL PROTECTED]> wrote: "shawn brig

Re: [Tutor] question about a list of lists

2007-01-29 Thread shawn bright
Thanks Kent, i am going with option A, the helper set, because i also need to count the occurances and this seems to be the easiest solution. thanks for your help. shawn On 1/28/07, Kent Johnson <[EMAIL PROTECTED]> wrote: shawn bright wrote: > lo there all. > > i have a lis

[Tutor] question about a list of lists

2007-01-28 Thread shawn bright
lo there all. i have a list of lists that i want to build, only if an item is not in the list already. kinda like this new_list = [] for item in lists: # item will look something like [var1, var2, var3] if item[0] in new_list ( only the first element of each list ) like new_list[0][0] basicl

Re: [Tutor] Best IDE for Python

2007-01-27 Thread shawn bright
i think pydev ( an eclipse plugin ) can too. shawn On 1/27/07, Dick Moores <[EMAIL PROTECTED]> wrote: At 07:12 PM 1/24/2007, Shadab Sayani wrote: Hi, I am using vim editor to code my project in python.Is there a good IDE where in I type the name of the class object and then dot then all the a

Re: [Tutor] question about *args and functions

2007-01-26 Thread shawn bright
nction(req_var, req_var2, un_req_var=None): if un_req_var != None: dosomething else: dosomethingelse Wesley Brooks. On 26/01/07, shawn bright <[EMAIL PROTECTED]> wrote: > lo there all, > > if i have a function that sometimes needs a value passed to it and sometimes

[Tutor] question about *args and functions

2007-01-26 Thread shawn bright
lo there all, if i have a function that sometimes needs a value passed to it and sometimes not, is this where i use *args ? like this def some_function(req_var, req_var2, un_req_var): do some stuff return value how would i use this if sometimes i need to process un_req_var and sometimes

[Tutor] question about pydev

2007-01-09 Thread shawn bright
hey there gents, i was wondering if anyone uses pydev ? its a plugin for eclipse. Has lots of cool stuffs, but i don't like the way it does code snippets, when i paste one that is kinda long, it messes up the indentation. anyone know a way around this ? i have posted this question on the pydev sou

Re: [Tutor] need help with sending email

2007-01-05 Thread shawn bright
this is really cool. working too, we have one provider now that it does not work with, but i think its them this time. thanks for your help on this shawn On 1/5/07, Christopher Arndt <[EMAIL PROTECTED]> wrote: shawn bright schrieb: > lo there all. > > i am in a tight spot be

Re: [Tutor] need help with sending email

2007-01-05 Thread shawn bright
l Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of shawn bright > Sent: Friday, January 05, 2007 10:18 AM > To: tutor-python > Subject: [Tutor] need help with sending email > > lo there all. > > i am in a tight spot because i need to send an email tha

[Tutor] need help with sending email

2007-01-05 Thread shawn bright
lo there all. i am in a tight spot because i need to send an email that it mime encoded plain-text ( not html or anything ) no attachements, no images, just text from a string. like message = 'some message' all the tutorials i find out there, and the cookbook recipies are for sending multipart me

Re: [Tutor] how to stop a thread

2007-01-04 Thread shawn bright
i can do that, will use my config file, thanks much and thanks for the link. shawn On 1/4/07, Kent Johnson <[EMAIL PROTECTED]> wrote: shawn bright wrote: > hello there all, > > i have a python reference book that got me started knowing how to use > threads, i can declare o

[Tutor] how to stop a thread

2007-01-04 Thread shawn bright
hello there all, i have a python reference book that got me started knowing how to use threads, i can declare one as a class, and start it like this class SomeThread(threading.Thread): run_process = SomeThread() run_process.start() but how do i kill it ? This part is not in my book. Basically

Re: [Tutor] how to know if a file exists

2007-01-03 Thread shawn bright
thanks, luke, Andre. appreciate it a lot shawn On 1/3/07, Andre Roberge <[EMAIL PROTECTED]> wrote: On 1/4/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > > shawn bright wrote: > > hello there, > > i am writing an app for linux. what command would be ea

[Tutor] how to know if a file exists

2007-01-03 Thread shawn bright
hello there, i am writing an app for linux. what command would be easiest to test and see if a certain file exist ? i was going to do something like this try: file = open('/path/to/file', 'rb') return True except: return False but i thought that there would be an easier way. thanks _

  1   2   >