当前位置: 首页>>代码示例>>Python>>正文


Python node.as_node函数代码示例

本文整理汇总了Python中mpx.lib.node.as_node函数的典型用法代码示例。如果您正苦于以下问题:Python as_node函数的具体用法?Python as_node怎么用?Python as_node使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了as_node函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的mpx.lib.node.as_node函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。