jabber_mirror: Don't try to restart on errors caused by initial configuration
(imported from commit 5d9e6c88e1a159fe6e5e46c21c483b5c79444223)
This commit is contained in:
parent
a4f3a0c79e
commit
43ef992ab0
|
@ -44,6 +44,11 @@ while backoff.keep_going():
|
||||||
ret = subprocess.call(args)
|
ret = subprocess.call(args)
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
else:
|
||||||
|
if ret == 2:
|
||||||
|
# Don't try again on initial configuration errors
|
||||||
|
sys.exit(ret)
|
||||||
|
|
||||||
backoff.fail()
|
backoff.fail()
|
||||||
|
|
||||||
print ""
|
print ""
|
||||||
|
|
|
@ -289,6 +289,10 @@ def get_rooms(zulip):
|
||||||
rooms.append(stream_to_room(stream))
|
rooms.append(stream_to_room(stream))
|
||||||
return rooms
|
return rooms
|
||||||
|
|
||||||
|
def config_error(msg):
|
||||||
|
sys.stderr.write("%s\n" % (msg,))
|
||||||
|
sys.exit(2)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = optparse.OptionParser(epilog=
|
parser = optparse.OptionParser(epilog=
|
||||||
'''Most general and Jabber configuration options may also be specified in the
|
'''Most general and Jabber configuration options may also be specified in the
|
||||||
|
@ -383,11 +387,11 @@ option does not affect login credentials.'''.replace("\n", " "))
|
||||||
options.zulip_email_suffix = ''
|
options.zulip_email_suffix = ''
|
||||||
|
|
||||||
if options.mode not in ('public', 'personal'):
|
if options.mode not in ('public', 'personal'):
|
||||||
sys.exit("Bad value for --mode: must be one of 'public' or 'personal'")
|
config_error("Bad value for --mode: must be one of 'public' or 'personal'")
|
||||||
|
|
||||||
if None in (options.jid, options.jabber_password):
|
if None in (options.jid, options.jabber_password):
|
||||||
sys.exit("You must specify your Jabber JID and Jabber password either "
|
config_error("You must specify your Jabber JID and Jabber password either "
|
||||||
+ "in the Zulip configuration file or on the commandline")
|
+ "in the Zulip configuration file or on the commandline")
|
||||||
|
|
||||||
zulip = ZulipToJabberBot(zulip.init_from_options(options, "JabberMirror/" + __version__))
|
zulip = ZulipToJabberBot(zulip.init_from_options(options, "JabberMirror/" + __version__))
|
||||||
# This won't work for open realms that don't have a consistent domain
|
# This won't work for open realms that don't have a consistent domain
|
||||||
|
@ -396,7 +400,7 @@ option does not affect login credentials.'''.replace("\n", " "))
|
||||||
try:
|
try:
|
||||||
jid = JID(options.jid)
|
jid = JID(options.jid)
|
||||||
except InvalidJID as e:
|
except InvalidJID as e:
|
||||||
sys.exit("Bad JID: %s: %s" % (options.jid, e.message))
|
config_error("Bad JID: %s: %s" % (options.jid, e.message))
|
||||||
|
|
||||||
if options.conference_domain is None:
|
if options.conference_domain is None:
|
||||||
options.conference_domain = "conference.%s" % (jid.domain,)
|
options.conference_domain = "conference.%s" % (jid.domain,)
|
||||||
|
|
Loading…
Reference in a new issue