printing table on the command line

2010-04-29 Thread Daniel Dalton
Hello, I'm using the MySQLdb library in python to interface with a mysql database I've created. I have written a command line app which runs from the command line. I have 10 fields and hence, have found that each record spreads over one line. What is the best way to print a table of a database

Re: working with laptop battery

2010-02-18 Thread Daniel Dalton
On Sat, Feb 13, 2010 at 09:19:59PM -0500, Chris Colbert wrote: You'll need acpi installed: In [6]: import subprocess Thanks for that code, I'll try putting something together this weekend. Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: working with laptop battery

2010-02-18 Thread Daniel Dalton
I'm not sure I have those files, but I'll look a little harder this weekend when I put together the script. Thanks for your help, Dan On Sat, Feb 13, 2010 at 08:23:28PM -0600, Tim Chase wrote: Daniel Dalton wrote: On Sat, Feb 13, 2010 at 05:26:02PM -0800, Chris Rebert wrote: It's probably

Re: working with laptop battery

2010-02-18 Thread Daniel Dalton
On Sun, Feb 14, 2010 at 03:22:11AM +0100, Daniel Fetchinson wrote: /proc/acpi/battery/BAT0/info /proc/acpi/battery/BAT0/state Had a quick look, but that path doesn't seem to exist, I'll look harder on the weekend when I put the script together, because it has to be somewhere. Thanks, Dan --

working with laptop battery

2010-02-13 Thread Daniel Dalton
Hi, I'm constantly working in the command line and need to write a program to give me alerts on my battery. Can someone please tell me what module I should use to access battery information? Looking for something that perhaps makes use of acpi so I can get estimated time left as well as a

Re: working with laptop battery

2010-02-13 Thread Daniel Dalton
On Sat, Feb 13, 2010 at 05:26:02PM -0800, Chris Rebert wrote: It's probably gonna depend on which OS you're running. Which would be...? Sorry, forgot to mention this. I'm running debian linux. Thanks, Dan -- http://mail.python.org/mailman/listinfo/python-list

Best way to conduct a google search

2009-12-12 Thread Daniel Dalton
Hi, I need to do the following in my program: 1. Conduct a google search, supplying the variable text to the search. Is there a google api or something similar I should use? 2. I then need to be able to get the url, of the page, or the html content, so I can dump it to text. Thanks, Dan

Re: python and vc numbers

2009-12-02 Thread Daniel Dalton
Can you make do with the tempfile module? Or you'd need to identify from an external process which console is locked? Perhaps, I wrote a small hack: - Manually set environment variable TTYNUMBER in .bash_profile - Then use this in the script, to establish what tty I'm working with. Thanks --

Re: python and vc numbers

2009-11-30 Thread Daniel Dalton
On Mon, Nov 30, 2009 at 02:21:54PM +1300, Gregory Ewing wrote: I use to figure out what tty my program was invoked from? Here's one way: % python Python 2.5 (r25:51908, Apr 8 2007, 22:22:18) [GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin Type help, copyright, credits or

Re: python and vc numbers

2009-11-30 Thread Daniel Dalton
On Mon, Nov 30, 2009 at 07:20:59PM +1100, Daniel Dalton wrote: That did the trick, thanks, after I append [-2] Further testing under screen says otherwise -- it seems to give me the tty number, not the virtual console number. Is there any way to figure out what virtual console I'm am in so

Re: python and vc numbers

2009-11-30 Thread Daniel Dalton
On Mon, Nov 30, 2009 at 02:26:14AM -0800, Chris Rebert wrote: Also, in my quickie newbie experimentation with `screen`, each screen window seems to get a unique tty#. Admittedly I am running OS X Correct (Which creates the problem) Perhaps if you could explain your problem in greater detail?

python and vc numbers

2009-11-28 Thread Daniel Dalton
Hi, I have a very simple problem, but I can't work out the answer. How do I return the current tty number in python? eg. what function/module should I use to figure out what tty my program was invoked from? Thanks -- Cheers, Dan http://members.iinet.net.au/~ddalton/ signature.asc

Re: python and web pages

2009-11-20 Thread Daniel Dalton
On Thu, Nov 19, 2009 at 09:43:50AM +0100, Diez B. Roggisch wrote: elinks, links, links2 and do the following. 1. Open a certain web page and find the first text box on the page, and put this text into the form. 2. Press the submit button, and wait for the result page to load. 3. Click on the

python and web pages

2009-11-18 Thread Daniel Dalton
Hi, Here is my situation: I'm using the command line, as in, I'm not starting gnome or kde (I'm on linux.) I have a string of text attached to a variable,. So I need to use one of the browsers on linux, that run under the command line, eg. lynx, elinks, links, links2 and do the following. 1. Open

Re: storing variable value

2009-04-13 Thread Daniel Dalton
Yes. I used a file, thanks. On Sat, Apr 11, 2009 at 09:30:40AM -0400, Dave Angel wrote: Daniel Dalton wrote: Hi! I'm writing a program to provide me with battery warnings when my battery hits certain levels. It just checks the current level and does something. I plan to call it from

storing variable value

2009-04-11 Thread Daniel Dalton
Hi! I'm writing a program to provide me with battery warnings when my battery hits certain levels. It just checks the current level and does something. I plan to call it from a a cron job. But If the cron runs every minute, warnings every minute would be rather annoying. so is there a way to make

Re: What's the difference between generating a value and returning a value?

2009-03-24 Thread Daniel Dalton
On Mon, Mar 23, 2009 at 03:12:19PM -0700, grocery_stocker wrote: So what's the difference between generating a value and returning a value? Well when you return, you would use the return keyword, I would imagine... I guess generating could mean many things, you can generate a value by operating

searching strings

2009-03-09 Thread Daniel Dalton
Hi, I'm writing a program where I search a variable (path), and see if it contains the whole string of variable name so: if name in path: else: One question about this, how can I make it do exactly what it's doing now, except ignore case? eg. if I do this: i=A j=ab i in j should

Re: searching strings

2009-03-09 Thread Daniel Dalton
On Mon, Mar 09, 2009 at 06:24:24PM -0700, Chris Rebert wrote: Normalize the case of the strings: i.lower() in j.lower() Too easy, thanks very much! Cheers, Daniel. -- http://mail.python.org/mailman/listinfo/python-list

help with printing to stdout...

2009-03-08 Thread Daniel Dalton
Hi, I've got a program here that prints out a percentage of it's completion. Currently with my implimentation it prints like this: 0% 1% 2% 3% 4% etc taking up lots and lots of lines of output... So, how can I make it write the percentage on the same line eg. while working: print percent

Re: help with printing to stdout...

2009-03-08 Thread Daniel Dalton
or like this: print '\r'+str(percent), Then make sure it gets sent out, like this: sys.stdout.flush() Hey! Thanks very much, that did the trick! Thanks to everyone that replied, I discovered converting to str was crutial to actually print anything. :) Cheers, Daniel. --

Re: NEWB: dividing numbers

2009-03-08 Thread Daniel Dalton
Hi, On Mon, Mar 09, 2009 at 12:08:16AM +0100, Lo wrote: I just tried python first time. 2/3 the result is zero That's because your dividing an int by an int to an int. The definition of an int is a whole number. So just use floating point I think it's called, this should work, and does