~loyalinfo/openerp-tools/trunk

« back to all changes in this revision

Viewing changes to openerp-runbot/openerprunbot/server.py

  • Committer: Olivier Dony
  • Date: 2013-10-29 20:26:24 UTC
  • Revision ID: odo@openerp.com-20131029202624-znvibyt0ge3pan5t
[IMP] runbot: rough method to delete a running group

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
    # Replace the whole dictionary at once.
91
91
    openerprunbot.state = state
92
92
 
 
93
def _delete(team, group):
 
94
    if team == 'openerp-dev' and group in openerprunbot.core.SERIES_BRANCHES:
 
95
        print 'delete', team, group, "ignored (core group)"
 
96
        return
 
97
    group_id = (team, group)
 
98
    group = openerprunbot.runbot.groups.get(group_id)
 
99
    if group:
 
100
        if group.is_sticky():
 
101
            print 'delete', team, group, "ignored (sticky)"
 
102
            return
 
103
        print 'delete', team, group
 
104
        del openerprunbot.runbot.groups[group_id]
 
105
        for j in group.points:
 
106
            j.stop()
 
107
        def f(state):
 
108
            # TODO check team and group are valid
 
109
            state.setdefault(team, {})
 
110
            state[team].pop(group, None)
 
111
            if not state[team]:
 
112
                del state[team]
 
113
        _with_state(f)
 
114
 
93
115
def _stick(team, group):
94
116
    print 'stick', team, group
95
117
    def f(state):
216
238
        if query.get('team'):
217
239
            team = query['team'][0]
218
240
 
 
241
            if query.get('deletegroup'):
 
242
                group = query['deletegroup'][0]
 
243
                _delete(team, group)
 
244
                response = group + ' is gone forever!'
 
245
                return send_notice(response)
 
246
 
219
247
            if query.get('stick'):
220
248
                group = query['stick'][0]
221
249
                _stick(team, group)