1
# gozerbot/utils/reboot.py
12
from gozerbot.fleet import fleet
13
from gozerbot.config import config
15
from simplejson import dump
17
import os, sys, pickle, tempfile
32
.. literalinclude:: ../../gozerbot/reboot.py
38
os.execl(sys.argv[0], *sys.argv)
40
def reboot_stateful(bot, ievent, fleet, partyline):
42
reboot the bot, but keep the connections.
44
:param bot: bot on which the reboot command is given
45
:type bot: gozerbot.botbase.BotBase
46
:param ievent: event that triggered the reboot
47
:type ievent: gozerbot.eventbase. EventBase
48
:param fleet: the fleet of the bot
49
:type fleet: gozerbot.fleet.Fleet
50
:param partyline: partyline of the bot
51
:type partyline: gozerbot.partyline.PartyLine
53
.. literalinclude:: ../../gozerbot/reboot.py
54
:pyobject: reboot_stateful
58
session = {'bots': {}, 'name': bot.name, 'channel': ievent.channel, 'partyline': []}
61
session['bots'].update(i._resumedata())
63
session['partyline'] = partyline._resumedata()
64
sessionfile = tempfile.mkstemp('-session', 'gozerbot-')[1]
65
dump(session, open(sessionfile, 'w'))
67
fleet.exit(jabber=True)
68
os.execl(sys.argv[0], sys.argv[0], '-r', sessionfile)