def main(): if not isHaggleRunning(): print "haggle is not running!" sys.exit(-1) print sys.argv[1], sys.argv[2],sys.argv[3] fileowner = sys.argv[1] interest = sys.argv[2] loopcounter = int(sys.argv[3]) hagglehandle_ptr = haggle.haggle_handle_t() retcode = haggle.haggle_handle_get("a17",byref(hagglehandle_ptr)) if retcode < 0: print "unable to get haggle handle retcode=",retcode sys.exit(-1) print on_dataobject_func registerEvents(hagglehandle_ptr) retcode = haggle.haggle_ipc_add_application_interest(hagglehandle_ptr, "FileOwner", interest); for i in range(loopcounter): print i content = "testmessage|"+fileowner+"||"+str(i)+"|" publishDataObjectFromString(hagglehandle_ptr,content,fileowner,i) while(True): time.sleep(5)
def main(): if not isHaggleRunning(): print "haggle is not running!" sys.exit(-1) print sys.argv[1] interest = sys.argv[1] hagglehandle_ptr = haggle.haggle_handle_t() retcode = haggle.haggle_handle_get("imagesubscribe1",byref(hagglehandle_ptr)) if retcode < 0: print "unable to get haggle handle retcode=",retcode sys.exit(-1) print on_dataobject_func registerEvents(hagglehandle_ptr) retcode = haggle.haggle_ipc_add_application_interest(hagglehandle_ptr, "FileOwner", interest); while(True): time.sleep(5)
def main(): if not isHaggleRunning(): logger.error("haggle is not running!") sys.exit(-1) print sys.argv[1], sys.argv[2], sys.argv[3] fileowner = sys.argv[1] imagepath = sys.argv[2] forever = sys.argv[3] hagglehandle_ptr = haggle.haggle_handle_t() retcode = haggle.haggle_handle_get("imagepublisher", byref(hagglehandle_ptr)) if retcode < 0: print "unable to get haggle handle retcode=", retcode sys.exit(-1) hagglesessionid = haggle.haggle_handle_get_session_id(hagglehandle_ptr) print "haggle sessionid=", hagglesessionid print on_dataobject_func registerEvents(hagglehandle_ptr) cnt = 0 while True: cnt = cnt + 1 #dataobject api does not set stored. so copy the file destinationFile = imagepath + ".copy" shutil.copyfile(imagepath, destinationFile) publishImage(hagglehandle_ptr, imagepath, fileowner, cnt) time.sleep(10) if "true" != forever.lower(): break while (True): time.sleep(5)
def main(): if not isHaggleRunning(): logger.error("haggle is not running!") sys.exit(-1) print sys.argv[1], sys.argv[2], sys.argv[3] fileowner = sys.argv[1] imagepath = sys.argv[2] forever = sys.argv[3] hagglehandle_ptr = haggle.haggle_handle_t() retcode = haggle.haggle_handle_get("imagepublisher",byref(hagglehandle_ptr)) if retcode < 0: print "unable to get haggle handle retcode=",retcode sys.exit(-1) hagglesessionid = haggle.haggle_handle_get_session_id(hagglehandle_ptr); print "haggle sessionid=",hagglesessionid print on_dataobject_func registerEvents(hagglehandle_ptr) cnt = 0 while True: cnt = cnt + 1 #dataobject api does not set stored. so copy the file destinationFile = imagepath+".copy" shutil.copyfile(imagepath,destinationFile) publishImage(hagglehandle_ptr,imagepath,fileowner,cnt) time.sleep(10) if "true" != forever.lower(): break while(True): time.sleep(5)