-
Notifications
You must be signed in to change notification settings - Fork 0
/
SettingMediator.py
32 lines (24 loc) · 1.13 KB
/
SettingMediator.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
# coding=utf-8
import json
import logging
class SettingMediator:
sm = None
logger = logging.getLogger('SettingMediator')
def __init__(self, ism):
self.sm = ism
def remove(self, name):
self.sm.communication.runCommand("removesetting", '{"name" : "' + name + '"}')
pass
def add(self, name, defValue, isPublic=False, readOnly=False):
self.sm.communication.runCommand('registersetting',
'{"name" : "' + name + '" , "defvalue" : "' + defValue + '" , "public" : "' + str(
isPublic) + '" , "readonly" : "' + str(readOnly) + '"}')
def get(self, name):
resp_data = self.sm.communication.runCommandSync("getsetting", '{"name" : "' + name + '"}')
js = json.loads(resp_data)
return js["value"]
def getAsync(self, name):
self.sm.communication.runCommand("getsetting", '{"name" : "' + name + '"}')
def set(self, name, value):
self.sm.communication.runCommand("setsetting",
'{"name" : "' + name + '", "value" : "' + value + '"}')