def main(): activemq_client = StompClient([("autoreduce.isis.cclrc.ac.uk", 61613)], 'autoreduce', 'xxxxxxxxx', 'RUN_BACKLOG') activemq_client.connect() message_lock = threading.Lock() for inst in INSTRUMENTS: # Create an event_handler, this will decide what to do when files are changed. event_handler = InstrumentMonitor(inst['name'], inst['use_nexus'], activemq_client, message_lock) # This will watch the folder the program is in, it will pick up all changes made in the folder. path = event_handler.get_watched_folder() # Tell the observer what to watch and give it the class that will handle the events. observer.schedule(event_handler, path) # Start watching files. observer.start()
def main(): activemq_client = StompClient([("autoreduce.isis.cclrc.ac.uk", 61613)], 'autoreduce', 'xxxxxxxxxxxxxxx', 'RUN_BACKLOG') activemq_client.connect() inp = {} if len(sys.argv) < 5: inp["inst_name"] = raw_input('Enter instrument name: ').upper() inp["min_run"] = int(raw_input('Start run number: ')) inp["max_run"] = int(raw_input('End run number: ')) inp["rename"] = raw_input('Use .nxs file? [Y/N]: ').lower() inp["rbnum"] = lookup_rb_number(inp["inst_name"], inp["min_run"]) # Assume all RBs are the same as the first if inp["rbnum"] == -1: print "Lookup failed" inp["rbnum"] = int(raw_input('RB Number: ')) else: print "Found rb number: " + str(inp["rbnum"]) inp["cycle"] = raw_input('Enter cycle number in format [14_3]: ') else: inp["inst_name"] = str(sys.argv[1]).upper() inp["min_run"] = int(sys.argv[2]) inp["max_run"] = int(sys.argv[3]) inp["rename"] = 'y' # change to use nxs file inp["rbnum"] = int(sys.argv[4]) # cast to int to test RB inp["cycle"] = str(sys.argv[5]) validate_input(inp) data_file_prefix, data_filename_length = get_file_name_data(inp["inst_name"]) data_location = DATA_LOC % (inp["inst_name"], inp["cycle"]) for run in range(inp["min_run"], inp["max_run"]+1): data_file = data_file_prefix + str(run).zfill(data_filename_length) + get_file_extension(inp["rename"]) data_dict = { "rb_number": str(inp["rbnum"]), "instrument": inp["inst_name"], "data": data_location + data_file, "run_number": str(int(run)), "facility": "ISIS" } activemq_client.send('/queue/DataReady', json.dumps(data_dict), priority=1) print data_dict