[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Duplicity-talk] Duplicity 0.6.19: help to pipe problem
From: |
edgar . soldin |
Subject: |
Re: [Duplicity-talk] Duplicity 0.6.19: help to pipe problem |
Date: |
Mon, 10 Sep 2012 19:59:04 +0200 |
User-agent: |
Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20120824 Thunderbird/15.0 |
On 09.09.2012 18:26, Дмитрий Черняк wrote:
> Hi, All!
>
> When duplicity invoked as
>
>> duplicity --help >somefile
>>
> or, in my actual case:
>
>> duplicity --help|grep -q -- --name
>>
> The error will be generated:
>
>> address@hidden:~/test$ duplicity --help >a
>> Traceback (most recent call last):
>> File "/usr/bin/duplicity", line 1391, in <module>
>> with_tempdir(main)
>> File "/usr/bin/duplicity", line 1384, in with_tempdir
>> fn()
>> File "/usr/bin/duplicity", line 1235, in main
>> action = commandline.ProcessCommandLine(sys.argv[1:])
>> File "/usr/lib/python2.6/dist-packages/duplicity/commandline.py", line
>> 970, in ProcessCommandLine
>> args = parse_cmdline_options(cmdline_list)
>> File "/usr/lib/python2.6/dist-packages/duplicity/commandline.py", line
>> 534, in parse_cmdline_options
>> (options, args) = parser.parse_args()
>> File "/usr/lib/python2.6/optparse.py", line 1394, in parse_args
>> stop = self._process_args(largs, rargs, values)
>> File "/usr/lib/python2.6/optparse.py", line 1434, in _process_args
>> self._process_long_opt(rargs, values)
>> File "/usr/lib/python2.6/optparse.py", line 1509, in _process_long_opt
>> option.process(opt, value, values, self)
>> File "/usr/lib/python2.6/optparse.py", line 788, in process
>> self.action, self.dest, opt, value, values, parser)
>> File "/usr/lib/python2.6/dist-packages/duplicity/commandline.py", line
>> 170, in take_action
>> self, action, dest, opt, value, values, parser)
>> File "/usr/lib/python2.6/optparse.py", line 810, in take_action
>> parser.print_help()
>> File "/usr/lib/python2.6/dist-packages/duplicity/commandline.py", line
>> 197, in print_help
>> file.write(self.format_help().decode('utf-8').encode(encoding,
>> "replace"))
>> TypeError: encode() argument 1 must be string, not None
>>
> The problem is in commandline.py line 187:
>
>> encoding = getattr(file, "encoding", "UTF-8")
>> return encoding
>>
> Actually there should be:
>
>> if encoding: return encoding
>> return "UTF-8"
>>
> It is because the third argument of getattr will be substituted only when
> requested attribute not exists at all.
>
> But, i suspect, there actually is the file.encoding attribute with the value
> of None.
>
> Here is the patch:
>
> =============================================
>
> --- commandline.py 2012-09-09 20:15:10.230192530 +0400
> +++ commandline.py.new 2012-09-09 20:16:25.029191293 +0400
> @@ -185,7 +185,8 @@
> which is default encoding in python3 and most recent unixes
> """
> encoding = getattr(file, "encoding", "UTF-8")
> - return encoding
> + if encoding: return encoding
> + return "UTF-8"
>
> def print_help(self, file=None):
> """
> ==============================================
>
>
proposed as
https://code.launchpad.net/~ed.so/duplicity/duplicity.helpfix
with some minor changes .. ede/duply.net