Checkin of 0.2.98 upstream source
[time-slider.git] / usr / share / time-slider / lib / plugin / pluginsmf.py
1 #!/usr/bin/python2.6
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22
23 import os
24 import sys
25 import subprocess
26 from os.path import abspath, dirname, join, pardir
27 sys.path.insert(0, join(dirname(__file__), pardir))
28 from time_slider import smf, autosnapsmf, util
29
30
31 PLUGINBASEFMRI = "svc:/application/time-slider/plugin"
32 PLUGINPROPGROUP = "plugin"
33
34 class PluginSMF(smf.SMFInstance):
35
36     def __init__(self, instanceName):
37         smf.SMFInstance.__init__(self, instanceName)
38         self.triggerCommand = None
39         self.triggers = None
40
41     def get_trigger_command(self):
42         # FIXME Use mutex locking for MT safety
43         if self.triggerCommand == None:
44             value = self.get_prop(PLUGINPROPGROUP, "trigger_command")
45             self.triggerCommand = value.strip()
46         return self.triggerCommand            
47
48     def get_trigger_list(self):
49         #FIXME Use mutex locking to make MT-safe
50         if self.triggers == None:
51             self.triggers = []
52             value = self.get_prop(PLUGINPROPGROUP, "trigger_on")
53             
54             # Strip out '\' characters inserted by svcprop
55             triggerList = value.strip().replace('\\', '').split(',')
56             for trigger in triggerList:
57                 self.triggers.append(trigger.strip())
58         return self.triggers
59
60     def get_verbose(self):
61         value = self.get_prop(PLUGINPROPGROUP, "verbose")
62         if value == "true":
63             return True
64         else:
65             return False
66