python backup script

MRAB python at mrabarnett.plus.com
Mon May 6 18:52:53 EDT 2013


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 <programmer.toronto at gmail.com> 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 through
>>
>> config.get() at all - just use them directly. In fact, I'd be inclined
>>
>> to just stuff them straight into the Database_list_command literal;
>>
>> that way, it's clear how they're used, and the fact that you aren't
>>
>> escaping them in any way isn't going to be a problem (tip: an
>>
>> apostrophe in your password would currently break your script).
>>
>>
>>
>> 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().
>>
>>
>>
>> ChrisA
>
> 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: name 'database_list_command' is not defined
>
> any idea?
>
Check the spelling (remember that the name is case-sensitive).



More information about the Python-list mailing list