def main(): logging.getLogger().setLevel(logging.NOTSET) l = logging.getLogger(__name__) irods_logging.register_tty_handler(sys.stderr, logging.WARNING, None) irods_logging.register_file_handler(get_log_path()) if (os.geteuid() == 0): l.error('irodsctl should not be run by the root user.') l.error('Exiting...') return 1 operations_dict = {} operations_dict['start'] = lambda: irods_controller.start( execution_environment=execution_environment) operations_dict['graceful_start'] = lambda: irods_controller.start( execution_environment=execution_environment) operations_dict['stop'] = lambda: irods_controller.stop() operations_dict['restart'] = lambda: irods_controller.restart( execution_environment=execution_environment) operations_dict['graceful_restart'] = lambda: irods_controller.restart( execution_environment=execution_environment) operations_dict['status'] = lambda: irods_controller.status() (options, arguments) = parse_options() if len(arguments) != 1: l.error('irodsctl accepts exactly one positional argument, ' 'but {0} were provided.'.format(len(arguments))) l.error('Exiting...') return 1 operation = arguments[0] if operation not in operations_dict: l.error('irodsctl accepts the following positional arguments:') l.error(indent(*operations_dict.keys())) l.error('but \'%s\' was provided.', operation) l.error('Exiting...') return 1 if options.verbose: irods_logging.register_tty_handler(sys.stdout, logging.INFO, logging.WARNING) try: irods_controller = IrodsController( top_level_directory=options.top_level_directory, config_directory=options.config_directory) except IrodsControllerError: l.error('Error encountered creating IrodsController.', exc_info=True) l.error('Exiting...') return 1 execution_environment = {} if options.server_log_level != None: execution_environment['spLogLevel'] = options.server_log_level if options.sql_log_level != None: execution_environment['spLogSql'] = options.sql_log_level if options.days_per_log != None: execution_environment['logfileInt'] = options.days_per_log if options.rule_engine_server_options != None: execution_environment[ 'reServerOption'] = options.rule_engine_server_options if options.server_reconnect_flag: execution_environment['irodsReconnect'] = '' try: operations_dict[operation]() except IrodsControllerError: l.error('Error encountered running %s on irods_control.', operation, exc_info=True) l.error('Exiting...') return 1 return 0
except AttributeError: # requests pre-v1.0.0 response.encoding = 'utf8' schema = json.loads(response.content) return schema def get_initial_schema_from_file(schema_uri): with open(schema_uri[7:]) as f: schema = json.load(f) return schema if __name__ == '__main__': logging.getLogger().setLevel(logging.NOTSET) l = logging.getLogger(__name__) irods_logging.register_tty_handler(sys.stdout, logging.INFO, logging.WARNING) irods_logging.register_tty_handler(sys.stderr, logging.WARNING, None) if len(sys.argv) != 3: l.error('Usage: %s <configuration_file> <schema_url>', sys.argv[0]) sys.exit(1) config_file = sys.argv[1] schema_uri = sys.argv[2] try: load_and_validate(config_file, schema_uri) except ValidationError as e: l.error('Encounterd an error in validation.', exc_info=True) sys.exit(1) except ValidationWarning as e: l.warning('Encountered a warning in validation.', exc_info=True)
def main(): logging.getLogger().setLevel(logging.NOTSET) l = logging.getLogger(__name__) irods_logging.register_tty_handler(sys.stderr, logging.WARNING, None) irods_logging.register_file_handler(get_log_path()) if (os.geteuid() == 0): l.error('irodsctl should not be run by the root user.') l.error('Exiting...') return 1 operations_dict = {} operations_dict['start'] = lambda: irods_controller.start( execution_environment=execution_environment) operations_dict['graceful_start'] = lambda: irods_controller.start( execution_environment=execution_environment) operations_dict['stop'] = lambda: irods_controller.stop() operations_dict['restart'] = lambda: irods_controller.restart( execution_environment=execution_environment) operations_dict['graceful_restart'] = lambda: irods_controller.restart( execution_environment=execution_environment) operations_dict['status'] = lambda: irods_controller.status() (options, arguments) = parse_options() if len(arguments) != 1: l.error( 'irodsctl accepts exactly one positional argument, ' 'but {0} were provided.'.format(len(arguments))) l.error('Exiting...') return 1 operation = arguments[0] if operation not in operations_dict: l.error('irodsctl accepts the following positional arguments:') l.error(indent(*operations_dict.keys())) l.error('but \'%s\' was provided.', operation) l.error('Exiting...') return 1 if options.verbose: irods_logging.register_tty_handler(sys.stdout, logging.INFO, logging.WARNING) try: irods_controller = IrodsController( top_level_directory=options.top_level_directory, config_directory=options.config_directory) except IrodsControllerError: l.error('Error encountered creating IrodsController.', exc_info=True) l.error('Exiting...') return 1 execution_environment = {} if options.server_log_level != None: execution_environment['spLogLevel'] = options.server_log_level if options.sql_log_level != None: execution_environment['spLogSql'] = options.sql_log_level if options.days_per_log != None: execution_environment['logfileInt'] = options.days_per_log if options.rule_engine_server_options != None: execution_environment['reServerOption'] = options.rule_engine_server_options if options.server_reconnect_flag: execution_environment['irodsReconnect'] = '' try: operations_dict[operation]() except IrodsControllerError: l.error('Error encountered running %s on irods_control.', operation, exc_info=True) l.error('Exiting...') return 1 return 0