1 #!/usr/bin/env python |
1 #!/usr/bin/env python |
2 # -*- coding: utf-8 -*- |
2 # -*- coding: utf-8 -*- |
|
3 |
|
4 # This file is part of Beremiz, a Integrated Development Environment for |
|
5 # programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
3 # |
6 # |
4 # Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
7 # Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
5 # |
8 # |
6 # See COPYING file for copyrights details. |
9 # See COPYING file for copyrights details. |
7 # |
10 # |
8 # This library is free software; you can redistribute it and/or |
11 # This program is free software; you can redistribute it and/or |
9 # modify it under the terms of the GNU General Public |
12 # modify it under the terms of the GNU General Public License |
10 # License as published by the Free Software Foundation; either |
13 # as published by the Free Software Foundation; either version 2 |
11 # version 2.1 of the License, or (at your option) any later version. |
14 # of the License, or (at your option) any later version. |
12 # |
15 # |
13 # This library is distributed in the hope that it will be useful, |
16 # This program is distributed in the hope that it will be useful, |
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 # General Public License for more details. |
19 # GNU General Public License for more details. |
17 # |
20 # |
18 # You should have received a copy of the GNU General Public |
21 # You should have received a copy of the GNU General Public License |
19 # License along with this library; if not, write to the Free Software |
22 # along with this program; if not, write to the Free Software |
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
24 |
21 import Pyro |
25 import Pyro |
22 import Pyro.core |
26 import Pyro.core |
23 import Pyro.util |
27 import Pyro.util |
24 from Pyro.errors import PyroError |
28 from Pyro.errors import PyroError |
25 import traceback |
29 import traceback |
81 if i is None: |
85 if i is None: |
82 raise Exception("'%s' not found" % location) |
86 raise Exception("'%s' not found" % location) |
83 ip = str(socket.inet_ntoa(i.getAddress())) |
87 ip = str(socket.inet_ntoa(i.getAddress())) |
84 port = str(i.getPort()) |
88 port = str(i.getPort()) |
85 newlocation = ip + ':' + port |
89 newlocation = ip + ':' + port |
86 confnodesroot.logger.write(_("'%s' is located at %s\n") % (location, newlocation)) |
90 confnodesroot.logger.write(_("'{a1}' is located at {a2}\n").format(a1 = location, a2 = newlocation)) |
87 location = newlocation |
91 location = newlocation |
88 r.close() |
92 r.close() |
89 except Exception, msg: |
93 except Exception, msg: |
90 confnodesroot.logger.write_error(_("MDNS resolution failure for '%s'\n") % location) |
94 confnodesroot.logger.write_error(_("MDNS resolution failure for '%s'\n") % location) |
91 confnodesroot.logger.write_error(traceback.format_exc()) |
95 confnodesroot.logger.write_error(traceback.format_exc()) |
106 """ |
110 """ |
107 def catcher_func(*args, **kwargs): |
111 def catcher_func(*args, **kwargs): |
108 try: |
112 try: |
109 return func(*args, **kwargs) |
113 return func(*args, **kwargs) |
110 except Pyro.errors.ConnectionClosedError, e: |
114 except Pyro.errors.ConnectionClosedError, e: |
111 confnodesroot.logger.write_error("Connection lost!\n") |
115 confnodesroot.logger.write_error(_("Connection lost!\n")) |
112 confnodesroot._SetConnector(None) |
116 confnodesroot._SetConnector(None) |
113 except Pyro.errors.ProtocolError, e: |
117 except Pyro.errors.ProtocolError, e: |
114 confnodesroot.logger.write_error("Pyro exception: " + str(e) + "\n") |
118 confnodesroot.logger.write_error(_("Pyro exception: %s\n") % e) |
115 except Exception, e: |
119 except Exception, e: |
116 # confnodesroot.logger.write_error(traceback.format_exc()) |
120 # confnodesroot.logger.write_error(traceback.format_exc()) |
117 errmess = ''.join(Pyro.util.getPyroTraceback(e)) |
121 errmess = ''.join(Pyro.util.getPyroTraceback(e)) |
118 confnodesroot.logger.write_error(errmess + "\n") |
122 confnodesroot.logger.write_error(errmess + "\n") |
119 print errmess |
123 print errmess |