Re: python backup script

2013-05-07 Thread Enrico 'Henryx' Bianchi
John Gordon wrote: > Looks like you need a comma after 'stdout=filename'. Sigh, yesterday was a terrible day (yes, it lacks a comma)... Anyway, when it is possible, is recommended to use the drivers for communicate with databases, because subprocess (or os.*open*) is more expensive compared to

Re: python backup script

2013-05-06 Thread Peter Otten
Chris Angelico wrote: > It's also worth noting that the ~/ notation is a shell feature. You > may or may not be able to use it in config.read(). The latter. Combined with """ read(self, filenames) method of ConfigParser.ConfigParser instance Read and parse a filename or a list of filenames.

Re: python backup script

2013-05-06 Thread MRAB
On 06/05/2013 23:40, MMZ wrote: On Monday, May 6, 2013 6:12:28 PM UTC-4, Chris Angelico wrote: On Tue, May 7, 2013 at 5:01 AM, MMZ wrote: > username = config.get('client', 'mmz') > password = config.get('client', 'pass1') > hostname = config.get('client', 'localhost') Are 'mmz', 'pass1',

Re: python backup script

2013-05-06 Thread Chris Angelico
On Tue, May 7, 2013 at 8:40 AM, MMZ wrote: > Thanks Chris. you are right. > So I used them directly and removed configParser. The new error is: > > Traceback (most recent call last): > File "./bbk.py", line 11, in ? > for database in os.popen(database_list_command).readlines(): > NameError:

Re: python backup script

2013-05-06 Thread MMZ
On Monday, May 6, 2013 6:12:28 PM UTC-4, Chris Angelico wrote: > On Tue, May 7, 2013 at 5:01 AM, MMZ wrote: > > > username = config.get('client', 'mmz') > > > password = config.get('client', 'pass1') > > > hostname = config.get('client', 'localhost') > > > > Are 'mmz', 'pass1', and 'localhos

Re: python backup script

2013-05-06 Thread MRAB
On 06/05/2013 23:12, m...@socialassets.org wrote: On Monday, May 6, 2013 5:48:44 PM UTC-4, Enrico 'Henryx' Bianchi wrote: Enrico 'Henryx' Bianchi wrote: > cmd2 = subprocess.Popen(['gzip' '-c'], > shell=False, > stdout=filename) Doh, my fault: cmd2 = subprocess.Popen(['gzip' '-c'],

Re: python backup script

2013-05-06 Thread John Gordon
In <36d2b7cf-2537-46a6-b984-9fce7ddd3...@googlegroups.com> m...@socialassets.org writes: > > cmd2 = subprocess.Popen(['gzip' '-c'], > > > > shell=False, > > > > stdout=filename > > > > stdin=cmd1.stdout) > Thank you Enric

Re: python backup script

2013-05-06 Thread MMZ
stdin=cmd1.stdout) ^ SyntaxError: invalid syntax On Monday, May 6, 2013 5:48:44 PM UTC-4, Enrico 'Henryx' Bianchi wrote: > Enrico 'Henryx' Bianchi wrote: > > > > > cmd2 = subprocess.Popen(['gzip' '-c'], > > > shell=False, > > > stdout=filename) > > > > Doh, my fault: > > > >

Re: python backup script

2013-05-06 Thread mina
On Monday, May 6, 2013 5:48:44 PM UTC-4, Enrico 'Henryx' Bianchi wrote: > Enrico 'Henryx' Bianchi wrote: > > > > > cmd2 = subprocess.Popen(['gzip' '-c'], > > > shell=False, > > > stdout=filename) > > > > Doh, my fault: > > > > cmd2 = subprocess.Popen(['gzip' '-c'], > >

Re: python backup script

2013-05-06 Thread Chris Angelico
On Tue, May 7, 2013 at 5:01 AM, MMZ wrote: > username = config.get('client', 'mmz') > password = config.get('client', 'pass1') > hostname = config.get('client', 'localhost') Are 'mmz', 'pass1', and 'localhost' the actual values you want for username, password, and hostname? If so, don't pass them

Re: python backup script

2013-05-06 Thread Enrico 'Henryx' Bianchi
Enrico 'Henryx' Bianchi wrote: > cmd2 = subprocess.Popen(['gzip' '-c'], > shell=False, > stdout=filename) Doh, my fault: cmd2 = subprocess.Popen(['gzip' '-c'], shell=False, stdout=filename stdin=cmd1.stdout) Enrico -- htt

Re: python backup script

2013-05-06 Thread Enrico 'Henryx' Bianchi
MMZ wrote: > config.read("~/my.cnf") > username = config.get('client', 'mmz') > password = config.get('client', 'pass1') > hostname = config.get('client', 'localhost') ### A simple config file ### [client] user = mmz password = pass1 host = localhost ### EOF ### #!/usr/bin/env python import Conf

Re: python backup script

2013-05-06 Thread Matt Jones
Why do you have to use that file? Why can't you copy its contents into a new file in your working directory and make whatever changes necessary? Example of the changes your code makes me think you want: # The following options will be passed to all MySQL clients [client

Re: python backup script

2013-05-06 Thread MMZ
Thanks Matt. my.cnf is a readonly file and cannot be changed or modified but do you know of a file that stores similar information on CentOS?I think I'm not reading from a right file maybe. On Monday, May 6, 2013 3:46:04 PM UTC-4, Matt Jones wrote: > I've never used ConfigParser either, but sho

Re: python backup script

2013-05-06 Thread Matt Jones
I've never used ConfigParser either, but shouldn't the "[client]" section have the options "mmz", "pass1", or "localhost" somewhere? Do you need to add them to that file? *Matt Jones* On Mon, May 6, 2013 at 2:20 PM, MMZ wrote: > On Monday, May 6, 2013 3:11:33 PM UTC-4, Jerry Hill wrote: > > O

Re: python backup script

2013-05-06 Thread MMZ
On Monday, May 6, 2013 3:11:33 PM UTC-4, Jerry Hill wrote: > On Mon, May 6, 2013 at 3:01 PM, MMZ wrote: > > > > I am trying to backup database on CentOS linux server,I'm getting error when > running the following script. anyone can help? > > > > > Traceback (most recent call last): > >  

Re: python backup script

2013-05-06 Thread Jerry Hill
On Mon, May 6, 2013 at 3:01 PM, MMZ wrote: > I am trying to backup database on CentOS linux server,I'm getting error > when running the following script. anyone can help? > > Traceback (most recent call last): > File "./backup.py", line 8, in ? > username = config.get('client', 'mmz') > F