diff --git a/aplikacija.ipynb b/aplikacija.ipynb index 21e2f0b..a15c5da 100644 --- a/aplikacija.ipynb +++ b/aplikacija.ipynb @@ -55,9 +55,14 @@ "# populira dropdown z najdenimi ključi za iskan niz\n", "def najdi_telo(t):\n", " ime_telesa = str(text_ime_telesa.value).capitalize()\n", + " najdeno = horizon_api.search_body(ime_telesa.strip())\n", " \n", - " if ime_telesa in slovar_teles.keys(): najdeno = {ime_telesa: slovar_teles[ime_telesa]}\n", - " else: najdeno = horizon_api.search_body(ime_telesa.strip())\n", + " # obravnavajmo primer, ko je najden le en rezultat pri iskanju niza\n", + " if najdeno and \"_single_\" in najdeno:\n", + " for ime, id_telesa in slovar_teles.items():\n", + " if id_telesa.strip() == najdeno[\"_single_\"].strip():\n", + " najdeno = {ime: id_telesa}\n", + " break\n", " \n", " out.clear_output(); dropdown_izbira.value=None; dropdown_izbira.options = []\n", " if not najdeno: \n", @@ -297,9 +302,9 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "simulacija_teles_venv", "language": "python", - "name": "python3" + "name": "simulacija_teles_venv" }, "language_info": { "codemirror_mode": { diff --git a/horizon_api.py b/horizon_api.py index d2baa9a..df76fcc 100644 --- a/horizon_api.py +++ b/horizon_api.py @@ -12,10 +12,12 @@ def create_query(parameter_map: dict): # funkcije vrne slovar teles ki se ujemajo search query-u in njihovih indeksov, če ni rezultatov ali pride do napake vrne None def search_body(search_query="MB"): try: - result = requests.get(create_query({"COMMAND":search_query})) + result = requests.get(create_query({"COMMAND":search_query}), timeout=5) lines = result.content.decode().splitlines()[:-2] widths_line = list(map(len, lines[7].split())) + if "Multiple" not in lines[4] and "Matching" not in lines[-1]: return {"_single_": lines[4].split()[-1].strip()} + parsed_body_map = {} for i in range(8, len(lines)): body_name = lines[i][widths_line[0]+4:widths_line[0]+4+widths_line[1]].strip() @@ -59,7 +61,7 @@ def extract_first_num(line): "CENTER": "500@0", "TLIST": f"%27{time}%27", "CSV_FORMAT": "YES" - })) + }), timeout=5) lines = result.content.decode().splitlines() # če mogoče najdemo vrstici ki vsebujejo maso in polmer @@ -95,6 +97,7 @@ def extract_first_num(line): # masa je GM/G kjer je G gravitacijska konstanta result_json = { "name": name, + "time": time, "mass": GM/6.6743015, "radius": radius, "x_vec": x_vec, diff --git a/requirements.txt b/requirements.txt index 6445fbd..ab8e4f6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,53 +1,101 @@ +anyio==3.7.1 +argon2-cffi==21.3.0 +argon2-cffi-bindings==21.2.0 asttokens==2.2.1 +attrs==23.1.0 backcall==0.2.0 +beautifulsoup4==4.12.2 +bleach==6.0.0 certifi==2023.5.7 +cffi==1.15.1 charset-normalizer==3.2.0 comm==0.1.3 contourpy==1.1.0 cycler==0.11.0 debugpy==1.6.7 decorator==5.1.1 +defusedxml==0.7.1 +entrypoints==0.4 +exceptiongroup==1.1.2 executing==1.2.0 +fastjsonschema==2.17.1 fonttools==4.40.0 idna==3.4 importlib-metadata==6.8.0 importlib-resources==6.0.0 ipykernel==6.24.0 ipython==8.12.2 +ipython-genutils==0.2.0 ipywidgets==8.0.7 jedi==0.18.2 -jupyter-client==8.3.0 +Jinja2==3.1.2 +jsonschema==4.18.0 +jsonschema-specifications==2023.6.1 +jupyter==1.0.0 +jupyter-client==7.4.9 +jupyter-console==6.6.3 jupyter-core==5.3.1 +jupyter-events==0.6.3 +jupyter-server==2.7.0 +jupyter-server-terminals==0.4.4 +jupyterlab-pygments==0.2.2 jupyterlab-widgets==3.0.8 kiwisolver==1.4.4 +MarkupSafe==2.1.3 matplotlib==3.7.2 matplotlib-inline==0.1.6 +mistune==3.0.1 +nbclassic==1.0.0 +nbclient==0.8.0 +nbconvert==7.6.0 +nbformat==5.9.1 nest-asyncio==1.5.6 +notebook==6.5.4 +notebook-shim==0.2.3 numpy==1.24.4 +overrides==7.3.1 packaging==23.1 +pandocfilters==1.5.0 parso==0.8.3 pexpect==4.8.0 pickleshare==0.7.5 Pillow==10.0.0 +pkgutil-resolve-name==1.3.10 platformdirs==3.8.1 plotly==5.15.0 +prometheus-client==0.17.0 prompt-toolkit==3.0.39 psutil==5.9.5 ptyprocess==0.7.0 pure-eval==0.2.2 +pycparser==2.21 Pygments==2.15.1 pyparsing==3.0.9 python-dateutil==2.8.2 +python-json-logger==2.0.7 +PyYAML==6.0 pyzmq==25.1.0 +qtconsole==5.4.3 +QtPy==2.3.1 +referencing==0.29.1 requests==2.31.0 +rfc3339-validator==0.1.4 +rfc3986-validator==0.1.1 +rpds-py==0.8.10 +Send2Trash==1.8.2 six==1.16.0 +sniffio==1.3.0 +soupsieve==2.4.1 stack-data==0.6.2 tenacity==8.2.2 +terminado==0.17.1 +tinycss2==1.2.1 tornado==6.3.2 traitlets==5.9.0 typing-extensions==4.7.1 urllib3==2.0.3 wcwidth==0.2.6 +webencodings==0.5.1 +websocket-client==1.6.1 widgetsnbextension==4.0.8 zipp==3.16.0 -nbformat==5.9.0 \ No newline at end of file