<jupyter_start><jupyter_text>Menu<jupyter_code>#export

import os
import datetime

from fastcore.script import * # @Callparser

from swfd.web_scraping import webScraping 
from swfd.download_model import downloadModel
from swfd.resources import getInfo
from swfd.manage_data import updatePredicts,doNewPredicts,infoDatesPredicts<jupyter_output><empty_output><jupyter_text>createFile(): Crea documento txt con el formato correcto.<jupyter_code>#export
def createFile():
    archi1=open("settings.txt","w") 
    archi1.write("user=''\n") 
    archi1.write("password=''\n") 
    archi1.write("csvdirectory=''\n")  
    archi1.write("pthdirectory=''\n")  
    archi1.close() 
createFile()<jupyter_output><empty_output><jupyter_text>changeTxtOption(): Actualiza la línea correspondiente del txt de información al valor que decida el usuario.<jupyter_code>#export
def changeTxtOption(line_num,option):
    
    with open("settings.txt", 'r') as txt:
        lines = txt.readlines()
        value=lines[line_num].split("'")[-2]
        
      
        if option != "password" and value!='':
            print("Current "+option+" value: "+value)    
        if option=="csvdirectory" or option=="pthdirectory": 
            print("It must starts and ends with / \nE.g: /home/user/desktop/folder1/csvfolder/ ")
            
        inputstring = str(input("Enter the value for "+option+" (write '0' to back): "))
        
        if(inputstring!="0"):
            print("prueba"+lines[line_num] +"\n")
            lines[line_num] = option+"='"+inputstring+"'\n"
            with open("settings.txt", 'w') as txt:
                txt.writelines(lines)
                print(option+" update")<jupyter_output><empty_output><jupyter_text>showTxtOptions():Funcion que muestra todos los parámetros excepto password<jupyter_code>#export
def showTxtOptions():
    try:
        with open("settings.txt", 'r') as txt:
            try:
                lines = txt.readlines()
                print("**********txt************\n")
                for line in lines:
                    option=line.split("=")[-2]
                    if(option != "password"):
                        print(line)
                print("\n*************************\n")
            finally:
                txt.close()
    except IOError:
        print("File not accessible")   

showTxtOptions()<jupyter_output>**********txt************

user=''

csvdirectory=''

pthdirectory=''


*************************<jupyter_text>chooseOption(): Pide al usuario un numero y lo devuelve.<jupyter_code>#export
def chooseOption():
    isnumber=False
    while(not isnumber):
        try:
            option = int(input("Enter the number of the option: "))
            isnumber=True
        except ValueError:
            print('Error, Need a correct option')
     
    return option<jupyter_output><empty_output><jupyter_text>showmenu(): Muestra el menu principal y hace las opciones correspondientes para cada opcion.<jupyter_code>#export
def showmenu():
    os.system ("clear") 
    exit=False
    while not exit:
        
        print("\n*******\n1-Download sfu data\n2-Download model\n3-Prediction settings\n4-Txt settings\n5-Exit\n*******\n")
        option=chooseOption()
        if option == 1:
            webScraping()
        elif option == 2:
            downloadModel()
        elif option == 3:
            showPredictionsMenu()
        elif option == 4:
            showTxtMenu()
        elif option == 5:
            exit = True
        else:
            print ("\n\nOption has to be between 1 and 5")<jupyter_output><empty_output><jupyter_text>showPredictionsMenu(): Muestra el menu de prediciones y hace las opciones correspondientes para cada opcion.<jupyter_code>#export
def showPredictionsMenu():
    if os.path.isdir(getInfo("csvdirectory")):
        os.system ("clear") 
        if(not os.path.isfile(getInfo("csvdirectory")+"predictionData.csv")):
            print("\npredictionData.csv not found, It will create and make new prediction\n")
            doNewPredicts(1)
        
        exit=False
        while not exit:
            print("\n*******\n1-Update predictions until today\n2-Extend past predictions\n3-back\n*******\n")
            startdate,enddate=infoDatesPredicts()
            if(startdate!=None and enddate!=None):
                print("\n\nFirst date loaded is: ",startdate.strftime("%Y-%m-%d"),"\nLast date loaded is: ",enddate.strftime("%Y-%m-%d"))
                option=chooseOption()
            else:
                print("You must predict first to use the file")
                option=2

            if option == 1:
                updatePredicts()
            elif option == 2:
                isnumber=False
                while(not isnumber):
                    try:
                        days = int(input("Enter the number of days to predict from {}: ".format(enddate)))
                        isnumber=True
                    except ValueError:
                        print('Error, Need a correct option')
                doNewPredicts(days)
            elif option == 3:
                exit = True
            else:
                print ("\n\nOption has to be between 1 and 3")
    else:
        print("\nPath to csv folder not found\n")<jupyter_output><empty_output><jupyter_text>showTxtMenu(): Muestra el menu del documento de texto y hace las opciones correspondientes para cada opcion.<jupyter_code>#export
def showTxtMenu():
    os.system ("clear") 
    exit=False
    while not exit:
        print("\n*******\n1-Change ESA user\n2-Change ESA password\n3-Change csv directory\n4-Change pth directory\n5-Show txt\n6-Back\n*******\n")
        option=chooseOption()
        if option == 1:
            changeTxtOption(0,"user")
        elif option == 2:
            changeTxtOption(1,"password")
        elif option == 3:
            changeTxtOption(2,"csvdirectory")
        elif option == 4:
            changeTxtOption(3,"pthdirectory")
        elif option == 5:
            showTxtOptions()
        elif option == 6:
            exit = True
        else:
            print ("\n\nOption has to be between 1 and 6")
#export
@call_parse
def main():
    if not os.path.isfile("settings.txt"):
        createFile()
    showmenu()
#main()<jupyter_output>*******
1-Download sfu data
2-Download model
3-Prediction settings
4-Txt settings
5-Exit
*******

Enter the number of the option: 2
[Errno 2] No such file or directory: 'ensembleH3.txt'
[Errno 2] No such file or directory: 'ensembleH5H7.txt'
[Errno 2] No such file or directory: 'ensembleH10H14.txt'
[Errno 2] No such file or directory: 'ensembleH21H27.txt'

*******
1-Download sfu data
2-Download model
3-Prediction settings
4-Txt settings
5-Exit
*******

Enter the number of the option: 2
[Errno 2] No such file or directory: 'ensembleH3.txt'
[Errno 2] No such file or directory: 'ensembleH5H7.txt'
[Errno 2] No such file or directory: 'ensembleH10H14.txt'
[Errno 2] No such file or directory: 'ensembleH21H27.txt'

*******
1-Download sfu data
2-Download model
3-Prediction settings
4-Txt settings
5-Exit
*******

Enter the number of the option: 2
Collecting runs on ensembleH3.txt
[Errno 2] No such file or directory: '../test/pth/ensembleH5H7.txt'
[Errno 2] No such file or directory: '../test/p[...]
{'fraction_non_alphanumeric': 0.1350013747594171, 'fraction_numerical': 0.014297497937860875, 'mean_word_length': 2.5367039377734564, 'pattern_counts': {'":': 1, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '233433', 'license': 'Apache-2.0', 'n_tokens_mistral': 2270, 'n_tokens_neox': 2203, 'n_words': 570, 'path': 'nbs/05_menu.ipynb', 'repo_name': 'Miguel-Antonm/deploy_DL_space_weather_forecast', 'size': '7274'}