-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplaybook.py
56 lines (51 loc) · 3.78 KB
/
playbook.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from plugins.playbook.models import playbook as pb
from core import plugin, model
class _playbook(plugin._plugin):
version = 1.48
def install(self):
# Register models
model.registerModel("playbook","_playbook","_document","plugins.playbook.models.playbook",True)
model.registerModel("playbookStart","_playbookStart","_action","plugins.playbook.models.action")
model.registerModel("playbookEnd","_playbookEnd","_action","plugins.playbook.models.action")
model.registerModel("playbookSearch","_playbookSearch","_trigger","plugins.playbook.models.trigger")
model.registerModel("playbookGet","_playbookGet","_action","plugins.playbook.models.action")
model.registerModel("playbookSearchAction","_playbookSearchAction","_action","plugins.playbook.models.action")
model.registerModel("playbookAdd","_playbookAdd","_action","plugins.playbook.models.action")
model.registerModel("playbookUpdateData","_playbookUpdateData","_action","plugins.playbook.models.action")
model.registerModel("playbookStartUpdate","_playbookStartUpdate","_action","plugins.playbook.models.action")
model.registerModel("playbookBulkAdd","_playbookBulkAdd","_action","plugins.playbook.models.action")
pb._playbook()._dbCollection.create_index("name")
pb._playbook()._dbCollection.create_index([("name", 1),("occurrence", 1)])
return True
def uninstall(self):
# deregister models
model.deregisterModel("playbook","_playbook","_document","plugins.playbook.models.playbook")
model.deregisterModel("playbookStart","_playbookStart","_action","plugins.playbook.models.action")
model.deregisterModel("playbookEnd","_playbookEnd","_action","plugins.playbook.models.action")
model.deregisterModel("playbookSearch","_playbookSearch","_action","plugins.playbook.models.trigger")
model.deregisterModel("playbookGet","_playbookGet","_action","plugins.playbook.models.action")
model.deregisterModel("playbookSearchAction","_playbookSearchAction","_action","plugins.playbook.models.action")
model.deregisterModel("playbookAdd","_playbookAdd","_action","plugins.playbook.models.action")
model.deregisterModel("playbookUpdateData","_playbookUpdateData","_action","plugins.playbook.models.action")
model.deregisterModel("playbookStartUpdate","_playbookStartUpdate","_action","plugins.playbook.models.action")
model.deregisterModel("playbookBulkAdd","_playbookBulkAdd","_action","plugins.playbook.models.action")
return True
def upgrade(self,LatestPluginVersion):
if self.version < 0.4:
model.registerModel("playbookSearch","_playbookSearch","_trigger","plugins.playbook.models.trigger")
if self.version < 0.5:
model.registerModel("playbookGet","_playbookGet","_action","plugins.playbook.models.action")
if self.version < 1.2:
model.registerModel("playbookSearchAction","_playbookSearchAction","_action","plugins.playbook.models.action")
if self.version < 1.3:
model.registerModel("playbookAdd","_playbookAdd","_action","plugins.playbook.models.action")
model.registerModel("playbookUpdateData","_playbookUpdateData","_action","plugins.playbook.models.action")
if self.version < 1.4:
model.registerModel("playbookStartUpdate","_playbookStartUpdate","_action","plugins.playbook.models.action")
if self.version < 1.45:
model.registerModel("playbookBulkAdd","_playbookBulkAdd","_action","plugins.playbook.models.action")
if self.version < 1.47:
print("Creating indexes...")
pb._playbook()._dbCollection.create_index("name")
pb._playbook()._dbCollection.create_index([("name", 1),("occurrence", 1)])
return True