arg_parser.add_argument('-c', '--config', nargs=1, metavar='CONFIG_PATH', type=str, \ help="Path to a config file which will be used instead of the default one.") # Parse the command line arguments cml_args = arg_parser.parse_args() ######################### # Load the config file config = cr.loadConfigFromDirectory(cml_args.config, cml_args.dir_path) ### Init the logger from RMS.Logger import initLogging initLogging(config, 'detection_') log = logging.getLogger("logger") ###### # Run detection on the folder _, _, _, detector = detectStarsAndMeteorsDirectory(cml_args.dir_path[0], config) # Delete backup files detector.deleteBackupFiles() print('Total time taken: ', datetime.datetime.utcnow() - time_start)
help="""Detect stars and meteors at the end of the night, after capture finishes. """) arg_parser.add_argument('-r', '--resume', action="store_true", \ help="""Resume capture into the last night directory in CapturedFiles. """) # Parse the command line arguments cml_args = arg_parser.parse_args() ###### # Load the config file config = cr.loadConfigFromDirectory(cml_args.config, os.path.abspath('.')) # Initialize the logger initLogging(config) # Get the logger handle log = logging.getLogger("logger") log.info("Program start") log.info("Station code: {:s}".format(str(config.stationID))) # Change the Ctrl+C action to the special handle setSIGINT() # Make the data directories root_dir = os.path.abspath(config.data_dir) mkdirP(root_dir) mkdirP(os.path.join(root_dir, config.captured_dir)) mkdirP(os.path.join(root_dir, config.archived_dir))
self.upload_queue_file = 'FILES_TO_UPLOAD.inf' self.data_dir = os.path.join(os.path.expanduser('~'), 'RMS_data') self.log_dir = 'logs' config = FakeConf() dir_local='/home/dvida/Desktop' #uploadSFTP(config.hostname, config.stationID, dir_local, dir_remote, file_list, rsa_private_key=config.rsa_private_key) # Init the logger initLogging(config) up = UploadManager(config) up.start() time.sleep(2) #up.addFiles([os.path.join(dir_local, 'test.txt')]) time.sleep(1) #up.addFiles([os.path.join(dir_local, 'test2.txt')]) #up.addFiles([os.path.join(dir_local, 'test3.txt')]) up.stop()
config = RMS.ConfigReader.loadConfigFromDirectory(None, "~/source/RMS/.config") print( "Running FlushNMqueue.py, 08-Aug, 2021, byte count 1452: flushing the NM upload queue..." ) # Create the config object for New Mexico Meteor Array purposes nm_config = copy.copy(config) nm_config.stationID = 'pi' nm_config.hostname = '10.8.0.61' nm_config.remote_dir = '/home/pi/RMS_Station_data' nm_config.upload_queue_file = 'NM_FILES_TO_UPLOAD.inf' initLogging(config, "NM_UPLOAD_") # Get the logger handle. log = logging.getLogger("logger.FlushNMqueue") # Upload files to the NM Server # create the upload manager for the local files upload_manager = UploadManager(nm_config) upload_manager.start() # Begin the upload! upload_manager.uploadData() upload_manager.stop() log.info("FlushNMqueue has finished!")
def rmsExternal(captured_night_dir, archived_night_dir, config): initLogging(config, 'iStream_') log = logging.getLogger("logger") log.info('iStream external script started') # create lock file to avoid RMS rebooting the system lockfile = os.path.join(config.data_dir, config.reboot_lock_file) with open(lockfile, 'w') as _: pass # Compute the capture duration from now start_time, duration = captureDuration(config.latitude, config.longitude, config.elevation) timenow = datetime.datetime.utcnow() remaining_seconds = 0 # Compute how long to wait before capture if start_time != True: waitingtime = start_time - timenow remaining_seconds = int(waitingtime.total_seconds()) # Run the Istrastream shell script script_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "iStream.sh") log.info('Calling {}'.format(script_path)) command = [ script_path, config.stationID, captured_night_dir, archived_night_dir, '{:.6f}'.format(config.latitude), '{:.6f}'.format(config.longitude), '{:.1f}'.format(config.elevation), str(config.width), str(config.height), str(remaining_seconds) ] proc = subprocess.Popen(command,stdout=subprocess.PIPE) # Read iStream script output and append to log file while True: line = proc.stdout.readline() if not line: break log.info(line.rstrip().decode("utf-8")) exit_code = proc.wait() log.info('Exit status: {}'.format(exit_code)) log.info('iStream external script finished') # relase lock file so RMS is authorized to reboot, if needed os.remove(lockfile) # Reboot the computer (script needs sudo priviledges, works only on Linux) try: log.info("Rebooting system...") os.system('sudo shutdown -r now') except Exception as e: log.debug('Rebooting failed with message:\n' + repr(e)) log.debug(repr(traceback.format_exception(*sys.exc_info())))
arg_parser.add_argument('-c', '--config', nargs=1, metavar='CONFIG_PATH', type=str, \ help="Path to a config file which will be used instead of the default one.") # Parse the command line arguments cml_args = arg_parser.parse_args() ######################### # Load the config file config = cr.loadConfigFromDirectory(cml_args.config, cml_args.dir_path) ### Init the logger from RMS.Logger import initLogging initLogging(config, 'reprocess_') log = logging.getLogger("logger") ###### # Process the night _, archive_name, detector = processNight(cml_args.dir_path[0], config) # Upload the archive, if upload is enabled if config.upload_enabled: # Init the upload manager print('Starting the upload manager...')