forked from qd-today/qd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask.py
More file actions
43 lines (38 loc) · 1.67 KB
/
task.py
File metadata and controls
43 lines (38 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2016 Binux <roy@binux.me>
import config
from db.task import TaskDB as _TaskDB
from .basedb import BaseDB
class TaskDB(_TaskDB, BaseDB):
def __init__(self, path=config.sqlite3.path):
self.path = path
self._execute('''CREATE TABLE IF NOT EXISTS `%s` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`tplid` INT UNSIGNED NOT NULL,
`userid` INT UNSIGNED NOT NULL,
`disabled` TINYINT(1) NOT NULL DEFAULT 0,
`init_env` BLOB NULL,
`env` BLOB NULL,
`session` BLOB NULL,
`last_success` INT UNSIGNED NULL,
`last_failed` INT UNSIGNED NULL,
`success_count` INT UNSIGNED NOT NULL DEFAULT 0,
`failed_count` INT UNSIGNED NOT NULL DEFAULT 0,
`last_failed_count` INT UNSIGNED NOT NULL DEFAULT 0,
`next` INT UNSIGNED NULL DEFAULT NULL,
`note` VARCHAR(256) NULL,
`ctime` INT UNSIGNED NOT NULL,
`mtime` INT UNSIGNED NOT NULL,
`ontimeflg` INT UNSIGNED NOT NULL DEFAULT 0,
`ontime` VARCHAR(256) NOT NULL DEFAULT '00:10:00',
`_groups` VARCHAR(256) NOT NULL DEFAULT 'None',
`pushsw` VARBINARY(128) NOT NULL DEFAULT '{\"logen\":false,\"pushen\":true}',
`newontime` VARBINARY(256) NOT NULL DEFAULT '{\"sw\":false,\"time\":\"00:10:10\",\"randsw\":false,\"tz1\":0,\"tz2\":0}'
)''' % self.__tablename__)
for each in ('userid', 'tplid'):
t = '''CREATE INDEX IF NOT EXISTS `ix_%s_%s` ON %s (%s)''' % (
self.__tablename__, each, self.__tablename__, each)
self._execute(t)