[Tutor] Tutor Digest, Vol 51, Issue 23

root jatinder.singh2 at wipro.com
Sun May 11 13:24:32 CEST 2008


Hi ,
	I AM TRYING FOR A PYTHON PROGRAM THAT WILL CHECK WHETHER {- PHP AND
MYSQL -} ARE INSTALLED ON lINUX OR NOT AND IF THEY ARE NOT INSTALLED
THEN THE SCRIPT WILL TO INSTALL IT.

for this I am doing

import sys
import os
import commands
import sys


	commands_hash = {}
	commands_hash['php'] = {}
	commands_hash['php']['title'] = "***********PHP**************"
	commands_hash['php']['value'] = "rpm -qa *php*"
	commands_hash['mysql'] = {}
	commands_hash['mysql']['title'] = "***********MYSQL**************"
	commands_hash['mysql']['value'] = "rpm -qa *mysql*"


this is checking whether PHP and MYSQL are installed but PLEASE TELL ME
HOW TO ENHANCE IT SO AS THE INSTALL IT IF NOT INSTALLED ALREADY.

Thanks

Jatinder Singh


On Sun, 2008-05-11 at 12:00 +0200, tutor-request at python.org wrote:
> Send Tutor mailing list submissions to
> 	tutor at python.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://mail.python.org/mailman/listinfo/tutor
> or, via email, send a message with subject or body 'help' to
> 	tutor-request at python.org
> 
> You can reach the person managing the list at
> 	tutor-owner at python.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."
> 
> 
> Today's Topics:
> 
>    1. Logging module (Dick Moores)
>    2. Re: Logging module (Martin Walsh)
>    3. Re: Logging module (Dick Moores)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Sat, 10 May 2008 06:36:53 -0700
> From: Dick Moores <rdm at rcblue.com>
> Subject: [Tutor] Logging module
> To: Python Tutor List <tutor at python.org>
> Message-ID: <20080510133759.CAFC51E4011 at bag.python.org>
> Content-Type: text/plain; charset="us-ascii"; format=flowed
> 
> I don't understand how to use this. I've read 
> <http://docs.python.org/lib/module-logging.html> and 
> <http://blog.doughellmann.com/2007/05/pymotw-logging.html>.
> 
> I thought I'd try with a script that screws up:
> 
> a = "qwerty"
> b = a*b
> 
> But how to use the logging module to log the report of the screw up? 
> Right now I don't care about the various levels. I just want to get 
> something into a log file.
> 
> Hellmann suggest this:
> 
> import logging
> LOG_FILENAME = '/tmp/logging_example.out'
> logging.basicConfig(filename=LOG_FILENAME,     level=logging.DEBUG,)
> logging.debug('This message should go to the log file')
> 
> But where to put it? In my above script?
> 
> Thanks,
> 
> Dick Moores
> 
> 
> 
> 
> ------------------------------
> 
> Message: 2
> Date: Sat, 10 May 2008 16:03:20 -0500
> From: Martin Walsh <mwalsh at groktech.org>
> Subject: Re: [Tutor] Logging module
> To: "tutor at python.org" <tutor at python.org>
> Message-ID: <48260D98.70101 at groktech.org>
> Content-Type: text/plain; charset=ISO-8859-1
> 
> Dick Moores wrote:
> > But how to use the logging module to log the report of the screw up?
> > Right now I don't care about the various levels. I just want to get
> > something into a log file.
> > 
> > Hellmann suggest this:
> > 
> > import logging
> > LOG_FILENAME = '/tmp/logging_example.out'
> > logging.basicConfig(filename=LOG_FILENAME,     level=logging.DEBUG,)
> > logging.debug('This message should go to the log file')
> > 
> > But where to put it? In my above script?
> 
> I usually wrap up code in a try except and use the logging.exception
> method, which is shorthand for logging.error(msg, exc_info=1), to
> include the traceback. Something like this:
> 
> import logging
> LOG_FILENAME = '/tmp/logging_example.out'
> logging.basicConfig(filename=LOG_FILENAME, level=logging.DEBUG)
> 
> def main():
>     a = "qwerty"
>     b = a * b
> 
> try:
>     main()
> except:
>     logging.exception('unknown')
>     raise
> 
> HTH,
> Marty
> 
> 
> 
> ------------------------------
> 
> Message: 3
> Date: Sat, 10 May 2008 17:08:18 -0700
> From: Dick Moores <rdm at rcblue.com>
> Subject: Re: [Tutor] Logging module
> To: "tutor at python.org" <tutor at python.org>
> Message-ID: <20080511000830.A08D91E4013 at bag.python.org>
> Content-Type: text/plain; charset="us-ascii"; format=flowed
> 
> At 02:03 PM 5/10/2008, Martin Walsh wrote:
> >Dick Moores wrote:
> > > But how to use the logging module to log the report of the screw up?
> > > Right now I don't care about the various levels. I just want to get
> > > something into a log file.
> > >
> > > Hellmann suggest this:
> > >
> > > import logging
> > > LOG_FILENAME = '/tmp/logging_example.out'
> > > logging.basicConfig(filename=LOG_FILENAME,     level=logging.DEBUG,)
> > > logging.debug('This message should go to the log file')
> > >
> > > But where to put it? In my above script?
> >
> >I usually wrap up code in a try except and use the logging.exception
> >method, which is shorthand for logging.error(msg, exc_info=1), to
> >include the traceback. Something like this:
> >
> >import logging
> >LOG_FILENAME = '/tmp/logging_example.out'
> >logging.basicConfig(filename=LOG_FILENAME, level=logging.DEBUG)
> >
> >def main():
> >     a = "qwerty"
> >     b = a * b
> >
> >try:
> >     main()
> >except:
> >     logging.exception('unknown')
> >     raise
> 
> Thank you! That gives me a good start.
> 
> Dick
> 
> 
> 
> ------------------------------
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 
> End of Tutor Digest, Vol 51, Issue 23
> *************************************


Please do not print this email unless it is absolutely necessary. 

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. 

www.wipro.com


More information about the Tutor mailing list