def launch(self): subprocess.run(["clear"]) print_heading(self.menu_heading, fg="bright_yellow") if not node_is_installed(): print_message(INSTALL_ERROR, fg="bright_red", bold=True) pause(message="Press any key to continue...") return if not NODEJS_INBOX.exists(): NODEJS_INBOX.mkdir(parents=True, exist_ok=True) if node_modules_folder_exists(): message = UPDATE_MESSAGE prompt = UPDATE_PROMPT temp_folder = None command = "npm update --timeout=9999999" else: message = INSTALL_MESSAGE prompt = INSTALL_PROMPT temp_folder = TemporaryDirectory(dir=NIGHTMAREJS_FOLDER) command = f"npm install --timeout=9999999 --cache={temp_folder.name}" print_message(message, fg="bright_yellow") if not yes_no_prompt(prompt, wrap=False): return Result.Ok(self.exit_menu) subprocess.run(["clear"]) print_heading(self.menu_heading, fg="bright_yellow") result = run_command(command, cwd=str(NIGHTMAREJS_FOLDER)) if result.failure: return result if temp_folder: temp_folder.cleanup() pause(message="\nPress any key to continue...") return Result.Ok(self.exit_menu)
def launch(self): subprocess.run(["clear"]) print_message(f"Variable Name: {self.setting_name}\n", fg="bright_magenta", bold=True) print_message(f"Current Value: {self.current_setting}\n", fg="bright_yellow", bold=True) if not yes_no_prompt(prompt="\nChange current setting?"): return Result.Ok(self.exit_menu) user_confirmed, new_value = False, None while not user_confirmed: subprocess.run(["clear"]) prompt = f"Enter a new value for {self.setting_name}:\n" new_value = Input( prompt, word_color=colors.foreground["default"]).launch() result = self.confirm_new_value(new_value) if result.failure: return Result.Ok(self.exit_menu) user_confirmed = result.value result = self.dotenv.change_value(self.setting_name, new_value) if not self.restart_required: return result print_message(RESTART_WARNING, fg="bright_magenta", bold=True) pause(message="Press any key to continue...") exit(0)
def launch(self): job_confirmed = False data_sets = [] start = None end = None job_name = None prompt = "Select all data sets to scrape:" while not job_confirmed: heading = self.get_menu_heading("Select Data Sets") data_sets = data_sets_prompt(heading, prompt, checked_data_sets=data_sets) dates_validated = False while not dates_validated: start = self.prompt_user_scrape_start_date(start) end = self.prompt_user_scrape_stop_date(end) result = validate_scrape_dates(self.db_session, start, end) if result.failure: continue dates_validated = True job_name = self.prompt_user_job_name(job_name) job_confirmed = self.confirm_job_details(data_sets, start, end, job_name) new_job = self.app.create_scrape_job(data_sets, start, end, job_name).value subprocess.run(["clear"]) if yes_no_prompt( prompt="\nWould you like to begin executing this job?"): job_runner = JobRunner(app=self.app, db_job=new_job) result = job_runner.execute() if result.failure: return result return Result.Ok(self.exit_menu)
def prompt_user_apply_patch_list(self): subprocess.run(["clear"]) prompt = "Would you like to apply the patch to fix the invalid data?" self.update_menu_heading("Apply Patch?", heading_color="bright_cyan") print_message( f"A patch list for {self.game_id} was successfully created!\n", fg="bright_cyan") return yes_no_prompt(prompt)
def prompt_user_view_patched_data(self): subprocess.run(["clear"]) prompt = "Would you like to see a report detailing the changes that were made by applying the patch list?" self.update_menu_heading("View Patch Results?", heading_color="bright_cyan") print_message( "The patch was successfully applied to the PitchFX data!\n", fg="bright_cyan") return yes_no_prompt(prompt)
def launch(self): subprocess.run(["clear"]) setting_heading = f"Setting: {self.setting_name_title} (Type: {self.data_type.name})" print_heading(setting_heading, fg="bright_magenta") self.print_description() print_message(self.current_settings, wrap=False, fg="bright_yellow", bold=True) if yes_no_prompt("\nChange current setting?"): change_setting_menu = ChangeConfigSettting(self.app, self.setting_name) return change_setting_menu.launch() return Result.Ok(self.exit_menu)
def confirm_job_details(self, data_sets, start_date, end_date, job_name): subprocess.run(["clear"]) heading = "Confirm job details" data_set_space = "\n\t " confirm_job_name = "" if job_name: confirm_job_name = f"Job Name....: {job_name}\n" job_details = ( f"{confirm_job_name}" f"Start date..: {start_date.strftime(DATE_ONLY_2)}\n" f"End Date....: {end_date.strftime(DATE_ONLY_2)}\n" f"Data Sets...: {data_set_space.join([DATA_SET_TO_NAME_MAP[ds] for ds in data_sets])}" ) print_heading(heading, fg="bright_yellow") print_message(job_details, wrap=False, fg="bright_yellow") return yes_no_prompt(prompt="\nAre the details above correct?")
def prompt_user_investigate_failures(self): prompt = ( "\nWould you like to analyze these results? In many cases, the batter/pitcher ID is " "incorrect and can be easily fixed by applying a patch file.") return yes_no_prompt(prompt)