# HG changeset patch # User souliane # Date 1454582683 -3600 # Node ID cdecf553e051e0684e18492f7eb2eb9dd62adbc6 # Parent b3b25dbac58537b4d6a5046b6b6e9a054cdf8124 frontends (jp/blog), plugin blog_import: fixes: - argparse argument with nargs > 1 and default == {} crashes when reading the user input - separate blog import options with a new line - convert DBus strings received by the backend to unicode diff -r b3b25dbac585 -r cdecf553e051 frontends/src/jp/cmd_blog.py --- a/frontends/src/jp/cmd_blog.py Thu Jan 28 16:44:47 2016 +0100 +++ b/frontends/src/jp/cmd_blog.py Thu Feb 04 11:44:43 2016 +0100 @@ -37,7 +37,7 @@ self.parser.add_argument('--no-images-upload', action='store_true', help=_(u"do *NOT* upload images (default: do upload images)")) self.parser.add_argument('--upload-ignore-host', help=_(u"do not upload images from this host (default: upload all images)")) self.parser.add_argument("--ignore-tls-errors", action="store_true", help=_("ignore invalide TLS certificate for uploads")) - self.parser.add_argument('-o', '--option', action='append', nargs=2, default={}, metavar=(u'NAME', u'VALUE'), + self.parser.add_argument('-o', '--option', action='append', nargs=2, default=[], metavar=(u'NAME', u'VALUE'), help=_(u"importer specific options (see importer description)")) self.parser.add_argument('--service', type=base.unicode_decoder, default=u'', metavar=u'PUBSUB_SERVICE', help=_(u"PubSub service where the items must be uploaded (default: server)")) @@ -77,7 +77,7 @@ if getattr(self.args, name): self.parser.error(_(u"{name} argument can't be used without location argument").format(name=name)) if self.args.importer is None: - print u''.join([u'{}: {}'.format(name, desc) for name, desc in self.host.bridge.blogImportList()]) + print u'\n'.join([u'{}: {}'.format(name, desc) for name, desc in self.host.bridge.blogImportList()]) else: try: short_desc, long_desc = self.host.bridge.blogImportDesc(self.args.importer) @@ -90,7 +90,7 @@ self.host.quit() else: # we have a location, an import is requested - options = dict(self.args.option) + options = {key: value for key, value in self.args.option} if self.args.host: options['host'] = self.args.host if self.args.ignore_tls_errors: diff -r b3b25dbac585 -r cdecf553e051 src/plugins/plugin_blog_import.py --- a/src/plugins/plugin_blog_import.py Thu Jan 28 16:44:47 2016 +0100 +++ b/src/plugins/plugin_blog_import.py Thu Feb 04 11:44:43 2016 +0100 @@ -94,12 +94,13 @@ def _blogImport(self, name, location, options, pubsub_service='', profile=C.PROF_KEY_DEFAULT): client = self.host.getClient(profile) + options = {key: unicode(value) for key, value in options.iteritems()} for option in BOOL_OPTIONS: try: options[option] = C.bool(options[option]) except KeyError: pass - return self.blogImport(client, name, location, options) + return self.blogImport(client, unicode(name), unicode(location), options) @defer.inlineCallbacks def blogImport(self, client, name, location, options=None, pubsub_service=None):