async def get_all_backups(): ret = Backup().getAll() if (len(ret) == 0): raise HTTPException(status_code=404, detail="no backups found") else: return parseJson(ret)
async def get_job(id: str): job = Job(id) if (job.exists() == False): raise HTTPException(status_code=404, detail="job not found") else: return parseJson(job)
async def apply_for_job(id: str): ret = Job(id).apply() if (ret == False): raise HTTPException(status_code=404, detail="job not found or already claimed") else: return parseJson(ret)
async def get_all_tasks(): ret = Task().getAll() if (len(ret) == 0): raise HTTPException(status_code=404, detail="no tasks found") else: return parseJson(ret)
async def check_host_connection(id: str): host = Host(id) if ( host.Connect() == False ): raise HTTPException(status_code=422, detail="host connection not possible") else: return parseJson(host)
async def get_all_credentials(): ret = Credential().getAll() if (len(ret) == 0): raise HTTPException(status_code=404, detail="no credentials found") else: return parseJson(ret)
async def get_all_secrets(): ret = Secret().getAll() if (len(ret) == 0): raise HTTPException(status_code=404, detail="no secrets found") else: return parseJson(ret)
async def update_job(id: str, item: Struct): job = Job(id) if not job: raise HTTPException(status_code=404, detail="job not found") if not job.update(item): raise HTTPException(status_code=422, detail="error update Job") return parseJson(job)
async def create_task(data: Struct): if (Task(name=data.name).exists()): raise HTTPException(status_code=422, detail="task already exist") ret = Task(data=data) if ret: return parseJson(ret) else: raise HTTPException(status_code=422, detail="can't create task")
async def update_secret(id: str, item: Struct): secret = Secret(id) if not secret.exists(): raise HTTPException(status_code=404, detail="secret not found") if not secret.update(item): raise HTTPException(status_code=422, detail="error update secret") return parseJson(secret)
async def update_host(id: str, item: Struct): host = Host(id) if not host.exists(): raise HTTPException(status_code=404, detail="host not found") if not host.update(item): raise HTTPException(status_code=422, detail="error update host") return parseJson(host)
async def update_task(id: str, item: Struct): task = Task(id) if not task.exists(): raise HTTPException(status_code=404, detail="task not found") if not task.update(item): raise HTTPException(status_code=422, detail="error update task") return parseJson(task)
async def update_credential(id: str, item: Struct): credential = Credential(id) if not credential.exists(): raise HTTPException(status_code=404, detail="credential not found") if not credential.update(item): raise HTTPException(status_code=422, detail="error update credential") return parseJson(credential)
async def delete_credential(id: str): ret = Credential(id).delete() if (ret == False): raise HTTPException(status_code=404, detail="credential not found") else: return parseJson(ret)
async def search_for_tasks(filter: Struct): ret = Task().getAll(filter=shrinkJson(filter)) return parseJson(ret)
async def get_all_jobs(): jobs = Job().getAll() if (len(jobs) == 0): raise HTTPException(status_code=404, detail="no jobs found") else: return parseJson(jobs)
async def get_target(id: str): ret = Target(id) if ( ret == False ): raise HTTPException(status_code=404, detail="target not found") else: return parseJson(ret)
async def search_for_backups(filter: Struct): ret = Backup().getAll(filter=shrinkJson(filter)) return parseJson(ret)
async def get_backup(id: str): ret = Backup(id) if (ret.exists() == False): raise HTTPException(status_code=404, detail="backup not found") else: return parseJson(ret)
async def request_job(): jobs = Job().request() if (jobs == False): raise HTTPException(status_code=404, detail="no jobs available") else: return parseJson(jobs)
async def search_for_dumps(filter: Struct): ret = Dump().getAll(filter=shrinkJson(filter)) return parseJson(ret)
async def search_for_secrets(filter: Struct): ret = Secret().getAll(filter=shrinkJson(filter)) return parseJson(ret)
async def search_for_credentials(filter: Struct): ret = Credential().getAll(filter=shrinkJson(filter)) return parseJson(ret)
async def delete_task(id: str): ret = Task(id).delete() if (ret == False): raise HTTPException(status_code=404, detail="task not found") else: return parseJson(ret)
def subMenu(): JsonFile = parser.getJsonFile() TEAMS_TOTAL, TEAMS_1ST_HALF, TEAMS_2ND_HALF, PLAYERS_HOME, PLAYERS_AWAY, EVENTS = parser.parseJson(JsonFile) choice = '0' while choice == '0': # Simple Menu try: print("-------- SUBMENU ---------") print("1.- Show total info of teams") print("2.- Show first half of teams") print("3.- Show second half of teams") print("4.- Show HOME team players stats") print("5.- Show AWAY team players stats") print("6.- Show total info of every player in the game") print("7.- Show events") print("8.- Export JSON to .CSV") print("9.- Exit Submenu") print("") choice = input("So what is it gonna be? ") if choice == '1': #Show total info of teams parser.printTable(TEAMS_TOTAL) elif choice == '2': #Show first half of teams parser.printTable(TEAMS_1ST_HALF) elif choice == '3': #Show second half of teams parser.printTable(TEAMS_2ND_HALF) elif choice == '4': #Show HOME team players stats parser.printTable(PLAYERS_HOME) elif choice == '5': #Show AWAY team players stats parser.printTable(PLAYERS_AWAY) elif choice == '6': #Show total info of every player in the game parser.printTable(PLAYERS_HOME,PLAYERS_AWAY) elif choice == '7': #Show events parser.printEvents(EVENTS) elif choice == '8': #Export to CSV ExportSubmenu(JsonFile,TEAMS_TOTAL, TEAMS_1ST_HALF, TEAMS_2ND_HALF, PLAYERS_HOME, PLAYERS_AWAY, EVENTS) elif choice == '9': #Exits submenu break else: print("Sorry I didn't get what you wanted to do?") choice = '0' #Only way of exiting this loop is manually except EOFError: pass