if (sys.platform == 'win32'): if (1 in run_tests): # Test #1 :: Create a new object data = {'items':['1','2','3','4','5']} json = tcpipbridge.tcpipConnector(simplejson.dumps(data)) print json print '='*40 def __callback__(*args, **kwargs): print 'DEBUG.%s: args=%s, kwargs=%s' % (misc.funcName(),args,kwargs) return args[0].replace('@vm2','@vm1') if (len(args) > 0) else args __eof__ = '@@@EOF@@@' if (2 in run_tests): tcpipbridge.startTCPIPBridge('127.0.0.1', 55555, callback=__callback__,__eof__=__eof__) print '+'*40 writer = tcpipbridge.SocketWriter('127.0.0.1', 55555) if (0): for i in xrange(0,100): writer.send('HELLO-%s' % (i)) writer.sendFile("C:\@vm2\simple-message-bus\data.json",__eof__=__eof__) time.sleep(1) _utils.terminate('Program complete.') else: print 'Do you have any idea what you are doing ? Get a grip and figure this out ! NOW !'
print 'INFO: Removing "%s".' % (fpath) os.remove(fpath) print 'DEBUG.%s: args=%s, kwargs=%s' % (misc.funcName(),args,kwargs) return None __is_listener__ = __listener__ and _utils.is_valid_ip_and_port(__listener__) __is_ipath__ = __ipath__ and _utils.is_valid_ip_and_port(__ipath__) if (__is_listener__) or (__is_ipath__): if (__is_listener__): cb = __callback2__ listen_to_ip,listen_to_port = tcpipbridge.parse_ip_address_and_port(__listener__, default_ip='0.0.0.0', default_port=50555) elif (__is_ipath__): cb = __callback__ listen_to_ip,listen_to_port = tcpipbridge.parse_ip_address_and_port(__ipath__, default_ip='0.0.0.0', default_port=55555) print 'INFO: Starting TCP/IP Bridge on %s:%s.' % (listen_to_ip, listen_to_port) tcpipbridge.startTCPIPBridge(listen_to_ip, listen_to_port, callback=cb,__eof__=__eof__) if (_utils.is_valid_ip_and_port(__opath__)): connect_to_ip,connect_to_port = tcpipbridge.parse_ip_address_and_port(__opath__, default_ip='0.0.0.0', default_port=55555) print 'INFO: Starting Socket Writer on %s:%s.' % (connect_to_ip, connect_to_port) __writer__ = tcpipbridge.SocketWriter(connect_to_ip, connect_to_port,retry=__retry__) if (__is_listener__): __writer__.send('@@@address=%s:%s@@@' % (listen_to_ip,listen_to_port)) if (__ipath__ and os.path.exists(__ipath__) and os.path.isdir(__ipath__)): print 'INFO: Beginning to look for changes appearing in "%s".' % (__ipath__) FILE_LIST_DIRECTORY = 0x0001 __hDir__ = win32file.CreateFile ( __ipath__, FILE_LIST_DIRECTORY,