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 print join (dirname(__file__), pardir)
29 from time_slider import smf, autosnapsmf, util
30
31
32 PLUGINBASEFMRI = "svc:/application/time-slider/plugin"
33 PLUGINPROPGROUP = "plugin"
34
35 class PluginSMF(smf.SMFInstance):
36
37     def __init__(self, instanceName):
38         smf.SMFInstance.__init__(self, instanceName)
39         self.triggerCommand = None
40         self.triggers = None
41
42     def get_trigger_command(self):
43         # FIXME Use mutex locking for MT safety
44         if self.triggerCommand == None:
45             value = self.get_prop(PLUGINPROPGROUP, "trigger_command")
46             self.triggerCommand = value.strip()
47         return self.triggerCommand            
48
49     def get_trigger_list(self):
50         #FIXME Use mutex locking to make MT-safe
51         if self.triggers == None:
52             self.triggers = []
53             value = self.get_prop(PLUGINPROPGROUP, "trigger_on")
54             
55             # Strip out '\' characters inserted by svcprop
56             triggerList = value.strip().replace('\\', '').split(',')
57             for trigger in triggerList:
58                 self.triggers.append(trigger.strip())
59         return self.triggers
60
61     def get_verbose(self):
62         value = self.get_prop(PLUGINPROPGROUP, "verbose")
63         if value == "true":
64             return True
65         else:
66             return False
67