Home | Trees | Indices | Help |
|
---|
|
1 """ 2 BIANA: Biologic Interactions and Network Analysis 3 Copyright (C) 2009 Javier Garcia-Garcia, Emre Guney, Baldo Oliva 4 5 This program is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 """ 19 20 import traceback 21 import socket 22 import sys 2325 26 outmethod = None 27 out_format = "xml" 2811030 """ 31 Changes the default outmethod to a socket 32 It should not be used by users, only graphical interface should use this method 33 """ 34 35 serverHost = server 36 serverPort = port 37 38 try: 39 # Start socket communication 40 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # create a TCP socket 41 s.connect((serverHost, serverPort)) # connect to server on the port 42 s.send("<?xml version=\"1.0\"?>\r\n") 43 s.send("<biana_to_gui>") 44 OutBianaInterface.outmethod = s.send 45 except: 46 print "Impossible to connect to port %s" %port 47 traceback.print_exc() 48 pass49 50 connect_to_socket = staticmethod(connect_to_socket) 51 54 55 set_outmethod = staticmethod(set_outmethod) 56 60 #sys.stderr.write("M: %s\n"%message) 61 62 send_data = staticmethod(send_data) 6365 if OutBianaInterface.out_format == "xml": 66 OutBianaInterface.send_data("<start_biana_process process=\"%s\" />" %message) 67 else: 68 OutBianaInterface.send_data("%s\n" %message)69 70 send_process_message = staticmethod(send_process_message) 7173 if OutBianaInterface.out_format == "xml": 74 OutBianaInterface.send_data("<end_biana_process />")75 76 send_end_process_message = staticmethod(send_end_process_message) 7779 if OutBianaInterface.out_format == "xml": 80 # To avoid parser error in case error line contains '<', '>' or '&' 81 error = "<![CDATA[%s]]>" % error 82 OutBianaInterface.send_data("<error_notification value=\"%s\">%s</error_notification>" %(message,error)) 83 #sys.stderr.write("M: %s\nE: %s\n" % (message, error)) 84 else: 85 OutBianaInterface.send_data("\n!%s:\n\n%s\n" %(message, error)) 86 87 if OutBianaInterface.outmethod is None: 88 sys.stderr.write(message) 89 sys.stderr.write("\n") 90 sys.stderr.write(error) 91 sys.stderr.write("\n")92 93 send_error_notification = staticmethod(send_error_notification) 9496 if OutBianaInterface.out_format == "xml": 97 message = "<![CDATA[%s]]>" % message 98 OutBianaInterface.send_data("<info_message>%s</info_message>" %(message)) 99 else: 100 OutBianaInterface.send_data("%s" %message)101 102 send_info_message = staticmethod(send_info_message) 103 104 107 108 109 close = staticmethod(close)
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue May 26 17:06:33 2009 | http://epydoc.sourceforge.net |