comparison frontends/src/jp/cmd_blog.py @ 1864:96ba685162f6

jp: all commands now use the new start method and set need_loop in __init__ when needed
author Goffi <goffi@goffi.org>
date Mon, 29 Feb 2016 16:52:51 +0100
parents 9eabf7fadfdd
children 397ef87958b9
comparison
equal deleted inserted replaced
1863:b2ddd7f5dcdf 1864:96ba685162f6
28 28
29 29
30 class Import(base.CommandAnswering): 30 class Import(base.CommandAnswering):
31 def __init__(self, host): 31 def __init__(self, host):
32 super(Import, self).__init__(host, 'import', use_progress=True, help=_(u'import an external blog')) 32 super(Import, self).__init__(host, 'import', use_progress=True, help=_(u'import an external blog'))
33 self.need_loop=True
33 34
34 def add_parser_options(self): 35 def add_parser_options(self):
35 self.parser.add_argument("importer", type=base.unicode_decoder, nargs='?', help=_(u"importer name, nothing to display importers list")) 36 self.parser.add_argument("importer", type=base.unicode_decoder, nargs='?', help=_(u"importer name, nothing to display importers list"))
36 self.parser.add_argument('--host', type=base.unicode_decoder, help=_(u"original blog host")) 37 self.parser.add_argument('--host', type=base.unicode_decoder, help=_(u"original blog host"))
37 self.parser.add_argument('--no-images-upload', action='store_true', help=_(u"do *NOT* upload images (default: do upload images)")) 38 self.parser.add_argument('--no-images-upload', action='store_true', help=_(u"do *NOT* upload images (default: do upload images)"))
65 66
66 def error(self, failure): 67 def error(self, failure):
67 self.disp(_("Error while trying to upload a blog: {reason}").format(reason=failure), error=True) 68 self.disp(_("Error while trying to upload a blog: {reason}").format(reason=failure), error=True)
68 self.host.quit(1) 69 self.host.quit(1)
69 70
70 def connected(self): 71 def start(self):
71 """Send files to jabber contact"""
72 self.need_loop=True
73 super(Import, self).connected()
74
75 if self.args.location is None: 72 if self.args.location is None:
76 for name in ('option', 'service', 'no_images_upload'): 73 for name in ('option', 'service', 'no_images_upload'):
77 if getattr(self.args, name): 74 if getattr(self.args, name):
78 self.parser.error(_(u"{name} argument can't be used without location argument").format(name=name)) 75 self.parser.error(_(u"{name} argument can't be used without location argument").format(name=name))
79 if self.args.importer is None: 76 if self.args.importer is None:
106 self.host.bridge.blogImport(self.args.importer, self.args.location, options, self.args.service, self.profile, 103 self.host.bridge.blogImport(self.args.importer, self.args.location, options, self.args.service, self.profile,
107 callback=gotId, errback=self.error) 104 callback=gotId, errback=self.error)
108 105
109 106
110 class Blog(base.CommandBase): 107 class Blog(base.CommandBase):
111 subcommands = (Import,) 108 subcommands = (Edit, Import)
112 109
113 def __init__(self, host): 110 def __init__(self, host):
114 super(Blog, self).__init__(host, 'blog', use_profile=False, help=_('blog/microblog management')) 111 super(Blog, self).__init__(host, 'blog', use_profile=False, help=_('blog/microblog management'))