def get_wrapper(args) -> DbWrapperBase: if args.db_method == "rm": return RmWrapper(args) elif args.db_method == "monocle": return MonocleWrapper(args) else: logger.error("Invalid db_method in config. Exiting") sys.exit(1)
See http://stackoverflow.com/a/39501288/1709587 for explanation. """ if platform.system() == 'Windows': return os.path.getctime(path_to_file) else: stat = os.stat(path_to_file) try: return stat.st_birthtime except AttributeError: # We're probably on Linux. No easy way to get creation dates here, # so we'll settle for when its content was last modified. return stat.st_mtime if __name__ == "__main__": from utils.walkerArgs import parseArgs from db.monocleWrapper import MonocleWrapper from db.rmWrapper import RmWrapper args = parseArgs() if args.db_method == "rm": db_wrapper = RmWrapper(args, None) elif args.db_method == "monocle": db_wrapper = MonocleWrapper(args, None) else: log.error("Invalid db_method in config. Exiting") sys.exit(1) app.run()
def load_mappings(db_wrapper): mapping_parser = MappingParser(db_wrapper) device_mappings = mapping_parser.get_devicemappings() routemanagers = mapping_parser.get_routemanagers() auths = mapping_parser.get_auths() return (device_mappings, routemanagers, auths) if __name__ == "__main__": # TODO: globally destroy all threads upon sys.exit() for example set_log_and_verbosity(log) webhook_helper = WebhookHelper(args) if args.db_method == "rm": db_wrapper = RmWrapper(args, webhook_helper) elif args.db_method == "monocle": db_wrapper = MonocleWrapper(args, webhook_helper) else: log.error("Invalid db_method in config. Exiting") sys.exit(1) db_wrapper.create_hash_database_if_not_exists() db_wrapper.check_and_create_spawn_tables() db_wrapper.create_quest_database_if_not_exists() db_wrapper.create_status_database_if_not_exists() webhook_helper.set_gyminfo(db_wrapper) version = MADVersion(args, db_wrapper) version.get_version() if not db_wrapper.ensure_last_updated_column(): log.fatal("Missing raids.last_updated column and couldn't create it")
if __name__ == "__main__": logger.info('Start MAD configmode - pls wait') filename = os.path.join('configs', 'config.ini') if not os.path.exists(filename): logger.error( 'Config.ini not found - check configs folder and copy .example') sys.exit(1) filename = os.path.join('configs', 'mappings.json') if not os.path.exists(filename): generate_mappingjson() if args.db_method == "rm": db_wrapper = RmWrapper(args) elif args.db_method == "monocle": db_wrapper = MonocleWrapper(args) else: logger.error("Invalid db_method in config. Exiting") sys.exit(1) db_wrapper.create_hash_database_if_not_exists() db_wrapper.check_and_create_spawn_tables() db_wrapper.create_quest_database_if_not_exists() db_wrapper.create_status_database_if_not_exists() db_wrapper.create_usage_database_if_not_exists() version = MADVersion(args, db_wrapper) version.get_version() try:
request, send_from_directory) from flask_caching import Cache from utils.questGen import generate_quest from utils.walkerArgs import parseArgs sys.path.append("..") # Adds higher directory to python modules path. app = Flask(__name__) cache = Cache(app, config={'CACHE_TYPE': 'simple'}) log = logging.getLogger(__name__) conf_args = parseArgs() if conf_args.db_method == "rm": db_wrapper = RmWrapper(conf_args, None) elif conf_args.db_method == "monocle": db_wrapper = MonocleWrapper(conf_args, None) else: log.error("Invalid db_method in config. Exiting") sys.exit(1) def auth_required(func): @wraps(func) def decorated(*args, **kwargs): username = getattr(conf_args, 'madmin_user', '') password = getattr(conf_args, 'madmin_password', '') if not username: return func(*args, **kwargs) if request.authorization:
if __name__ == "__main__": filename = os.path.join('configs', 'config.ini') if not os.path.exists(filename): print('Config.ini not found - check configs folder and copy .example') sys.exit(1) filename = os.path.join('configs', 'mappings.json') if not os.path.exists(filename): generate_mappingjson() webhook_helper = None if args.db_method == "rm": db_wrapper = RmWrapper(args, webhook_helper) elif args.db_method == "monocle": db_wrapper = MonocleWrapper(args, webhook_helper) else: log.error("Invalid db_method in config. Exiting") sys.exit(1) print( 'Starting MADmin with Port {} - open browser and click "Mapping Editor"' .format(int(args.madmin_port))) t_flask = Thread(name='madmin', target=start_madmin, args=( args, db_wrapper, ))
from db.monocleWrapper import MonocleWrapper from db.rmWrapper import RmWrapper from utils.walkerArgs import parseArgs args = parseArgs() if args.db_method == "rm": db_wrapper = RmWrapper(args) elif args.db_method == "monocle": db_wrapper = MonocleWrapper(args) else: print("Invalid db_method in config. Exiting") exit(1) def main(): if db_wrapper.download_gym_images(): print("Successfully downloaded gym images to ocr/gym_img") else: print("Failed downloading gym images") if __name__ == '__main__': main()
mapping_parser = MappingParser(db_wrapper) device_mappings = mapping_parser.get_devicemappings() routemanagers = mapping_parser.get_routemanagers() auths = mapping_parser.get_auths() return (device_mappings, routemanagers, auths) if __name__ == "__main__": # TODO: globally destroy all threads upon sys.exit() for example set_log_and_verbosity(log) install_thread_excepthook() webhook_helper = WebhookHelper(args) if args.db_method == "rm": db_wrapper = RmWrapper(args, webhook_helper) elif args.db_method == "monocle": db_wrapper = MonocleWrapper(args, webhook_helper) else: log.error("Invalid db_method in config. Exiting") sys.exit(1) webhook_helper.set_db_wrapper(db_wrapper) db_wrapper.create_hash_database_if_not_exists() db_wrapper.check_and_create_spawn_tables() db_wrapper.create_quest_database_if_not_exists() db_wrapper.create_status_database_if_not_exists() db_wrapper.create_usage_database_if_not_exists() version = MADVersion(args, db_wrapper) version.get_version() if args.clean_hash_database: