def off(crontab_id): crontab = Crontab.get(crontab_id) if not crontab: return jsonify({'r': 1, 'msg': 'not found'}) if not get_crontab(crontab): return jsonify({'r': 1, 'msg': 'already off'}) remove_crontab(crontab) return jsonify({'r': 0, 'msg': 'ok'})
def on(crontab_id): crontab = Crontab.get(crontab_id) if not crontab: return jsonify({'r': 1, 'msg': 'not found'}) if get_crontab(crontab): return jsonify({'r': 1, 'msg': 'already on'}) add_crontab(crontab) return jsonify({'r': 0, 'msg': 'ok'})