| OLD | NEW |
| 1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. | 1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
| 2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr | 2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
| 3 # | 3 # |
| 4 # This file is part of logilab-common. | 4 # This file is part of logilab-common. |
| 5 # | 5 # |
| 6 # logilab-common is free software: you can redistribute it and/or modify it unde
r | 6 # logilab-common is free software: you can redistribute it and/or modify it unde
r |
| 7 # the terms of the GNU Lesser General Public License as published by the Free | 7 # the terms of the GNU Lesser General Public License as published by the Free |
| 8 # Software Foundation, either version 2.1 of the License, or (at your option) an
y | 8 # Software Foundation, either version 2.1 of the License, or (at your option) an
y |
| 9 # later version. | 9 # later version. |
| 10 # | 10 # |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 return daemon | 111 return daemon |
| 112 | 112 |
| 113 def get_object_uri(qnsid): | 113 def get_object_uri(qnsid): |
| 114 return _PYRO_OBJS[qnsid] | 114 return _PYRO_OBJS[qnsid] |
| 115 | 115 |
| 116 def ns_unregister(nsid, defaultnsgroup=_MARKER, nshost=None): | 116 def ns_unregister(nsid, defaultnsgroup=_MARKER, nshost=None): |
| 117 """unregister the object with the given nsid from the pyro name server""" | 117 """unregister the object with the given nsid from the pyro name server""" |
| 118 nsgroup, nsid = ns_group_and_id(nsid, defaultnsgroup) | 118 nsgroup, nsid = ns_group_and_id(nsid, defaultnsgroup) |
| 119 try: | 119 try: |
| 120 nsd = locate_ns(nshost) | 120 nsd = locate_ns(nshost) |
| 121 except errors.PyroError as ex: | 121 except errors.PyroError, ex: |
| 122 # name server not responding | 122 # name server not responding |
| 123 _LOGGER.error('can\'t locate pyro name server: %s', ex) | 123 _LOGGER.error('can\'t locate pyro name server: %s', ex) |
| 124 else: | 124 else: |
| 125 try: | 125 try: |
| 126 nsd.unregister('%s.%s' % (nsgroup, nsid)) | 126 nsd.unregister('%s.%s' % (nsgroup, nsid)) |
| 127 _LOGGER.info('%s unregistered from pyro name server', nsid) | 127 _LOGGER.info('%s unregistered from pyro name server', nsid) |
| 128 except errors.NamingError: | 128 except errors.NamingError: |
| 129 _LOGGER.warning('%s not registered in pyro name server', nsid) | 129 _LOGGER.warning('%s not registered in pyro name server', nsid) |
| 130 | 130 |
| 131 | 131 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 152 | 152 |
| 153 def ns_get_proxy(nsid, defaultnsgroup=_MARKER, nshost=None): | 153 def ns_get_proxy(nsid, defaultnsgroup=_MARKER, nshost=None): |
| 154 """ | 154 """ |
| 155 if nshost is None, the nameserver is found by a broadcast. | 155 if nshost is None, the nameserver is found by a broadcast. |
| 156 """ | 156 """ |
| 157 # resolve the Pyro object | 157 # resolve the Pyro object |
| 158 nsgroup, nsid = ns_group_and_id(nsid, defaultnsgroup) | 158 nsgroup, nsid = ns_group_and_id(nsid, defaultnsgroup) |
| 159 try: | 159 try: |
| 160 nsd = locate_ns(nshost) | 160 nsd = locate_ns(nshost) |
| 161 pyrouri = nsd.resolve('%s.%s' % (nsgroup, nsid)) | 161 pyrouri = nsd.resolve('%s.%s' % (nsgroup, nsid)) |
| 162 except errors.ProtocolError as ex: | 162 except errors.ProtocolError, ex: |
| 163 raise errors.PyroError( | 163 raise errors.PyroError( |
| 164 'Could not connect to the Pyro name server (host: %s)' % nshost) | 164 'Could not connect to the Pyro name server (host: %s)' % nshost) |
| 165 except errors.NamingError: | 165 except errors.NamingError: |
| 166 raise errors.PyroError( | 166 raise errors.PyroError( |
| 167 'Could not get proxy for %s (not registered in Pyro), ' | 167 'Could not get proxy for %s (not registered in Pyro), ' |
| 168 'you may have to restart your server-side application' % nsid) | 168 'you may have to restart your server-side application' % nsid) |
| 169 return core.getProxyForURI(pyrouri) | 169 return core.getProxyForURI(pyrouri) |
| 170 | 170 |
| 171 def get_proxy(pyro_uri): | 171 def get_proxy(pyro_uri): |
| 172 """get a proxy for the passed pyro uri without using a nameserver | 172 """get a proxy for the passed pyro uri without using a nameserver |
| 173 """ | 173 """ |
| 174 return core.getProxyForURI(pyro_uri) | 174 return core.getProxyForURI(pyro_uri) |
| 175 | 175 |
| 176 def set_pyro_log_threshold(level): | 176 def set_pyro_log_threshold(level): |
| 177 pyrologger = logging.getLogger('Pyro.%s' % str(id(util.Log))) | 177 pyrologger = logging.getLogger('Pyro.%s' % str(id(util.Log))) |
| 178 # remove handlers so only the root handler is used | 178 # remove handlers so only the root handler is used |
| 179 pyrologger.handlers = [] | 179 pyrologger.handlers = [] |
| 180 pyrologger.setLevel(level) | 180 pyrologger.setLevel(level) |
| OLD | NEW |