本文整理汇总了Python中mpx.lib.node.as_node函数的典型用法代码示例。如果您正苦于以下问题:Python as_node函数的具体用法?Python as_node怎么用?Python as_node使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了as_node函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: start
def start(self):
self._do_read = getattr(self.parent, self.read_op)
if self.write_op:
self._do_write = getattr(self.parent, self.write_op)
setattr(self, 'set', self._set)
self.inparams_write = self.parent._proxy.methods[self.write_op].inparams
for parameter in self.write_params:
if hasattr(self.__call_args_w, name):
raise EConfigurationInvalid(name)
if value.startswith('/') and is_node_url(value):
setattr(self.__call_args_w, name, as_node(value))
else:
setattr(self.__call_args_w, name, value)
self.inparams_read = self.parent._proxy.methods[self.read_op].inparams
for parameter in self.read_params:
if not self.__call_args_r:
self.__call_args_r = object()
name = parameter['pn']
value = parameter['value']
if hasattr(self.__call_args_r, name):
raise EConfigurationInvalid(name)
if value.startswith('/') and is_node_url(value):
setattr(self.__call_args_r, name, as_node(value))
else:
setattr(self.__call_args_r, name, value)
return super(RemoteWebServiceOp, self).start()
开发者ID:mcruse,项目名称:monotone,代码行数:26,代码来源:soap_proxy.py
示例2: __init__
def __init__(self, port1, port2):
self.port1 = as_node('/interfaces/'+port1)
self.port2 = as_node('/interfaces/'+port2)
# it's just a helper class that is part of the Serial Tests
super(_PortTester, self).__init__()
self._test_name = 'SerialTester'
return
开发者ID:mcruse,项目名称:monotone,代码行数:7,代码来源:serial.py
示例3: create_node
def create_node(self, factory, nodeurl, **config):
try:
as_node(nodeurl)
except KeyError:
pass
else:
raise TypeError("Node exists: %s" % nodeurl)
if isinstance(factory, str):
module,sep,name = factory.rpartition(".")
if name:
exec("import %s" % module)
factory = eval(factory)
parent,sep,name = nodeurl.rpartition("/")
configuration = {"name": name, "parent": parent}
configuration.update(config)
node = factory()
try:
node.configure(configuration)
except:
msglog.log("broadway", msglog.types.WARN,
"Error prevented configuration of new node: %s" % node)
msglog.exception(prefix="handled")
try:
node.prune()
except:
msglog.exception(prefix="handled")
else:
msglog.log("broadway", msglog.types.INFO,
"Node successfully pruned.")
else:
msglog.log("broadway", msglog.types.INFO,
"New node created: %s" % node)
self.updatepdo(nodeurl, node)
node.start()
return node.configuration()
开发者ID:mcruse,项目名称:monotone,代码行数:35,代码来源:configurator.py
示例4: _get_bcu_time
def _get_bcu_time( self ):
if self.debug: print 'get bcu time'
if self.bcu_time_node is None:
self.bcu_time_node = as_node(self.bcu_time) #could test classes etc
if self.bcu_date_node is None:
self.bcu_date_node = as_node(self.bcu_date)
y, m, d, dwk = self.bcu_date_node.get(1).value.value #should be date list
hour, min, second, hundreths = self.bcu_time_node.get(1).value.value #should be time list
answer = ((m, d, y), hour * 3600 + min * 60 + second)
if self.debug: print 'bcu time', y, m, d, dwk, hour, min, second, hundreths
return answer
开发者ID:mcruse,项目名称:monotone,代码行数:11,代码来源:time_synch_bcu.py
示例5: start
def start(self):
if self.is_running():
return
if as_node('/services').has_child('Entity Manager'):
em = as_node('/services/Entity Manager')
if not em.is_running():
# see if this function is already wrapped. If it is wrapped
# im_self is not an attribute.
if hasattr(em.do_start, 'im_self'):
em.do_start = wrapped(em.do_start, None, self.do_start)
return
self.do_start()
开发者ID:mcruse,项目名称:monotone,代码行数:12,代码来源:manager.py
示例6: __call__
def __call__(self, local=False):
if self.alarm is None:
try:
self.alarm = as_node(self.state['url'])
except KeyError:
self.alarm = self.state.get('class')()
config = self.state['config']
parent = as_node(config['parent'])
config.setdefault('nodespace', parent.nodespace)
self.alarm.configure(config)
self.alarm.start()
return self.alarm
开发者ID:mcruse,项目名称:monotone,代码行数:12,代码来源:adapters.py
示例7: start
def start(self):
self._alias_root = as_node('/aliases')
# if the NBM supports BACnet, defer start up of entity infrastructure
# until BACnet starts.
for node in as_node('/services/network').children_nodes():
if isinstance(node, BACnet):
if not node.is_running():
# see if this function is already wrapped. If it is wrapped
# im_self is not an attribute.
if hasattr(node.start, 'im_self'):
node.start = wrapped(node.start, None, self.do_start)
return
self.do_start()
开发者ID:mcruse,项目名称:monotone,代码行数:13,代码来源:entity.py
示例8: __call__
def __call__(self):
if self.trigger is None:
try: self.trigger = as_node(self.state['url'])
except KeyError: self.trigger = self.state.get('class')()
config = self.state['config']
parent = as_node(config['parent'])
config.setdefault('nodespace', parent.nodespace)
self.trigger.configure(config)
if self.state['running']:
self.trigger.start()
for target in self.state.get('targets', []):
self.trigger.add_target(target)
return self.trigger
开发者ID:mcruse,项目名称:monotone,代码行数:13,代码来源:adapters.py
示例9: __node_from_components
def __node_from_components(klass, components):
elements = ['/']
parent = as_node('/')
for element, factory in components:
elements.append(urllib.quote(element))
path = os.path.join(*elements)
if node_exists(path):
parent = as_node(path)
continue
msglog.log('Device Manager', msglog.types.INFO,
"Creating %r." % path)
node = factory()
node.configure({'parent':parent,'name':element})
parent = node
return parent
开发者ID:mcruse,项目名称:monotone,代码行数:15,代码来源:manager.py
示例10: move_sched
def move_sched(self, source, destination, cfg, is_rename=False):
source = normalize_nodepath(source)
destination = normalize_nodepath(destination)
for sched in self.get_scheds():
if not sched.startswith(source):
continue
data = self._persisted_data[sched]
del self._persisted_data[sched]
if sched == source:
# rename
if is_rename:
newsched = destination
else:
newsched = sched.replace(source, destination) + source.split('/')[-2] + '/'
oldroot = sched
newroot = newsched
self._persisted_data[newsched] = data
# prior to persisting, the schedule should have been moved
# within the nodetree. We grab and persist the latest configuration.
# This put call will also ensure sync to disk to takes place.
self.put_sched_cfg(newsched, cfg)
else:
newsched = normalize_nodepath(sched.replace(oldroot, newroot)) #+ sched_name + '/'
self._persisted_data[newsched] = data
self.put_sched_cfg(newsched, serialize_node(as_node(newsched)))
开发者ID:mcruse,项目名称:monotone,代码行数:25,代码来源:persist.py
示例11: get
def get(self):
try:
node = as_node(self.nodeurl)
except ENoSuchName:
return ''
else:
return node.attributes.get(self.attribute, '')
开发者ID:mcruse,项目名称:monotone,代码行数:7,代码来源:dispatch.py
示例12: configure
def configure(self, config):
set_attribute(self, 'debug', 0, config, int)
set_attribute(self, 'ip', '', config)
default = '${mpx.properties.%s_PORT}' % self.server_type
set_attribute(self,'port',default,config,int)
set_attribute(self,'user_manager',
as_node('/services/User Manager'),config,as_node)
set_attribute(self,'authentication','form',config)
if (self.authentication is not None and
self.authentication not in ('digest','basic','form')):
raise EInvalidValue('authentication',self.authentication,
'Authentication scheme not recognized.')
set_attribute(self,'port',default,config,int)
set_attribute(self, 'maintenance_interval', 25, config, int)
set_attribute(self, 'zombie_timeout', 600, config, int)
set_attribute(self, 'thread_count', 3, config, int)
if not self.has_child("Request Responder"):
self._setup_request_responder()
if not self.has_child("Authenticator"):
self._setup_authentication_handler()
if not self.has_child("PSP Handler"):
self._setup_psp_handler()
if not self.has_child("JSON-RPC Handler"):
self._setup_json_handler()
ServiceNode.configure(self, config)
开发者ID:mcruse,项目名称:monotone,代码行数:25,代码来源:__init__.py
示例13: handle_request
def handle_request(self, request):
request._DynamicLogHandler__success = False
path = request.get_path()
if request.has_query():
query = request.get_query_dictionary()
log_name = ""
if (query.has_key('node_url')):
log_name = query['node_url']
else:
if path[-1] == '/':
path = path[0:-1]
log_name = path[len(self.request_path):]
log_name = os.path.join('/services/logger', log_name)
#use as_node to follow Aliases
log_node = as_node(log_name)
if (query.has_key('action')):
action = query['action']
if action == 'download_all':
self.download_all(request, log_node, query)
elif action == 'download_slice':
self.download_slice(request, log_node, query)
elif action == 'download_sequence':
self.download_sequence(request, log_node, query)
if not request._DynamicLogHandler__success:
raise EInternalError('Failed to handle request.')
return
开发者ID:mcruse,项目名称:monotone,代码行数:26,代码来源:download_handler.py
示例14: clear_subscr
def clear_subscr(self, targets=None):
if self.line_handler is None:
return
if (type(targets) == types.ListType):
targets0_type = type(targets[0])
if (targets0_type == types.TupleType):
pass
elif (targets0_type == types.StringType):
new_targets = []
for node_URL in targets:
node = None
try:
node = as_node(node_URL)
except ENoSuchName:
msglog.exception()
continue
new_targets.append((node.lan_address,node.id_number,))
if len(new_targets) == 0:
return
targets = new_targets
else:
raise EInvalidValue('targets',targets,'Should be None, int, ' \
'or list of 2-tuples (dev_id, obj_id) or ' \
'a list of node URL strings.')
self.line_handler.clear_subscr(targets)
return
开发者ID:mcruse,项目名称:monotone,代码行数:26,代码来源:rznet_node.py
示例15: create_partition_tree
def create_partition_tree(name, mount_point):
global storage_root_url
children_names = ['available',
'size',
'used',
]
msgstr = 'In create_drive_tree with name of %s ' % name
msgstr += 'and mount_point of %s.' % mount_point
msglog.log('Services_Storage', msglog.types.INFO,
msgstr)
pnode = as_node(storage_root_url)
dict = {'name':name,
'mount_point':mount_point,
'debug':1,
'parent':pnode,
}
drive_node = DriveNode()
drive_node.configure(dict)
#
for x in children_names:
dict = {'name':x,
'debug':1,
'parent':drive_node,
}
drive_attr_node = DriveAttributeNode()
drive_attr_node.configure(dict)
#
drive_node.start()
开发者ID:mcruse,项目名称:monotone,代码行数:28,代码来源:storage.py
示例16: get_subject
def get_subject(self):
if self.__subject is None:
if self.is_remote():
self.set_subject(as_node(self.as_remote_url()))
else:
self.set_subject(self)
return self.__subject
开发者ID:mcruse,项目名称:monotone,代码行数:7,代码来源:entity.py
示例17: save_trends
def save_trends(self, trend_list):
# Traverse through _pdo.items and check if new domain is either subset
# of any configured or superset.
# If subset return with msg already covered and dont save this
# If superset then configure new ones and delete subset from
# _pdo.items
'''Adding and saving trends'''
for point in reversed(trend_list):
point_period = point['frequency']
point_domain = point['domain']
for saved_domain,saved_period in tuple(self._pdo.trends.items()):
if saved_domain == point_domain:
if saved_period != point_period:
self.delete_trend_configuration(saved_domain)
break
if not self._pdo.trends.has_key(point_domain):
# add this trend
try:
domain_node = as_node(point_domain)
if isinstance(domain_node,EnergywiseSwitch) or isinstance(domain_node,EnergywiseDomain):
self.add_trend_configuration(point_period, point_domain)
domain_node.new_trend(point_period)
except Exception:
msglog.exception()
msglog.log(
"Energywise",msglog.types.ERR,
"Failed to create trend for %r every %r seconds"
%(point_domain,point_period)
)
return
开发者ID:mcruse,项目名称:monotone,代码行数:30,代码来源:energywise_manager.py
示例18: handle_request
def handle_request(self, request):
response = Response(request)
request_data = request.get_post_data_as_dictionary()
request_data.update(request.get_query_string_as_dictionary())
if not (request_data.has_key('type') and
request_data.has_key('id') and
request_data.has_key('method')):
response.error(400, 'Missnig required param type, id, or method.')
return
id = urllib.unquote_plus(request_data.get('id')[0])
if request_data.get('type')[0] == 'node':
target = as_node(id)
elif request_data.get('type')[0] == 'event':
target = Event.get_event(id)
else:
response.error(400, 'Unknown type.')
return
methodname = urllib.unquote_plus(request_data.get('method')[0])
method = getattr(target, methodname)
args = urllib.unquote_plus(request_data.get('args', ['()'])[0])
args = eval(args)
keywords = urllib.unquote_plus(request_data.get('keywords', ['{}'])[0])
keywords = eval(keywords)
result = method(*args, **keywords)
result = repr(result)
self.message('Invoking %s on %s with %s, %s, returned %s' % (
methodname, id, args, keywords, result))
response.send(result)
开发者ID:mcruse,项目名称:monotone,代码行数:28,代码来源:request_handler.py
示例19: start
def start(self):
super(Kwh2Kw, self).start()
self.running = True
self._history = KwList(self._window_size)
self._sid = SM.create_polled({self._nid:self.link})
# retrieve an initial value to start things off
value = ts = None
result = SM.poll_all(self._sid)
if result is None:
# still waiting
try:
value = as_node(self.link).get()
ts = time.time()
except:
pass
else:
try:
value = result[self._nid]['value']
ts = result[self._nid]['timestamp']
except:
pass
if isinstance(value, MpxException):
value = None
if value and ts:
self._history.add(value, ts)
self._scheduled = scheduler.seconds_from_now_do(self.sample_period, self.run_update)
return
开发者ID:mcruse,项目名称:monotone,代码行数:27,代码来源:kwh2kw.py
示例20: start
def start(self):
Column.start(self)
if (type(self.__function_config) == types.StringType and
string.count(self.__function_config,'as_node') == 1 and
self.__function_config.endswith('get')):
func = self.__function_config
self.__node = as_node(func[func.find('(')+2:func.rfind(')')-1])
if self.use_subscription_manager:
self._sid = SM.create_delivered(self, {1:as_node_url(self.__node)})
self.function = self.get_last
else:
self.function = getattr(self.__node,func[func.rfind('.')+1:])
rexec = self.parent.parent.get_environment()
self.original_function = RFunction(self.function, args=self.args,
context=self.context,
rexec=rexec)
self.function = self._convert
self.variables = {}
nodes = self.children_nodes()
for potential_calculator in nodes:
if hasattr(potential_calculator, 'evaluate'):
if self._calculator: #oops
raise EAttributeError('Too many calculator nodes', self)
self._calculator = potential_calculator
self.function = self._evaluate # hook the calculator in
self.__original_function = self.original_function
self.original_function = self.__evaluate_original_function
self.__started = 1
开发者ID:mcruse,项目名称:monotone,代码行数:28,代码来源:periodic_column.py
注:本文中的mpx.lib.node.as_node函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论