parent
e206c89868
commit
f62aec2cda
38 changed files with 9937 additions and 1350 deletions
@ -0,0 +1,127 @@ |
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "2bec1b04-f1ab-4165-a4ea-cc890cc9e5ec", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"!python -m pip install gql" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "dca88210-18db-45ee-9949-7010b92dbae7", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"import json\n", |
||||
"import os\n", |
||||
"import pprint\n", |
||||
"\n", |
||||
"import requests\n", |
||||
"from gql import Client, gql\n", |
||||
"from gql.transport.requests import RequestsHTTPTransport\n", |
||||
"\n", |
||||
"cwd = os.getcwd()\n", |
||||
"print(cwd)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "7374f89e-23f8-407d-967b-c76e7d6d93a2", |
||||
"metadata": { |
||||
"scrolled": true, |
||||
"tags": [] |
||||
}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"with open(\"/home/jovyan/code/directus/docker.json\") as f:\n", |
||||
" scrubbed_records = json.load(f)\n", |
||||
"\n", |
||||
"# print(scrubbed_records[0])\n", |
||||
"item = scrubbed_records[0]\n", |
||||
"name = item[\"Name\"]\n", |
||||
"image = item[\"Config\"][\"Image\"]\n", |
||||
"# print(name)\n", |
||||
"# print(image)\n", |
||||
"image = image.replace(\":latest\", \"\")\n", |
||||
"name = name.replace(\"/\", \"\")\n", |
||||
"print(name)\n", |
||||
"print(image)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "f2b300a9-f7c0-4863-9696-29e92e6cedc8", |
||||
"metadata": { |
||||
"scrolled": true, |
||||
"tags": [] |
||||
}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"for x in scrubbed_records:\n", |
||||
" # pprint.pprint(x)\n", |
||||
" item = x\n", |
||||
" name = item[\"Name\"]\n", |
||||
" image = item[\"Config\"][\"Image\"]\n", |
||||
" image = image.replace(\":latest\", \"\")\n", |
||||
" name = name.replace(\"/\", \"\")\n", |
||||
" print(name)\n", |
||||
" print(image)\n", |
||||
" input_set = {\"id\": name, \"image\": image, \"name\": name, \"raw\": item}\n", |
||||
"\n", |
||||
" my_headers = {\n", |
||||
" \"Authorization\": os.getenv(directus_token),\n", |
||||
" \"Content-Type\": \"application/json\",\n", |
||||
" }\n", |
||||
" response = requests.post(\n", |
||||
" \"https://cms.donavanaldrich.com/items/containers\",\n", |
||||
" headers=my_headers,\n", |
||||
" json=(input_set),\n", |
||||
" )\n", |
||||
" print(response.json())" |
||||
] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3.10.4 64-bit", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.10.4" |
||||
}, |
||||
"toc-autonumbering": false, |
||||
"toc-showcode": false, |
||||
"toc-showtags": false, |
||||
"vscode": { |
||||
"interpreter": { |
||||
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" |
||||
} |
||||
}, |
||||
"widgets": { |
||||
"application/vnd.jupyter.widget-state+json": { |
||||
"state": {}, |
||||
"version_major": 2, |
||||
"version_minor": 0 |
||||
} |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 5 |
||||
} |
||||
@ -0,0 +1,326 @@ |
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "2bec1b04-f1ab-4165-a4ea-cc890cc9e5ec", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"!python -m pip install gql" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "7374f89e-23f8-407d-967b-c76e7d6d93a2", |
||||
"metadata": { |
||||
"scrolled": true, |
||||
"tags": [] |
||||
}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"import csv\n", |
||||
"\n", |
||||
"with open(\"/home/jovyan/code/directus/homebrew.txt\") as f:\n", |
||||
" reader = csv.reader(f)\n", |
||||
" for row in reader:\n", |
||||
" item = row[0]\n", |
||||
" print(item)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "f0367eee-e052-4184-b016-8ecb0dd1aa32", |
||||
"metadata": { |
||||
"scrolled": true, |
||||
"tags": [] |
||||
}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"for x in scrubbed_records:\n", |
||||
" # pprint.pprint(x)\n", |
||||
" image = image.replace(\":latest\", \"\")\n", |
||||
" name = name.replace(\"/\", \"\")\n", |
||||
" data = x" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "f2b300a9-f7c0-4863-9696-29e92e6cedc8", |
||||
"metadata": { |
||||
"scrolled": true, |
||||
"tags": [] |
||||
}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"for x in scrubbed_records:\n", |
||||
" item = x\n", |
||||
" name = item[\"Name\"]\n", |
||||
" image = item[\"Config\"][\"Image\"]\n", |
||||
" image = image.replace(\":latest\", \"\")\n", |
||||
" name = name.replace(\"/\", \"\")\n", |
||||
" print(name)\n", |
||||
" print(image)\n", |
||||
" input_set = {\"id\": name, \"image\": image, \"name\": name, \"raw\": item}\n", |
||||
"\n", |
||||
" my_headers = {\n", |
||||
" \"Authorization\": \"os.env(directus_token)\",\n", |
||||
" \"Content-Type\": \"application/json\",\n", |
||||
" }\n", |
||||
" response = requests.post(\n", |
||||
" \"https://cms.donavanaldrich.com/items/containers\",\n", |
||||
" headers=my_headers,\n", |
||||
" json=(input_set),\n", |
||||
" )\n", |
||||
" print(response.json())" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "a4dc5471-3df9-4d52-865e-ca9202d472a3", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"# https://formulae.brew.sh/api/cask.json" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 3, |
||||
"id": "74566291-5fb8-455a-b674-03c0733c6700", |
||||
"metadata": { |
||||
"tags": [] |
||||
}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"{'appcast': None,\n", |
||||
" 'artifacts': [['0 A.D..app'],\n", |
||||
" {'signal': {},\n", |
||||
" 'trash': '~/Library/Saved Application '\n", |
||||
" 'State/com.wildfiregames.0ad.savedState'}],\n", |
||||
" 'auto_updates': None,\n", |
||||
" 'caveats': None,\n", |
||||
" 'conflicts_with': None,\n", |
||||
" 'container': None,\n", |
||||
" 'depends_on': {'macos': {'>=': ['10.12']}},\n", |
||||
" 'desc': 'Real-time strategy game',\n", |
||||
" 'full_token': '0-ad',\n", |
||||
" 'homepage': 'https://play0ad.com/',\n", |
||||
" 'installed': None,\n", |
||||
" 'name': ['0 A.D.'],\n", |
||||
" 'outdated': False,\n", |
||||
" 'sha256': 'd1a2073dee3435d8a78bf289206248c9ed6be5e17f4ba1ac8412caf6d0eae0b0',\n", |
||||
" 'tap': 'homebrew/cask',\n", |
||||
" 'token': '0-ad',\n", |
||||
" 'url': 'https://releases.wildfiregames.com/0ad-0.0.25b-alpha-osx64.dmg',\n", |
||||
" 'version': '0.0.25b-alpha',\n", |
||||
" 'versions': {}}\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"import json\n", |
||||
"import os\n", |
||||
"import pprint\n", |
||||
"\n", |
||||
"import requests\n", |
||||
"\n", |
||||
"my_headers = {\"Content-Type\": \"application/json\"}\n", |
||||
"raw_casks = requests.get(\"https://formulae.brew.sh/api/cask.json\")\n", |
||||
"\n", |
||||
"casks = raw_casks.json()\n", |
||||
"\n", |
||||
"# pprint.pprint(casks[0])" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "7b3f64e7-019a-4c21-9de2-5c84bd22640f", |
||||
"metadata": { |
||||
"scrolled": true, |
||||
"tags": [] |
||||
}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"for cask in casks:\n", |
||||
" name = cask[\"name\"][0]\n", |
||||
" desc = cask[\"desc\"]\n", |
||||
" homepage = cask[\"homepage\"]\n", |
||||
" url = cask[\"url\"]\n", |
||||
" tap = cask[\"tap\"]\n", |
||||
" full_name = cask[\"full_token\"]\n", |
||||
" print(full_token)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 4, |
||||
"id": "1d6f86f0-91ab-4773-aba3-ace57852f9e4", |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"ename": "NameError", |
||||
"evalue": "name 'raw' is not defined", |
||||
"output_type": "error", |
||||
"traceback": [ |
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
||||
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", |
||||
"\u001b[0;32m/tmp/ipykernel_9736/2986828884.py\u001b[0m in \u001b[0;36m<cell line: 3>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[0mcategory\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"cask\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 11\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 12\u001b[0;31m \u001b[0minput_set\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m\"id\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mfull_name\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"description\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mdesc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"homepage\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mhomepage\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"tap\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mtap\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"raw\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mraw\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"category\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mcategory\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 13\u001b[0m response = requests.post(\n\u001b[1;32m 14\u001b[0m \u001b[0;34m\"https://cms.donavanaldrich.com/items/all_homebrews\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", |
||||
"\u001b[0;31mNameError\u001b[0m: name 'raw' is not defined" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"my_headers = {\"Authorization\": \"os.env(directus_token)\", \"Content-Type\": \"application/json\"}\n", |
||||
"\n", |
||||
"for cask in casks:\n", |
||||
" name = cask[\"name\"][0]\n", |
||||
" desc = cask[\"desc\"]\n", |
||||
" homepage = cask[\"homepage\"]\n", |
||||
" url = cask[\"url\"]\n", |
||||
" tap = cask[\"tap\"]\n", |
||||
" full_name = cask[\"full_token\"]\n", |
||||
" category = \"cask\"\n", |
||||
" # raw\n", |
||||
"\n", |
||||
" input_set = {\n", |
||||
" \"id\": full_name,\n", |
||||
" \"description\": desc,\n", |
||||
" \"homepage\": homepage,\n", |
||||
" \"tap\": tap,\n", |
||||
" \"raw\": cask,\n", |
||||
" \"category\": category,\n", |
||||
" }\n", |
||||
" response = requests.post(\n", |
||||
" \"https://cms.donavanaldrich.com/items/all_homebrews\",\n", |
||||
" headers=my_headers,\n", |
||||
" json=(input_set),\n", |
||||
" )\n", |
||||
" print(response.json())" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "ecab5d16-91a5-4a3d-9772-516410b8ce76", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"# https://formulae.brew.sh/api/formula.json" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "762b9c4d-dbfb-45dc-a24f-ca1a3a3bbbcf", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"my_headers = {\"Content-Type\": \"application/json\"}\n", |
||||
"raw_brews = requests.get(\"https://formulae.brew.sh/api/formula.json\")\n", |
||||
"\n", |
||||
"brews = raw_brews.json()\n", |
||||
"\n", |
||||
"pprint.pprint(brews[0])" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "9bb9a11e-4343-421c-820d-ef927e02532f", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"for brew in brews:\n", |
||||
" name = brew[\"name\"]\n", |
||||
" desc = brew[\"desc\"]\n", |
||||
" homepage = brew[\"homepage\"]\n", |
||||
" url = brew[\"urls\"][\"stable\"][\"url\"]\n", |
||||
" tap = brew[\"tap\"]\n", |
||||
" full_name = brew[\"full_name\"]\n", |
||||
" print(urls)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "9630a738-10ef-40a0-b666-097b0ab02c06", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"my_headers = {\"Authorization\": \"os.env(directus_token)\", \"Content-Type\": \"application/json\"}\n", |
||||
"\n", |
||||
"for brew in brews:\n", |
||||
" name = brew[\"name\"]\n", |
||||
" desc = brew[\"desc\"]\n", |
||||
" homepage = brew[\"homepage\"]\n", |
||||
" url = brew[\"urls\"][\"stable\"][\"url\"]\n", |
||||
" tap = brew[\"tap\"]\n", |
||||
" full_name = brew[\"full_name\"]\n", |
||||
" category = \"brew\"\n", |
||||
"\n", |
||||
" input_set = {\n", |
||||
" \"id\": full_name,\n", |
||||
" \"description\": desc,\n", |
||||
" \"homepage\": homepage,\n", |
||||
" \"tap\": tap,\n", |
||||
" \"raw\": brew,\n", |
||||
" \"category\": category,\n", |
||||
" }\n", |
||||
" response = requests.post(\n", |
||||
" \"https://cms.donavanaldrich.com/items/all_homebrews\",\n", |
||||
" headers=my_headers,\n", |
||||
" json=(input_set),\n", |
||||
" )\n", |
||||
" print(response.json())" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "b835d52d-88bd-49f5-a1e3-d2b3c56e4fb2", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3 (ipykernel)", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.9.12" |
||||
}, |
||||
"toc-autonumbering": false, |
||||
"toc-showcode": false, |
||||
"toc-showtags": false, |
||||
"widgets": { |
||||
"application/vnd.jupyter.widget-state+json": { |
||||
"state": {}, |
||||
"version_major": 2, |
||||
"version_minor": 0 |
||||
} |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 5 |
||||
} |
||||
@ -0,0 +1,324 @@ |
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "2bec1b04-f1ab-4165-a4ea-cc890cc9e5ec", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"pip install gql" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "dca88210-18db-45ee-9949-7010b92dbae7", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"import json\n", |
||||
"import os\n", |
||||
"import pprint\n", |
||||
"\n", |
||||
"import requests\n", |
||||
"from gql import Client, gql\n", |
||||
"from gql.transport.requests import RequestsHTTPTransport\n", |
||||
"\n", |
||||
"cwd = os.getcwd()\n", |
||||
"print(cwd)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 14, |
||||
"id": "7374f89e-23f8-407d-967b-c76e7d6d93a2", |
||||
"metadata": { |
||||
"scrolled": true, |
||||
"tags": [] |
||||
}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"active_workflow\n", |
||||
"automaticmode/active_workflow\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"data_json = os.env(PATH)\n", |
||||
"\n", |
||||
"\n", |
||||
"with open(data_json) as f:\n", |
||||
" scrubbed_records = json.load(f)\n", |
||||
"\n", |
||||
"# print(scrubbed_records[0])\n", |
||||
"item = scrubbed_records[0]\n", |
||||
"name = item[\"Name\"]\n", |
||||
"image = item[\"Config\"][\"Image\"]\n", |
||||
"# print(name)\n", |
||||
"# print(image)\n", |
||||
"image = image.replace(\":latest\", \"\")\n", |
||||
"name = name.replace(\"/\", \"\")\n", |
||||
"print(name)\n", |
||||
"print(image)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "f0367eee-e052-4184-b016-8ecb0dd1aa32", |
||||
"metadata": { |
||||
"scrolled": true, |
||||
"tags": [] |
||||
}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"for x in scrubbed_records:\n", |
||||
" # pprint.pprint(x)\n", |
||||
" image = image.replace(\":latest\", \"\")\n", |
||||
" name = name.replace(\"/\", \"\")\n", |
||||
" data = x" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "f2b300a9-f7c0-4863-9696-29e92e6cedc8", |
||||
"metadata": { |
||||
"scrolled": true, |
||||
"tags": [] |
||||
}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"for x in scrubbed_records:\n", |
||||
" # pprint.pprint(x)\n", |
||||
" item = x\n", |
||||
" name = item[\"Name\"]\n", |
||||
" image = item[\"Config\"][\"Image\"]\n", |
||||
" image = image.replace(\":latest\", \"\")\n", |
||||
" name = name.replace(\"/\", \"\")\n", |
||||
" print(name)\n", |
||||
" print(image)\n", |
||||
" input_set = {\"id\": name, \"image\": image, \"name\": name, \"raw\": item}\n", |
||||
"\n", |
||||
" my_headers = {\"Authorization\": \"os.env(directus_token)\", \"Content-Type\": \"application/json\"}\n", |
||||
" response = requests.post(\n", |
||||
" \"https://cms.donavanaldrich.com/items/containers\",\n", |
||||
" headers=my_headers,\n", |
||||
" json=(input_set),\n", |
||||
" )\n", |
||||
" print(response.json())" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "927fe89f-9660-4681-884b-f258fc669b88", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"pip install gql[all] aiohttp\n" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 28, |
||||
"id": "a4dc5471-3df9-4d52-865e-ca9202d472a3", |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"ename": "NameError", |
||||
"evalue": "name 'RequestsHTTPTransport' is not defined", |
||||
"output_type": "error", |
||||
"traceback": [ |
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
||||
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", |
||||
"\u001b[0;32m/tmp/ipykernel_7244/3689489481.py\u001b[0m in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m sample_transport = RequestsHTTPTransport(\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0murl\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"http://directus:8055/graphql\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0muse_json\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m headers={\n\u001b[1;32m 5\u001b[0m \u001b[0;34m\"Content-type\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;34m\"application/json\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", |
||||
"\u001b[0;31mNameError\u001b[0m: name 'RequestsHTTPTransport' is not defined" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"\n", |
||||
"sample_transport = RequestsHTTPTransport(\n", |
||||
" url=\"http://directus:8055/graphql\",\n", |
||||
" use_json=True,\n", |
||||
" headers={\n", |
||||
" \"Content-type\": \"application/json\",\n", |
||||
" \"Authorization\": \"os.env(directus_token)\",\n", |
||||
" },\n", |
||||
" verify=True,\n", |
||||
" retries=3,\n", |
||||
")\n", |
||||
"\n", |
||||
"client = Client(\n", |
||||
" transport=sample_transport,\n", |
||||
" fetch_schema_from_transport=True,\n", |
||||
")\n", |
||||
"\n", |
||||
"query = gql(\n", |
||||
" '''\n", |
||||
" query {\n", |
||||
" pages {\n", |
||||
" single(id: 3) {\n", |
||||
" id\n", |
||||
" path\n", |
||||
" locale\n", |
||||
" title\n", |
||||
" description\n", |
||||
" contentType\n", |
||||
" isPublished\n", |
||||
" isPrivate\n", |
||||
" privateNS\n", |
||||
" createdAt\n", |
||||
" updatedAt\n", |
||||
" }\n", |
||||
" }\n", |
||||
" }\n", |
||||
"'''\n", |
||||
")\n", |
||||
"\n", |
||||
"# params = { \"title\": article_attributes_data-posted-on }\n", |
||||
"\n", |
||||
"result = client.execute(query, variable_values=params)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "48935cc6-c7c7-43f7-9fb7-c34bd457c903", |
||||
"metadata": { |
||||
"scrolled": true, |
||||
"tags": [] |
||||
}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"import asyncio\n", |
||||
"\n", |
||||
"from gql import gql, Client\n", |
||||
"from gql.transport.aiohttp import AIOHTTPTransport\n", |
||||
"\n", |
||||
"transport = AIOHTTPTransport(\n", |
||||
" url=\"http://wiki:3000/graphql\",\n", |
||||
" headers={\n", |
||||
" \"Content-type\": \"application/json\",\n", |
||||
" \"Authorization\": \"os.env(directus_token)\",\n", |
||||
" },\n", |
||||
")\n", |
||||
"\n", |
||||
"# Create a GraphQL client using the defined transport\n", |
||||
"# client = Client(transport=transport, fetch_schema_from_transport=True)\n", |
||||
"client = Client(transport=transport, fetch_schema_from_transport=False)\n", |
||||
"# client = Client(transport=transport, fetch_schema_from_transport=True)\n", |
||||
"\n", |
||||
"query = gql(\n", |
||||
" '''\n", |
||||
" query pageList {\n", |
||||
" pages {\n", |
||||
" list(locale: \"en\") {\n", |
||||
" id\n", |
||||
" path\n", |
||||
" locale\n", |
||||
" title\n", |
||||
" description\n", |
||||
" contentType\n", |
||||
" isPublished\n", |
||||
" isPrivate\n", |
||||
" privateNS\n", |
||||
" createdAt\n", |
||||
" updatedAt\n", |
||||
" tags\n", |
||||
" }\n", |
||||
" }\n", |
||||
" }\n", |
||||
"'''\n", |
||||
")\n", |
||||
"\n", |
||||
"\n", |
||||
"\n", |
||||
"# result = await session.execute(query)\n", |
||||
"# print(result)\n", |
||||
"result = await client.execute_async(query)\n", |
||||
"print(result)\n", |
||||
"\n", |
||||
" \n", |
||||
"# asyncio.run(main())\n", |
||||
"# Execute the query on the transport\n", |
||||
"# result = await client.execute_async(query)\n", |
||||
"# print(result)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "cfe2738f-7b10-45e2-bb31-38e8820b1ed6", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"from gql import gql, Client\n", |
||||
"from gql.transport.aiohttp import AIOHTTPTransport\n", |
||||
"\n", |
||||
"# Select your transport with a defined url endpoint\n", |
||||
"transport = AIOHTTPTransport(url=\"https://countries.trevorblades.com/\")\n", |
||||
"\n", |
||||
"# Create a GraphQL client using the defined transport\n", |
||||
"client = Client(transport=transport, fetch_schema_from_transport=True)\n", |
||||
"\n", |
||||
"# Provide a GraphQL query\n", |
||||
"query = gql(\n", |
||||
" \"\"\"\n", |
||||
" query getContinents {\n", |
||||
" continents {\n", |
||||
" code\n", |
||||
" name\n", |
||||
" }\n", |
||||
" }\n", |
||||
"\"\"\"\n", |
||||
")\n", |
||||
"\n", |
||||
"# Execute the query on the transport\n", |
||||
"result = client.execute(query)\n", |
||||
"print(result)" |
||||
] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3.8.9 64-bit", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.10.4" |
||||
}, |
||||
"toc-autonumbering": false, |
||||
"toc-showcode": false, |
||||
"toc-showtags": false, |
||||
"vscode": { |
||||
"interpreter": { |
||||
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" |
||||
} |
||||
}, |
||||
"widgets": { |
||||
"application/vnd.jupyter.widget-state+json": { |
||||
"state": {}, |
||||
"version_major": 2, |
||||
"version_minor": 0 |
||||
} |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 5 |
||||
} |
||||
@ -0,0 +1,198 @@ |
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "markdown", |
||||
"id": "5a2a0654", |
||||
"metadata": {}, |
||||
"source": [ |
||||
"curl --request GET \\\n", |
||||
" --url https://demo.linkace.org/api/v1/links \\\n", |
||||
" --header 'Authorization: Bearer undefined' \\\n", |
||||
" --header 'Content-Type: application/json' \\\n", |
||||
" --header 'accept: application/json'" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "60990b52", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"\n" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "markdown", |
||||
"id": "ebef409e-ddc1-4cc4-bd4d-a4839ba62d66", |
||||
"metadata": {}, |
||||
"source": [ |
||||
"## Pull links from Linkace" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 6, |
||||
"id": "02d6d963-538a-47c1-957f-06c7ea7c7497", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"import json\n", |
||||
"import os\n", |
||||
"import pprint\n", |
||||
"import urllib.parse\n", |
||||
"import sys\n", |
||||
"import requests\n", |
||||
"\n", |
||||
"my_headers = {\n", |
||||
" \"Authorization\": os.env(LINKACE_TOKEN),\n", |
||||
" \"Content-Type\": \"application/json\",\n", |
||||
" \"Accept\": \"application/json\",\n", |
||||
"}\n", |
||||
"\n", |
||||
"response = requests.get(\n", |
||||
" \"http://linkace/api/v1/links\",\n", |
||||
" headers=my_headers,\n", |
||||
")\n", |
||||
"\n", |
||||
"initial = response.json()\n", |
||||
"\n", |
||||
"last = initial['last_page']\n", |
||||
"\n", |
||||
"links = []\n", |
||||
"\n", |
||||
"for x in range(1, last + 1):\n", |
||||
" response = requests.get(\n", |
||||
" \"http://linkace/api/v1/links?page=\" + str(x),\n", |
||||
" headers=my_headers,\n", |
||||
" )\n", |
||||
" result = response.json()\n", |
||||
" data = result['data']\n", |
||||
" links = links + data\n", |
||||
" \n", |
||||
"out_file = open(\"links.json\", \"w\")\n", |
||||
"json.dump(links, out_file, indent = 2)\n", |
||||
"out_file.close()" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "markdown", |
||||
"id": "e6a27401-cc7d-4ffe-834d-2f051dce7025", |
||||
"metadata": {}, |
||||
"source": [ |
||||
"## Update Links in Directus" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 7, |
||||
"id": "f2b300a9-f7c0-4863-9696-29e92e6cedc8", |
||||
"metadata": { |
||||
"scrolled": true, |
||||
"tags": [] |
||||
}, |
||||
"outputs": [ |
||||
{ |
||||
"ename": "JSONDecodeError", |
||||
"evalue": "[Errno Expecting value] : 0", |
||||
"output_type": "error", |
||||
"traceback": [ |
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
||||
"\u001b[0;31mJSONDecodeError\u001b[0m Traceback (most recent call last)", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.9/site-packages/requests/models.py:910\u001b[0m, in \u001b[0;36mResponse.json\u001b[0;34m(self, **kwargs)\u001b[0m\n\u001b[1;32m 909\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 910\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mcomplexjson\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mloads\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtext\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 911\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m JSONDecodeError \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m 912\u001b[0m \u001b[38;5;66;03m# Catch JSON-related errors and raise as requests.JSONDecodeError\u001b[39;00m\n\u001b[1;32m 913\u001b[0m \u001b[38;5;66;03m# This aliases json.JSONDecodeError and simplejson.JSONDecodeError\u001b[39;00m\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.9/json/__init__.py:346\u001b[0m, in \u001b[0;36mloads\u001b[0;34m(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)\u001b[0m\n\u001b[1;32m 343\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m (\u001b[38;5;28mcls\u001b[39m \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m object_hook \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m\n\u001b[1;32m 344\u001b[0m parse_int \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m parse_float \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m\n\u001b[1;32m 345\u001b[0m parse_constant \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m object_pairs_hook \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m kw):\n\u001b[0;32m--> 346\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_default_decoder\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdecode\u001b[49m\u001b[43m(\u001b[49m\u001b[43ms\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 347\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mcls\u001b[39m \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.9/json/decoder.py:337\u001b[0m, in \u001b[0;36mJSONDecoder.decode\u001b[0;34m(self, s, _w)\u001b[0m\n\u001b[1;32m 333\u001b[0m \u001b[38;5;124;03m\"\"\"Return the Python representation of ``s`` (a ``str`` instance\u001b[39;00m\n\u001b[1;32m 334\u001b[0m \u001b[38;5;124;03mcontaining a JSON document).\u001b[39;00m\n\u001b[1;32m 335\u001b[0m \n\u001b[1;32m 336\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m--> 337\u001b[0m obj, end \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mraw_decode\u001b[49m\u001b[43m(\u001b[49m\u001b[43ms\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43midx\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m_w\u001b[49m\u001b[43m(\u001b[49m\u001b[43ms\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mend\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 338\u001b[0m end \u001b[38;5;241m=\u001b[39m _w(s, end)\u001b[38;5;241m.\u001b[39mend()\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.9/json/decoder.py:355\u001b[0m, in \u001b[0;36mJSONDecoder.raw_decode\u001b[0;34m(self, s, idx)\u001b[0m\n\u001b[1;32m 354\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mStopIteration\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m err:\n\u001b[0;32m--> 355\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m JSONDecodeError(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mExpecting value\u001b[39m\u001b[38;5;124m\"\u001b[39m, s, err\u001b[38;5;241m.\u001b[39mvalue) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;28mNone\u001b[39m\n\u001b[1;32m 356\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m obj, end\n", |
||||
"\u001b[0;31mJSONDecodeError\u001b[0m: Expecting value: line 1 column 1 (char 0)", |
||||
"\nDuring handling of the above exception, another exception occurred:\n", |
||||
"\u001b[0;31mJSONDecodeError\u001b[0m Traceback (most recent call last)", |
||||
"Input \u001b[0;32mIn [7]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 8\u001b[0m headers \u001b[38;5;241m=\u001b[39m {\n\u001b[1;32m 9\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAuthorization\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mos.env(directus_token)\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 10\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mContent-Type\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mapplication/json\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 11\u001b[0m }\n\u001b[1;32m 12\u001b[0m response \u001b[38;5;241m=\u001b[39m requests\u001b[38;5;241m.\u001b[39mpatch(\n\u001b[1;32m 13\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhttp://directus:8055/items/bookmarks/\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;241m+\u001b[39m \u001b[38;5;28mstr\u001b[39m(myid),\n\u001b[1;32m 14\u001b[0m headers\u001b[38;5;241m=\u001b[39mheaders,\n\u001b[1;32m 15\u001b[0m json\u001b[38;5;241m=\u001b[39m(link),\n\u001b[1;32m 16\u001b[0m )\n\u001b[0;32m---> 17\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mresponse\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mjson\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m)\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.9/site-packages/requests/models.py:917\u001b[0m, in \u001b[0;36mResponse.json\u001b[0;34m(self, **kwargs)\u001b[0m\n\u001b[1;32m 915\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m RequestsJSONDecodeError(e\u001b[38;5;241m.\u001b[39mmessage)\n\u001b[1;32m 916\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 917\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m RequestsJSONDecodeError(e\u001b[38;5;241m.\u001b[39mmsg, e\u001b[38;5;241m.\u001b[39mdoc, e\u001b[38;5;241m.\u001b[39mpos)\n", |
||||
"\u001b[0;31mJSONDecodeError\u001b[0m: [Errno Expecting value] : 0" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"for link in links:\n", |
||||
" url = link['url']\n", |
||||
" myid = link.pop(\"id\")\n", |
||||
" parsed_url = urllib.parse.urlparse(url)\n", |
||||
" domain = parsed_url.netloc\n", |
||||
" pdom = domain.replace(\"www.\", \"\")\n", |
||||
" link['domain'] = pdom\n", |
||||
" headers = {\n", |
||||
" \"Authorization\": \"os.env(directus_token)\",\n", |
||||
" \"Content-Type\": \"application/json\",\n", |
||||
" }\n", |
||||
" response = requests.patch(\n", |
||||
" \"http://directus:8055/items/bookmarks/\" + str(myid),\n", |
||||
" headers=headers,\n", |
||||
" json=(link),\n", |
||||
" )\n", |
||||
" print(response.json())" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "b9d5bb9f-be1e-4db2-b0a3-d0d179e6b6a6", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"import urllib.parse\n", |
||||
"import sys\n", |
||||
"\n", |
||||
"link = links[1]\n", |
||||
"url = link['url']\n", |
||||
"myid = link.pop(\"id\")\n", |
||||
"print(link)\n", |
||||
"parsed_url = urllib.parse.urlparse(url)\n", |
||||
"domain = parsed_url.netloc\n", |
||||
"pdom = domain.replace(\"www.\", \"\")\n", |
||||
"print(pdom)\n", |
||||
"link['domain'] = pdom\n", |
||||
"\n", |
||||
"\n", |
||||
"print(link)\n", |
||||
"\n", |
||||
"print(myid)" |
||||
] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3 (ipykernel)", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.10.5" |
||||
}, |
||||
"toc-autonumbering": false, |
||||
"toc-showcode": false, |
||||
"toc-showtags": false, |
||||
"vscode": { |
||||
"interpreter": { |
||||
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" |
||||
} |
||||
}, |
||||
"widgets": { |
||||
"application/vnd.jupyter.widget-state+json": { |
||||
"state": {}, |
||||
"version_major": 2, |
||||
"version_minor": 0 |
||||
} |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 5 |
||||
} |
||||
@ -0,0 +1,86 @@ |
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "927fe89f-9660-4681-884b-f258fc669b88", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"pip install gql[all] aiohttp" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "a4dc5471-3df9-4d52-865e-ca9202d472a3", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"import asyncio\n", |
||||
"\n", |
||||
"from gql import Client, gql\n", |
||||
"from gql.transport.aiohttp import AIOHTTPTransport\n", |
||||
"\n", |
||||
"transport = AIOHTTPTransport(\n", |
||||
" url=\"http://directus:8055/graphql\",\n", |
||||
" headers={\n", |
||||
" \"Content-type\": \"application/json\",\n", |
||||
" \"Authorization\": \"os.env(directus_token)\",\n", |
||||
" },\n", |
||||
")\n", |
||||
"\n", |
||||
"client = Client(transport=transport, fetch_schema_from_transport=False)\n", |
||||
"\n", |
||||
"query = gql(\n", |
||||
" \"\"\"\n", |
||||
" query {\n", |
||||
" pages {\n", |
||||
" id\n", |
||||
" }\n", |
||||
" }\n", |
||||
"\"\"\"\n", |
||||
")\n", |
||||
"\n", |
||||
"result = await client.execute_async(query)\n", |
||||
"print(result)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "f9429bdb-d291-49ce-8191-9977b3624f97", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3 (ipykernel)", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.9.12" |
||||
}, |
||||
"widgets": { |
||||
"application/vnd.jupyter.widget-state+json": { |
||||
"state": {}, |
||||
"version_major": 2, |
||||
"version_minor": 0 |
||||
} |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 5 |
||||
} |
||||
@ -0,0 +1,114 @@ |
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "2b593a01", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"import json\n", |
||||
"import os\n", |
||||
"import pprint\n", |
||||
"import urllib.parse\n", |
||||
"import sys\n", |
||||
"import requests\n", |
||||
"\n", |
||||
"my_headers = {\n", |
||||
" \"Content-Type\": \"application/json\",\n", |
||||
" \"Accept\": \"application/json\",\n", |
||||
"}\n", |
||||
"\n", |
||||
"\n", |
||||
"url = \"https://donavanaldrich.com/api/metrics/netdata/charts\"\n", |
||||
"\n", |
||||
"response = requests.get(url, headers=my_headers)\n", |
||||
"\n", |
||||
"print(response.text)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 8, |
||||
"id": "61edf606", |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"/bin/bash: curl: command not found\r\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"!curl 'https://donavanaldrich.com/api/metrics/netdata/charts'\n", |
||||
" " |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 10, |
||||
"id": "5b29fb25", |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]\n", |
||||
"Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease \u001b[0m\n", |
||||
"Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]\n", |
||||
"Get:4 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [1,472 kB]\n", |
||||
"Get:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB][33m\u001b[33m\n", |
||||
"Get:6 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [2,099 kB]\n", |
||||
"Get:7 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [889 kB]m\u001b[33m\n", |
||||
"Get:8 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [1,183 kB]\n", |
||||
"Get:9 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [1,583 kB]\n", |
||||
"Get:10 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [2,555 kB]\n", |
||||
"Get:11 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [27.4 kB]\n", |
||||
"Get:12 http://archive.ubuntu.com/ubuntu focal-backports/main amd64 Packages [55.1 kB]\n", |
||||
"Fetched 10.2 MB in 2s (5,367 kB/s)3m \u001b[0m\u001b[33m\u001b[33m\n", |
||||
"Reading package lists... Done\n", |
||||
"Building dependency tree \n", |
||||
"Reading state information... Done\n", |
||||
"7 packages can be upgraded. Run 'apt list --upgradable' to see them.\n", |
||||
"/bin/bash: suo: command not found\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"!sudo apt update && sudo apt upgrade -y" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "1f7c6a9d", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3 (ipykernel)", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.10.5" |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 5 |
||||
} |
||||
@ -0,0 +1,130 @@ |
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "e3fe9fc8", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"import json\n", |
||||
"import os\n", |
||||
"import pprint\n", |
||||
"import urllib.parse\n", |
||||
"import sys\n", |
||||
"import requests\n", |
||||
"\n", |
||||
"my_headers = {\n", |
||||
" \"Content-Type\": \"application/json\",\n", |
||||
" \"Accept\": \"application/json\",\n", |
||||
"}\n", |
||||
"\n", |
||||
"\n", |
||||
"url = \"https://donavanaldrich.com/api/metrics/netdata/charts\"\n", |
||||
"\n", |
||||
"response = requests.get(url, headers=my_headers)\n", |
||||
"\n", |
||||
"print(response.text)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "a59e77d5", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"!curl 'https://donavanaldrich.com/api/metrics/netdata/charts'\n", |
||||
" " |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 1, |
||||
"id": "6745302c", |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease\n", |
||||
"Hit:2 http://security.ubuntu.com/ubuntu focal-security InRelease\n", |
||||
"Hit:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease\n", |
||||
"Hit:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease\n", |
||||
"Reading package lists... Done\u001b[33m\u001b[33m\n", |
||||
"Building dependency tree \n", |
||||
"Reading state information... Done\n", |
||||
"All packages are up to date.\n", |
||||
"Reading package lists... Done\n", |
||||
"Building dependency tree \n", |
||||
"Reading state information... Done\n", |
||||
"Calculating upgrade... Done\n", |
||||
"0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.\n", |
||||
"Reading package lists... Done\n", |
||||
"Building dependency tree \n", |
||||
"Reading state information... Done\n", |
||||
"The following additional packages will be installed:\n", |
||||
" libcurl4\n", |
||||
"The following NEW packages will be installed:\n", |
||||
" curl libcurl4\n", |
||||
"0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.\n", |
||||
"Need to get 396 kB of archives.\n", |
||||
"After this operation, 1,121 kB of additional disk space will be used.\n", |
||||
"Get:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libcurl4 amd64 7.68.0-1ubuntu2.12 [235 kB]\n", |
||||
"Get:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 curl amd64 7.68.0-1ubuntu2.12 [161 kB]\n", |
||||
"Fetched 396 kB in 0s (812 kB/s)[0m\u001b[33m\n", |
||||
"debconf: delaying package configuration, since apt-utils is not installed\n", |
||||
"\n", |
||||
"\u001b7\u001b[0;23r\u001b8\u001b[1A\u001b[1;31mE: \u001b[0mCan not write log (Is /dev/pts mounted?) - open (1: Operation not permitted)\u001b[0m\n", |
||||
"Selecting previously unselected package libcurl4:amd64.\n", |
||||
"(Reading database ... 147435 files and directories currently installed.)\n", |
||||
"Preparing to unpack .../libcurl4_7.68.0-1ubuntu2.12_amd64.deb ...\n", |
||||
"\u001b7\u001b[24;0f\u001b[42m\u001b[30mProgress: [ 0%]\u001b[49m\u001b[39m [..........................................................] \u001b8\u001b7\u001b[24;0f\u001b[42m\u001b[30mProgress: [ 11%]\u001b[49m\u001b[39m [######....................................................] \u001b8Unpacking libcurl4:amd64 (7.68.0-1ubuntu2.12) ...\n", |
||||
"\u001b7\u001b[24;0f\u001b[42m\u001b[30mProgress: [ 22%]\u001b[49m\u001b[39m [############..............................................] \u001b8Selecting previously unselected package curl.\n", |
||||
"Preparing to unpack .../curl_7.68.0-1ubuntu2.12_amd64.deb ...\n", |
||||
"\u001b7\u001b[24;0f\u001b[42m\u001b[30mProgress: [ 33%]\u001b[49m\u001b[39m [###################.......................................] \u001b8Unpacking curl (7.68.0-1ubuntu2.12) ...\n", |
||||
"\u001b7\u001b[24;0f\u001b[42m\u001b[30mProgress: [ 44%]\u001b[49m\u001b[39m [#########################.................................] \u001b8\u001b[1;31mE: \u001b[0mCan not write log (Is /dev/pts mounted?) - open (1: Operation not permitted)\u001b[0m\n", |
||||
"Setting up libcurl4:amd64 (7.68.0-1ubuntu2.12) ...\n", |
||||
"\u001b7\u001b[24;0f\u001b[42m\u001b[30mProgress: [ 56%]\u001b[49m\u001b[39m [################################..........................] \u001b8\u001b7\u001b[24;0f\u001b[42m\u001b[30mProgress: [ 67%]\u001b[49m\u001b[39m [######################################....................] \u001b8Setting up curl (7.68.0-1ubuntu2.12) ...\n", |
||||
"\u001b7\u001b[24;0f\u001b[42m\u001b[30mProgress: [ 78%]\u001b[49m\u001b[39m [#############################################.............] \u001b8\u001b7\u001b[24;0f\u001b[42m\u001b[30mProgress: [ 89%]\u001b[49m\u001b[39m [###################################################.......] \u001b8Processing triggers for libc-bin (2.31-0ubuntu9.9) ...\n", |
||||
"\n", |
||||
"\u001b7\u001b[0;24r\u001b8\u001b[1A\u001b[J" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"!sudo apt update && sudo apt upgrade -y && sudo apt install curl -y" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "54f37a3a", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3 (ipykernel)", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.10.5" |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 5 |
||||
} |
||||
@ -0,0 +1,47 @@ |
||||
import requests, logging |
||||
|
||||
class Directus: |
||||
def __init__(self, url:str): |
||||
self.url = self._validate_url(url) |
||||
|
||||
def get_item(self, id:int|str, collection_name:str) -> dict: |
||||
r = requests.get(f'{self.url}/content/{collection_name}') |
||||
try: |
||||
item:dict = r.json() |
||||
return item |
||||
except ValueError: |
||||
logging.error('fail to get item') |
||||
return |
||||
|
||||
def get_file(self): |
||||
pass |
||||
|
||||
def import_file(self, url:str, title:str=None) -> dict: |
||||
"""Uses the automatic import of directus |
||||
Args: |
||||
url (str): url from wich directus should import a files |
||||
Returns: |
||||
dict: returns the message from directus |
||||
""" |
||||
payload: dict = { |
||||
'url': url, |
||||
'data': {} |
||||
} |
||||
if title: |
||||
payload['data']['title'] = title |
||||
|
||||
r = requests.post( |
||||
url = self.url + '/files/import', |
||||
json = payload |
||||
) |
||||
try: |
||||
return r.json() |
||||
except: |
||||
return {'message':'no response from directus (means "OK")'} |
||||
|
||||
def _validate_url(self, url:str): |
||||
https:str = 'https://' |
||||
http:str = 'http://' |
||||
url = url[:-1] if url[-1] == '/' else url |
||||
url = https + url if https not in url else url.replace(http, https) |
||||
return url |
||||
@ -0,0 +1,603 @@ |
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 1, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"zsh:1: command not found: brew\n", |
||||
"mkdir: cannot create directory ‘temp/gotenberg’: No such file or directory\n", |
||||
"zsh:1: command not found: fetch\n", |
||||
"Defaulting to user installation because normal site-packages is not writeable\n", |
||||
"Requirement already satisfied: markdown in /home/donaldrich/.local/lib/python3.10/site-packages (3.4.1)\n", |
||||
"Note: you may need to restart the kernel to use updated packages.\n", |
||||
"Defaulting to user installation because normal site-packages is not writeable\n", |
||||
"Requirement already satisfied: python-frontmatter in /home/donaldrich/.local/lib/python3.10/site-packages (1.0.0)\n", |
||||
"Requirement already satisfied: PyYAML in /home/donaldrich/.local/lib/python3.10/site-packages (from python-frontmatter) (5.1)\n", |
||||
"Note: you may need to restart the kernel to use updated packages.\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"!brew install fetch\n", |
||||
"!mkdir temp/gotenberg\n", |
||||
"!fetch --branch=main --source-path=/docs --repo=https://github.com/gotenberg/gotenberg.dev temp/gotenberg\n", |
||||
"%pip install markdown\n", |
||||
"%pip install python-frontmatter" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "markdown", |
||||
"metadata": {}, |
||||
"source": [ |
||||
"## Create Book if it doesn't exist\n" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 29, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"{\"name\":\"python-cheatsheet\",\"description\":\"python-cheatsheet\",\"created_by\":1,\"updated_by\":1,\"owned_by\":1,\"slug\":\"python-cheatsheet\",\"updated_at\":\"2022-08-10T00:14:32.000000Z\",\"created_at\":\"2022-08-10T00:14:32.000000Z\",\"id\":3}\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"import requests\n", |
||||
"import os\n", |
||||
"\n", |
||||
"url = \"https://donavanaldrich.com/api/bookstack/books\"\n", |
||||
"\n", |
||||
"payload = {\n", |
||||
" \"name\":\n", |
||||
" \"python-cheatsheet\",\n", |
||||
" \"description\":\n", |
||||
" \"python-cheatsheet\",\n", |
||||
" \"tags\": [{\n", |
||||
" \"name\": \"Platform\",\n", |
||||
" \"value\": \"Python\"\n", |
||||
" }, {\n", |
||||
" \"name\": \"Category\",\n", |
||||
" \"value\": \"Code\"\n", |
||||
" }, {\n", |
||||
" \"name\": \"Type\",\n", |
||||
" \"value\": \"Cheatsheet\"\n", |
||||
" }]\n", |
||||
"}\n", |
||||
"headers = {\n", |
||||
" \"X-API-KEY\": os.getenv(X_API_KEY),\n", |
||||
" \"Authorization\": os.getenv(BOOKSTACK_API_TOKEN)\n", |
||||
"}\n", |
||||
"\n", |
||||
"response = requests.request(\"POST\", url, json=payload, headers=headers)\n", |
||||
"\n", |
||||
"print(response.text)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "markdown", |
||||
"metadata": {}, |
||||
"source": [ |
||||
"## Create Chapters\n" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "markdown", |
||||
"metadata": {}, |
||||
"source": [ |
||||
"### List folders to map to chapters\n" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 1, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"['cheatsheet', 'modules', 'builtin']\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"import os\n", |
||||
"\n", |
||||
"dir = os.listdir(\"../temp/python-cheatsheets\")\n", |
||||
"\n", |
||||
"print(dir)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 23, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"18\n", |
||||
"19\n", |
||||
"20\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"import requests\n", |
||||
"\n", |
||||
"chapters = ['cheatsheet', 'modules', 'builtin']\n", |
||||
"\n", |
||||
"url = \"https://donavanaldrich.com/api/bookstack/chapters\"\n", |
||||
"\n", |
||||
"for chapter_name in chapters:\n", |
||||
"\n", |
||||
" payload = {\n", |
||||
" \"book_id\": 2,\n", |
||||
" \"name\": chapter_name,\n", |
||||
" \"description\": chapter_name,\n", |
||||
" \"tags\": [{\n", |
||||
" \"name\": \"chapter\",\n", |
||||
" \"value\": chapter_name\n", |
||||
" }]\n", |
||||
" }\n", |
||||
" headers = {\n", |
||||
" \"X-API-KEY\": os.getenv(X_API_KEY),\n", |
||||
" \"Authorization\": os.getenv(BOOKSTACK_API_TOKEN)\n", |
||||
" }\n", |
||||
"\n", |
||||
" response = requests.request(\"POST\", url, json=payload, headers=headers)\n", |
||||
" response_json = response.json()\n", |
||||
" chapter_id = response_json['id']\n", |
||||
" print(chapter_id)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "markdown", |
||||
"metadata": {}, |
||||
"source": [ |
||||
"## Add Pages\n" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 1, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"ename": "NameError", |
||||
"evalue": "name 'X_API_KEY' is not defined", |
||||
"output_type": "error", |
||||
"traceback": [ |
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
||||
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", |
||||
"\u001b[1;32m/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb Cell 9\u001b[0m in \u001b[0;36m<cell line: 10>\u001b[0;34m()\u001b[0m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X11sdnNjb2RlLXJlbW90ZQ%3D%3D?line=5'>6</a>\u001b[0m chapters \u001b[39m=\u001b[39m [\u001b[39m'\u001b[39m\u001b[39mcheatsheet\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mmodules\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mbuiltin\u001b[39m\u001b[39m'\u001b[39m]\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X11sdnNjb2RlLXJlbW90ZQ%3D%3D?line=6'>7</a>\u001b[0m \u001b[39m# The Python interpreter has a number of functions and types built into it that are always available.\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X11sdnNjb2RlLXJlbW90ZQ%3D%3D?line=7'>8</a>\u001b[0m \u001b[39m# Standard Library\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X11sdnNjb2RlLXJlbW90ZQ%3D%3D?line=8'>9</a>\u001b[0m headers \u001b[39m=\u001b[39m {\n\u001b[0;32m---> <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X11sdnNjb2RlLXJlbW90ZQ%3D%3D?line=9'>10</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mX-API-KEY\u001b[39m\u001b[39m\"\u001b[39m: os\u001b[39m.\u001b[39mgetenv(X_API_KEY),\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X11sdnNjb2RlLXJlbW90ZQ%3D%3D?line=10'>11</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mAuthorization\u001b[39m\u001b[39m\"\u001b[39m: os\u001b[39m.\u001b[39mgetenv(BOOKSTACK_API_TOKEN)\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X11sdnNjb2RlLXJlbW90ZQ%3D%3D?line=11'>12</a>\u001b[0m }\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X11sdnNjb2RlLXJlbW90ZQ%3D%3D?line=13'>14</a>\u001b[0m url \u001b[39m=\u001b[39m \u001b[39m\"\u001b[39m\u001b[39mhttps://donavanaldrich.com/api/bookstack/books\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X11sdnNjb2RlLXJlbW90ZQ%3D%3D?line=15'>16</a>\u001b[0m payload \u001b[39m=\u001b[39m {\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X11sdnNjb2RlLXJlbW90ZQ%3D%3D?line=16'>17</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mname\u001b[39m\u001b[39m\"\u001b[39m:\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X11sdnNjb2RlLXJlbW90ZQ%3D%3D?line=17'>18</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mpython-cheatsheet\u001b[39m\u001b[39m\"\u001b[39m,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X11sdnNjb2RlLXJlbW90ZQ%3D%3D?line=29'>30</a>\u001b[0m }]\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X11sdnNjb2RlLXJlbW90ZQ%3D%3D?line=30'>31</a>\u001b[0m }\n", |
||||
"\u001b[0;31mNameError\u001b[0m: name 'X_API_KEY' is not defined" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"from pathlib import Path\n", |
||||
"import requests\n", |
||||
"import frontmatter\n", |
||||
"\n", |
||||
"chapters = ['cheatsheet', 'modules', 'builtin']\n", |
||||
"\n", |
||||
"headers = {\n", |
||||
" \"X-API-KEY\": os.getenv(X_API_KEY),\n", |
||||
" \"Authorization\": os.getenv(BOOKSTACK_API_TOKEN)\n", |
||||
"}\n", |
||||
"\n", |
||||
"url = \"https://donavanaldrich.com/api/bookstack/books\"\n", |
||||
"\n", |
||||
"payload = {\n", |
||||
" \"name\":\n", |
||||
" \"python-cheatsheet\",\n", |
||||
" \"description\":\n", |
||||
" \"python-cheatsheet\",\n", |
||||
" \"tags\": [{\n", |
||||
" \"name\": \"Platform\",\n", |
||||
" \"value\": \"Python\"\n", |
||||
" }, {\n", |
||||
" \"name\": \"Category\",\n", |
||||
" \"value\": \"Code\"\n", |
||||
" }, {\n", |
||||
" \"name\": \"Type\",\n", |
||||
" \"value\": \"Cheatsheet\"\n", |
||||
" }]\n", |
||||
"}\n", |
||||
"\n", |
||||
"response = requests.request(\"POST\", url, json=payload, headers=headers)\n", |
||||
"response_json = response.json()\n", |
||||
"book_id = response_json['id']\n", |
||||
"\n", |
||||
"# book_id = xs\n", |
||||
"#\n", |
||||
"for chapter in chapters:\n", |
||||
" payload = {\n", |
||||
" \"book_id\": book_id,\n", |
||||
" \"name\": chapter,\n", |
||||
" \"description\": chapter,\n", |
||||
" \"tags\": [{\n", |
||||
" \"name\": \"chapter\",\n", |
||||
" \"value\": chapter\n", |
||||
" }]\n", |
||||
" }\n", |
||||
" url = \"https://donavanaldrich.com/api/bookstack/chapters\"\n", |
||||
" response = requests.request(\"POST\", url, json=payload, headers=headers)\n", |
||||
" response_json = response.json()\n", |
||||
" chapter_id = response_json['id']\n", |
||||
" print(chapter_id)\n", |
||||
"\n", |
||||
" for page in Path('../temp/python-cheatsheets/' + chapter).iterdir():\n", |
||||
" url = \"https://donavanaldrich.com/api/bookstack/pages\"\n", |
||||
" with open(page, 'r') as f:\n", |
||||
" metadata, content = frontmatter.parse(f.read())\n", |
||||
" try:\n", |
||||
" page_name = metadata['title']\n", |
||||
" except:\n", |
||||
" page_name = str(page)\n", |
||||
" payload = {\n", |
||||
" \"book_id\": book_id,\n", |
||||
" \"chapter_id\": chapter_id,\n", |
||||
" \"name\": page_name,\n", |
||||
" \"markdown\": content,\n", |
||||
" \"tags\": [{\n", |
||||
" \"name\": \"chapter\",\n", |
||||
" \"value\": chapter\n", |
||||
" }]\n", |
||||
" }\n", |
||||
" response = requests.request(\"POST\",\n", |
||||
" url,\n", |
||||
" json=payload,\n", |
||||
" headers=headers)\n", |
||||
"\n", |
||||
" # print(response.text)\n" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "markdown", |
||||
"metadata": {}, |
||||
"source": [ |
||||
"### Development/Sandboxing\n" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 28, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"# Python Debugging\n", |
||||
"\n", |
||||
"<base-disclaimer>\n", |
||||
" <base-disclaimer-title>\n", |
||||
" <a target=\"_blank\" href=\"https://en.wikipedia.org/wiki/Debugging\">Finding and resolving bugs</a>\n", |
||||
" </base-disclaimer-title>\n", |
||||
" <base-disclaimer-content>\n", |
||||
" In computer programming and software development, debugging is the process of finding and resolving bugs (defects or problems that prevent correct operation) within computer programs, software, or systems.\n", |
||||
" </base-disclaimer-content>\n", |
||||
"</base-disclaimer>\n", |
||||
"\n", |
||||
"## Raising Exceptions\n", |
||||
"\n", |
||||
"Exceptions are raised with a raise statement. In code, a raise statement consists of the following:\n", |
||||
"\n", |
||||
"- The `raise` keyword\n", |
||||
"- A call to the `Exception()` function\n", |
||||
"- A string with a helpful error message passed to the `Exception()` function\n", |
||||
"\n", |
||||
"```python\n", |
||||
">>> raise Exception('This is the error message.')\n", |
||||
"# Traceback (most recent call last):\n", |
||||
"# File \"<pyshell#191>\", line 1, in <module>\n", |
||||
"# raise Exception('This is the error message.')\n", |
||||
"# Exception: This is the error message.\n", |
||||
"```\n", |
||||
"\n", |
||||
"Typically, it’s the code that calls the function, not the function itself, that knows how to handle an exception. So, you will commonly see a raise statement inside a function and the `try` and `except` statements in the code calling the function.\n", |
||||
"\n", |
||||
"```python\n", |
||||
">>> def box_print(symbol, width, height):\n", |
||||
"... if len(symbol) != 1:\n", |
||||
"... raise Exception('Symbol must be a single character string.')\n", |
||||
"... if width <= 2:\n", |
||||
"... raise Exception('Width must be greater than 2.')\n", |
||||
"... if height <= 2:\n", |
||||
"... raise Exception('Height must be greater than 2.')\n", |
||||
"... print(symbol * width)\n", |
||||
"... for i in range(height - 2):\n", |
||||
"... print(symbol + (' ' * (width - 2)) + symbol)\n", |
||||
"... print(symbol * width)\n", |
||||
"...\n", |
||||
">>> for sym, w, h in (('*', 4, 4), ('O', 20, 5), ('x', 1, 3), ('ZZ', 3, 3)):\n", |
||||
"... try:\n", |
||||
"... box_print(sym, w, h)\n", |
||||
"... except Exception as err:\n", |
||||
"... print('An exception happened: ' + str(err))\n", |
||||
"...\n", |
||||
"# ****\n", |
||||
"# * *\n", |
||||
"# * *\n", |
||||
"# ****\n", |
||||
"# OOOOOOOOOOOOOOOOOOOO\n", |
||||
"# O O\n", |
||||
"# O O\n", |
||||
"# O O\n", |
||||
"# OOOOOOOOOOOOOOOOOOOO\n", |
||||
"# An exception happened: Width must be greater than 2.\n", |
||||
"# An exception happened: Symbol must be a single character string.\n", |
||||
"```\n", |
||||
"\n", |
||||
"Read more about [Exception Handling](/cheatsheet/exception-handling).\n", |
||||
"\n", |
||||
"## Getting the Traceback as a string\n", |
||||
"\n", |
||||
"The `traceback` is displayed by Python whenever a raised exception goes unhandled. But can also obtain it as a string by calling traceback.format_exc(). This function is useful if you want the information from an exception’s traceback but also want an except statement to gracefully handle the exception. You will need to import Python’s traceback module before calling this function.\n", |
||||
"\n", |
||||
"```python\n", |
||||
">>> import traceback\n", |
||||
"\n", |
||||
">>> try:\n", |
||||
"... raise Exception('This is the error message.')\n", |
||||
">>> except:\n", |
||||
"... with open('errorInfo.txt', 'w') as error_file:\n", |
||||
"... error_file.write(traceback.format_exc())\n", |
||||
"... print('The traceback info was written to errorInfo.txt.')\n", |
||||
"...\n", |
||||
"# 116\n", |
||||
"# The traceback info was written to errorInfo.txt.\n", |
||||
"```\n", |
||||
"\n", |
||||
"The 116 is the return value from the `write()` method, since 116 characters were written to the file. The `traceback` text was written to errorInfo.txt.\n", |
||||
"\n", |
||||
" Traceback (most recent call last):\n", |
||||
" File \"<pyshell#28>\", line 2, in <module>\n", |
||||
" Exception: This is the error message.\n", |
||||
"\n", |
||||
"## Assertions\n", |
||||
"\n", |
||||
"An assertion is a sanity check to make sure your code isn’t doing something obviously wrong. These sanity checks are performed by `assert` statements. If the sanity check fails, then an `AssertionError` exception is raised. In code, an `assert` statement consists of the following:\n", |
||||
"\n", |
||||
"- The `assert` keyword\n", |
||||
"- A condition (that is, an expression that evaluates to `True` or `False`)\n", |
||||
"- A comma\n", |
||||
"- A `string` to display when the condition is `False`\n", |
||||
"\n", |
||||
"```python\n", |
||||
">>> pod_bay_door_status = 'open'\n", |
||||
">>> assert pod_bay_door_status == 'open', 'The pod bay doors need to be \"open\".'\n", |
||||
"\n", |
||||
">>> pod_bay_door_status = 'I\\'m sorry, Dave. I\\'m afraid I can\\'t do that.'\n", |
||||
">>> assert pod_bay_door_status == 'open', 'The pod bay doors need to be \"open\".'\n", |
||||
"# Traceback (most recent call last):\n", |
||||
"# File \"<pyshell#10>\", line 1, in <module>\n", |
||||
"# assert pod_bay_door_status == 'open', 'The pod bay doors need to be \"open\".'\n", |
||||
"# AssertionError: The pod bay doors need to be \"open\".\n", |
||||
"```\n", |
||||
"\n", |
||||
"In plain English, an assert statement says, “I assert that this condition holds true, and if not, there is a bug somewhere in the program.” Unlike exceptions, your code should not handle assert statements with try and except; if an assert fails, your program should crash. By failing fast like this, you shorten the time between the original cause of the bug and when you first notice the bug. This will reduce the amount of code you will have to check before finding the code that’s causing the bug.\n", |
||||
"\n", |
||||
"### Disabling Assertions\n", |
||||
"\n", |
||||
"Assertions can be disabled by passing the `-O` option when running Python.\n", |
||||
"\n", |
||||
"## Logging\n", |
||||
"\n", |
||||
"To enable the `logging` module to display log messages on your screen as your program runs, copy the following to the top of your program:\n", |
||||
"\n", |
||||
"```python\n", |
||||
">>> import logging\n", |
||||
">>> logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s - %(levelname)s- %(message)s')\n", |
||||
"```\n", |
||||
"\n", |
||||
"Say you wrote a function to calculate the factorial of a number. In mathematics, factorial 4 is 1 × 2 × 3 × 4, or 24. Factorial 7 is 1 × 2 × 3 × 4 × 5 × 6 × 7, or 5,040. Open a new file editor window and enter the following code. It has a bug in it, but you will also enter several log messages to help yourself figure out what is going wrong. Save the program as factorialLog.py.\n", |
||||
"\n", |
||||
"```python\n", |
||||
">>> import logging\n", |
||||
">>> logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s - %(levelname)s- %(message)s')\n", |
||||
">>> logging.debug('Start of program')\n", |
||||
"\n", |
||||
">>> def factorial(n):\n", |
||||
"... logging.debug('Start of factorial(%s)' % (n))\n", |
||||
"... total = 1\n", |
||||
"... for i in range(1, n + 1):\n", |
||||
"... total *= i\n", |
||||
"... logging.debug('i is ' + str(i) + ', total is ' + str(total))\n", |
||||
"... logging.debug('End of factorial(%s)' % (n))\n", |
||||
"... return total\n", |
||||
"...\n", |
||||
">>> print(factorial(5))\n", |
||||
">>> logging.debug('End of program')\n", |
||||
"# 2015-05-23 16:20:12,664 - DEBUG - Start of program\n", |
||||
"# 2015-05-23 16:20:12,664 - DEBUG - Start of factorial(5)\n", |
||||
"# 2015-05-23 16:20:12,665 - DEBUG - i is 0, total is 0\n", |
||||
"# 2015-05-23 16:20:12,668 - DEBUG - i is 1, total is 0\n", |
||||
"# 2015-05-23 16:20:12,670 - DEBUG - i is 2, total is 0\n", |
||||
"# 2015-05-23 16:20:12,673 - DEBUG - i is 3, total is 0\n", |
||||
"# 2015-05-23 16:20:12,675 - DEBUG - i is 4, total is 0\n", |
||||
"# 2015-05-23 16:20:12,678 - DEBUG - i is 5, total is 0\n", |
||||
"# 2015-05-23 16:20:12,680 - DEBUG - End of factorial(5)\n", |
||||
"# 0\n", |
||||
"# 2015-05-23 16:20:12,684 - DEBUG - End of program\n", |
||||
"```\n", |
||||
"\n", |
||||
"## Logging Levels\n", |
||||
"\n", |
||||
"Logging levels provide a way to categorize your log messages by importance. There are five logging levels, described in Table 10-1 from least to most important. Messages can be logged at each level using a different logging function.\n", |
||||
"\n", |
||||
"| Level | Logging Function | Description |\n", |
||||
"| ---------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------ |\n", |
||||
"| `DEBUG` | `logging.debug()` | The lowest level. Used for small details. Usually you care about these messages only when diagnosing problems. |\n", |
||||
"| `INFO` | `logging.info()` | Used to record information on general events in your program or confirm that things are working at their point in the program. |\n", |
||||
"| `WARNING` | `logging.warning()` | Used to indicate a potential problem that doesn’t prevent the program from working but might do so in the future. |\n", |
||||
"| `ERROR` | `logging.error()` | Used to record an error that caused the program to fail to do something. |\n", |
||||
"| `CRITICAL` | `logging.critical()` | The highest level. Used to indicate a fatal error that has caused or is about to cause the program to stop running entirely. |\n", |
||||
"\n", |
||||
"## Disabling Logging\n", |
||||
"\n", |
||||
"After you’ve debugged your program, you probably don’t want all these log messages cluttering the screen. The logging.disable() function disables these so that you don’t have to go into your program and remove all the logging calls by hand.\n", |
||||
"\n", |
||||
"```python\n", |
||||
">>> import logging\n", |
||||
"\n", |
||||
">>> logging.basicConfig(level=logging.INFO, format=' %(asctime)s -%(levelname)s - %(message)s')\n", |
||||
">>> logging.critical('Critical error! Critical error!')\n", |
||||
"# 2015-05-22 11:10:48,054 - CRITICAL - Critical error! Critical error!\n", |
||||
"\n", |
||||
">>> logging.disable(logging.CRITICAL)\n", |
||||
">>> logging.critical('Critical error! Critical error!')\n", |
||||
">>> logging.error('Error! Error!')\n", |
||||
"```\n", |
||||
"\n", |
||||
"## Logging to a File\n", |
||||
"\n", |
||||
"Instead of displaying the log messages to the screen, you can write them to a text file. The `logging.basicConfig()` function takes a filename keyword argument, like so:\n", |
||||
"\n", |
||||
"```python\n", |
||||
">>> import logging\n", |
||||
">>> logging.basicConfig(filename='myProgramLog.txt', level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')\n", |
||||
"```\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"# for page in Path('../temp/python-cheatsheets/' + chapter).iterdir():\n", |
||||
"page = '../temp/python-cheatsheets/cheatsheet/debugging.md'\n", |
||||
"url = \"https://donavanaldrich.com/api/bookstack/pages\"\n", |
||||
"\n", |
||||
"with open(page, 'r') as f:\n", |
||||
" # text = f.read()\n", |
||||
" # post = frontmatter.load(page)\n", |
||||
" metadata, content = frontmatter.parse(f.read())\n", |
||||
"print(content)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "markdown", |
||||
"metadata": {}, |
||||
"source": [ |
||||
"## Reference\n", |
||||
"\n", |
||||
"### Payloads\n", |
||||
"\n", |
||||
"#### book\n", |
||||
"\n", |
||||
"```json\n", |
||||
"{\n", |
||||
" \"name\": \"python-cheatsheet\",\n", |
||||
" \"description\": \"python-cheatsheet\",\n", |
||||
" \"tags\": [\n", |
||||
" { \"name\": \"Platform\", \"value\": \"Python\" },\n", |
||||
" { \"name\": \"Category\", \"value\": \"Code\" },\n", |
||||
" { \"name\": \"Type\", \"value\": \"Cheatsheet\" }\n", |
||||
" ]\n", |
||||
"}\n", |
||||
"```\n", |
||||
"\n", |
||||
"#### Chapter\n", |
||||
"\n", |
||||
"```json\n", |
||||
"{\n", |
||||
" \"book_id\": 1,\n", |
||||
" \"name\": \"My fantastic new chapter\",\n", |
||||
" \"description\": \"This is a great new chapter that I've created via the API\",\n", |
||||
" \"tags\": [\n", |
||||
" { \"name\": \"Category\", \"value\": \"Top Content\" },\n", |
||||
" { \"name\": \"Rating\", \"value\": \"Highest\" }\n", |
||||
" ]\n", |
||||
"}\n", |
||||
"```\n", |
||||
"\n", |
||||
"#### Page\n", |
||||
"\n", |
||||
"```json\n", |
||||
"{\n", |
||||
" \"book_id\": 1,\n", |
||||
" \"name\": \"My API Page\",\n", |
||||
" \"markdown\": \"<p>my new API page</p>\",\n", |
||||
" \"tags\": [\n", |
||||
" { \"name\": \"Category\", \"value\": \"Not Bad Content\" },\n", |
||||
" { \"name\": \"Rating\", \"value\": \"Average\" }\n", |
||||
" ]\n", |
||||
"}\n", |
||||
"```\n" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 12, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"ename": "AttributeError", |
||||
"evalue": "module 'frontmatter' has no attribute 'load'", |
||||
"output_type": "error", |
||||
"traceback": [ |
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
||||
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", |
||||
"\u001b[1;32m/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb Cell 19\u001b[0m in \u001b[0;36m<cell line: 13>\u001b[0;34m()\u001b[0m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X23sdnNjb2RlLXJlbW90ZQ%3D%3D?line=5'>6</a>\u001b[0m file_parts \u001b[39m=\u001b[39m frontmatter\u001b[39m.\u001b[39mload(filepath)\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X23sdnNjb2RlLXJlbW90ZQ%3D%3D?line=7'>8</a>\u001b[0m \u001b[39mreturn\u001b[39;00m {\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X23sdnNjb2RlLXJlbW90ZQ%3D%3D?line=8'>9</a>\u001b[0m \u001b[39m# 'html': markdown_parser.convert(file_parts.content),\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X23sdnNjb2RlLXJlbW90ZQ%3D%3D?line=9'>10</a>\u001b[0m \u001b[39m'\u001b[39m\u001b[39mmetadata\u001b[39m\u001b[39m'\u001b[39m: file_parts\u001b[39m.\u001b[39mmetadata\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X23sdnNjb2RlLXJlbW90ZQ%3D%3D?line=10'>11</a>\u001b[0m }\n\u001b[0;32m---> <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X23sdnNjb2RlLXJlbW90ZQ%3D%3D?line=12'>13</a>\u001b[0m parse_markdown(\u001b[39m'\u001b[39;49m\u001b[39m../temp/python-cheatsheets/cheatsheet/debugging.md\u001b[39;49m\u001b[39m'\u001b[39;49m)\n", |
||||
"\u001b[1;32m/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb Cell 19\u001b[0m in \u001b[0;36mparse_markdown\u001b[0;34m(filepath)\u001b[0m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X23sdnNjb2RlLXJlbW90ZQ%3D%3D?line=3'>4</a>\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mparse_markdown\u001b[39m(filepath):\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X23sdnNjb2RlLXJlbW90ZQ%3D%3D?line=4'>5</a>\u001b[0m \u001b[39m# markdown_parser = markdown.Markdown(extensions=markdown_extensions)\u001b[39;00m\n\u001b[0;32m----> <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X23sdnNjb2RlLXJlbW90ZQ%3D%3D?line=5'>6</a>\u001b[0m file_parts \u001b[39m=\u001b[39m frontmatter\u001b[39m.\u001b[39;49mload(filepath)\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X23sdnNjb2RlLXJlbW90ZQ%3D%3D?line=7'>8</a>\u001b[0m \u001b[39mreturn\u001b[39;00m {\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X23sdnNjb2RlLXJlbW90ZQ%3D%3D?line=8'>9</a>\u001b[0m \u001b[39m# 'html': markdown_parser.convert(file_parts.content),\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X23sdnNjb2RlLXJlbW90ZQ%3D%3D?line=9'>10</a>\u001b[0m \u001b[39m'\u001b[39m\u001b[39mmetadata\u001b[39m\u001b[39m'\u001b[39m: file_parts\u001b[39m.\u001b[39mmetadata\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwebserver/home/donaldrich/projects/secrets/jupyter-notebooks/documentation/python-cheatsheet.ipynb#X23sdnNjb2RlLXJlbW90ZQ%3D%3D?line=10'>11</a>\u001b[0m }\n", |
||||
"\u001b[0;31mAttributeError\u001b[0m: module 'frontmatter' has no attribute 'load'" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"import frontmatter # https://pypi.org/project/python-frontmatter/\n", |
||||
"import markdown\n", |
||||
"\n", |
||||
"\n", |
||||
"def parse_markdown(filepath):\n", |
||||
" # markdown_parser = markdown.Markdown(extensions=markdown_extensions)\n", |
||||
" file_parts = frontmatter.load(filepath)\n", |
||||
"\n", |
||||
" return {\n", |
||||
" # 'html': markdown_parser.convert(file_parts.content),\n", |
||||
" 'metadata': file_parts.metadata\n", |
||||
" }\n", |
||||
"\n", |
||||
"\n", |
||||
"parse_markdown('../temp/python-cheatsheets/cheatsheet/debugging.md')" |
||||
] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3.8.9 64-bit", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.10.4" |
||||
}, |
||||
"orig_nbformat": 4, |
||||
"vscode": { |
||||
"interpreter": { |
||||
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" |
||||
} |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 2 |
||||
} |
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,335 @@ |
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 1, |
||||
"id": "ada14109", |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"hello world\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"print(\"hello world\")" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 17, |
||||
"id": "aaa46c91", |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"\u001b[1;31mE: \u001b[0mCould not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)\u001b[0m\n", |
||||
"\u001b[1;31mE: \u001b[0mUnable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?\u001b[0m\n", |
||||
"/bin/bash: ping: command not found\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"!apt install nettools\n", |
||||
"\n", |
||||
"!ping tcp://mongo -p 27017" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 22, |
||||
"id": "874ee20a", |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"data": { |
||||
"text/html": [ |
||||
"<!DOCTYPE html>\n", |
||||
"<!-- Important: must specify -->\n", |
||||
"<html>\n", |
||||
" <head>\n", |
||||
" <meta charset=\"utf-8\" />\n", |
||||
" <!-- Important: rapi-doc uses utf8 characters -->\n", |
||||
" <script\n", |
||||
" type=\"module\"\n", |
||||
" src=\"https://unpkg.com/rapidoc/dist/rapidoc-min.js\"\n", |
||||
" ></script>\n", |
||||
" </head>\n", |
||||
" <body>\n", |
||||
" <rapi-doc-mini\n", |
||||
" style=\"min-width: 600px; border: 1px solid #eee; border-top-width: 0\"\n", |
||||
" spec-url=\"https://donavanaldrich.com/api/openapi.yaml\"\n", |
||||
" theme=\"dark\"\n", |
||||
" paths-expanded=\"false\"\n", |
||||
" match-paths=\"get /bookstack/pages\"\n", |
||||
" >\n", |
||||
" </rapi-doc-mini>\n", |
||||
" <!-- <rapi-doc spec-url = \"https://petstore.swagger.io/v2/swagger.json\"> </rapi-doc> -->\n", |
||||
" </body>\n", |
||||
"</html>\n", |
||||
"<!-- match-paths=\"^get /bookstack$|^post /bookstack$\"\n", |
||||
"match-type=\"regex\" -->" |
||||
], |
||||
"text/plain": [ |
||||
"<IPython.core.display.HTML object>" |
||||
] |
||||
}, |
||||
"metadata": {}, |
||||
"output_type": "display_data" |
||||
} |
||||
], |
||||
"source": [ |
||||
"from IPython.display import HTML\n", |
||||
"s = \"\"\"<!DOCTYPE html>\n", |
||||
"<!-- Important: must specify -->\n", |
||||
"<html>\n", |
||||
" <head>\n", |
||||
" <meta charset=\"utf-8\" />\n", |
||||
" <!-- Important: rapi-doc uses utf8 characters -->\n", |
||||
" <script\n", |
||||
" type=\"module\"\n", |
||||
" src=\"https://unpkg.com/rapidoc/dist/rapidoc-min.js\"\n", |
||||
" ></script>\n", |
||||
" </head>\n", |
||||
" <body>\n", |
||||
" <rapi-doc-mini\n", |
||||
" style=\"min-width: 600px; border: 1px solid #eee; border-top-width: 0\"\n", |
||||
" spec-url=\"https://donavanaldrich.com/api/openapi.yaml\"\n", |
||||
" theme=\"dark\"\n", |
||||
" paths-expanded=\"false\"\n", |
||||
" match-paths=\"get /bookstack/pages\"\n", |
||||
" >\n", |
||||
" </rapi-doc-mini>\n", |
||||
" <!-- <rapi-doc spec-url = \"https://petstore.swagger.io/v2/swagger.json\"> </rapi-doc> -->\n", |
||||
" </body>\n", |
||||
"</html>\n", |
||||
"<!-- match-paths=\"^get /bookstack$|^post /bookstack$\"\n", |
||||
"match-type=\"regex\" -->\"\"\"\n", |
||||
"h = HTML(s)\n", |
||||
"display(h)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "71b6f2d3", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 23, |
||||
"id": "f20b51c5", |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"data": { |
||||
"text/html": [ |
||||
"<!DOCTYPE html>\n", |
||||
"<!-- Important: must specify -->\n", |
||||
"<html>\n", |
||||
" <head>\n", |
||||
" <meta charset=\"utf-8\" />\n", |
||||
" <!-- Important: rapi-doc uses utf8 characters -->\n", |
||||
" <script\n", |
||||
" type=\"module\"\n", |
||||
" src=\"https://unpkg.com/rapidoc/dist/rapidoc-min.js\"\n", |
||||
" ></script>\n", |
||||
" </head>\n", |
||||
" <body>\n", |
||||
" <rapi-doc spec-url = \"https://donavanaldrich.com/api/openapi.yaml\"> </rapi-doc>\n", |
||||
" </body>\n", |
||||
"</html>" |
||||
], |
||||
"text/plain": [ |
||||
"<IPython.core.display.HTML object>" |
||||
] |
||||
}, |
||||
"metadata": {}, |
||||
"output_type": "display_data" |
||||
} |
||||
], |
||||
"source": [ |
||||
"from IPython.display import HTML\n", |
||||
"s = \"\"\"<!DOCTYPE html>\n", |
||||
"<!-- Important: must specify -->\n", |
||||
"<html>\n", |
||||
" <head>\n", |
||||
" <meta charset=\"utf-8\" />\n", |
||||
" <!-- Important: rapi-doc uses utf8 characters -->\n", |
||||
" <script\n", |
||||
" type=\"module\"\n", |
||||
" src=\"https://unpkg.com/rapidoc/dist/rapidoc-min.js\"\n", |
||||
" ></script>\n", |
||||
" </head>\n", |
||||
" <body>\n", |
||||
" <rapi-doc spec-url = \"https://donavanaldrich.com/api/openapi.yaml\"> </rapi-doc>\n", |
||||
" </body>\n", |
||||
"</html>\"\"\"\n", |
||||
"h = HTML(s)\n", |
||||
"display(h)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 24, |
||||
"id": "ab67d0f4", |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stderr", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"IOPub data rate exceeded.\n", |
||||
"The Jupyter server will temporarily stop sending output\n", |
||||
"to the client in order to avoid crashing it.\n", |
||||
"To change this limit, set the config variable\n", |
||||
"`--ServerApp.iopub_data_rate_limit`.\n", |
||||
"\n", |
||||
"Current values:\n", |
||||
"ServerApp.iopub_data_rate_limit=1000000.0 (bytes/sec)\n", |
||||
"ServerApp.rate_limit_window=3.0 (secs)\n", |
||||
"\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"import requests\n", |
||||
"\n", |
||||
"url = \"https://donavanaldrich.com/api/metrics/netdata/charts\"\n", |
||||
"\n", |
||||
"response = requests.request(\"GET\", url)\n", |
||||
"\n", |
||||
"print(response.text)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 25, |
||||
"id": "3735aab4", |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"{'id': 'system.cpu', 'name': 'system.cpu', 'type': 'system', 'family': 'cpu', 'context': 'system.cpu', 'title': 'Total CPU utilization (system.cpu)', 'priority': 100, 'plugin': 'proc.plugin', 'module': '/proc/stat', 'units': 'percentage', 'data_url': '/api/v1/data?chart=system.cpu', 'chart_type': 'stacked', 'duration': 478780, 'first_entry': 1662087080, 'last_entry': 1662565840, 'update_every': 20, 'dimensions': {'guest_nice': {'name': 'guest_nice'}, 'guest': {'name': 'guest'}, 'steal': {'name': 'steal'}, 'softirq': {'name': 'softirq'}, 'irq': {'name': 'irq'}, 'user': {'name': 'user'}, 'system': {'name': 'system'}, 'nice': {'name': 'nice'}, 'iowait': {'name': 'iowait'}}, 'chart_variables': {}, 'green': None, 'red': None, 'alarms': {'20min_steal_cpu': {'id': 1662512394, 'status': 'CLEAR', 'units': '%', 'update_every': 300}, '10min_cpu_iowait': {'id': 1662512393, 'status': 'CLEAR', 'units': '%', 'update_every': 60}, '10min_cpu_usage': {'id': 1662512392, 'status': 'CLEAR', 'units': '%', 'update_every': 60}}, 'chart_labels': {'_collect_plugin': 'proc.plugin', '_collect_module': '/proc/stat', '_instance_family': 'cpu'}}\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"import requests\n", |
||||
"\n", |
||||
"url = \"https://donavanaldrich.com/api/metrics/netdata/chart\"\n", |
||||
"\n", |
||||
"querystring = {\"chart\":\"system.cpu\"}\n", |
||||
"\n", |
||||
"response = requests.request(\"GET\", url, params=querystring)\n", |
||||
"\n", |
||||
"print(response.json())\n", |
||||
"\n", |
||||
"mydict = response.json()" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 21, |
||||
"id": "c547fcb0", |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"ename": "OperationFailure", |
||||
"evalue": "Authentication failed., full error: {'ok': 0.0, 'errmsg': 'Authentication failed.', 'code': 18, 'codeName': 'AuthenticationFailed'}", |
||||
"output_type": "error", |
||||
"traceback": [ |
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
||||
"\u001b[0;31mOperationFailure\u001b[0m Traceback (most recent call last)", |
||||
"Input \u001b[0;32mIn [21]\u001b[0m, in \u001b[0;36m<cell line: 14>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 10\u001b[0m mycol \u001b[38;5;241m=\u001b[39m mydb[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mnetdata\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n\u001b[1;32m 12\u001b[0m mydict \u001b[38;5;241m=\u001b[39m { \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mname\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mPeter\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124maddress\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mLowstreet 27\u001b[39m\u001b[38;5;124m\"\u001b[39m }\n\u001b[0;32m---> 14\u001b[0m x \u001b[38;5;241m=\u001b[39m \u001b[43mmycol\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43minsert_one\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmydict\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 16\u001b[0m \u001b[38;5;28mprint\u001b[39m(x\u001b[38;5;241m.\u001b[39minserted_id)\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/pymongo/collection.py:621\u001b[0m, in \u001b[0;36mCollection.insert_one\u001b[0;34m(self, document, bypass_document_validation, session, comment)\u001b[0m\n\u001b[1;32m 617\u001b[0m document[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m_id\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m ObjectId()\n\u001b[1;32m 619\u001b[0m write_concern \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_write_concern_for(session)\n\u001b[1;32m 620\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m InsertOneResult(\n\u001b[0;32m--> 621\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_insert_one\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 622\u001b[0m \u001b[43m \u001b[49m\u001b[43mdocument\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 623\u001b[0m \u001b[43m \u001b[49m\u001b[43mordered\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 624\u001b[0m \u001b[43m \u001b[49m\u001b[43mwrite_concern\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mwrite_concern\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 625\u001b[0m \u001b[43m \u001b[49m\u001b[43mop_id\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 626\u001b[0m \u001b[43m \u001b[49m\u001b[43mbypass_doc_val\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mbypass_document_validation\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 627\u001b[0m \u001b[43m \u001b[49m\u001b[43msession\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43msession\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 628\u001b[0m \u001b[43m \u001b[49m\u001b[43mcomment\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcomment\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 629\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m,\n\u001b[1;32m 630\u001b[0m write_concern\u001b[38;5;241m.\u001b[39macknowledged,\n\u001b[1;32m 631\u001b[0m )\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/pymongo/collection.py:562\u001b[0m, in \u001b[0;36mCollection._insert_one\u001b[0;34m(self, doc, ordered, write_concern, op_id, bypass_doc_val, session, comment)\u001b[0m\n\u001b[1;32m 550\u001b[0m result \u001b[38;5;241m=\u001b[39m sock_info\u001b[38;5;241m.\u001b[39mcommand(\n\u001b[1;32m 551\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m__database\u001b[38;5;241m.\u001b[39mname,\n\u001b[1;32m 552\u001b[0m command,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 557\u001b[0m retryable_write\u001b[38;5;241m=\u001b[39mretryable_write,\n\u001b[1;32m 558\u001b[0m )\n\u001b[1;32m 560\u001b[0m _check_write_command_response(result)\n\u001b[0;32m--> 562\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m__database\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mclient\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_retryable_write\u001b[49m\u001b[43m(\u001b[49m\u001b[43macknowledged\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m_insert_command\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msession\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 564\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(doc, RawBSONDocument):\n\u001b[1;32m 565\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m doc\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m_id\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/pymongo/mongo_client.py:1448\u001b[0m, in \u001b[0;36mMongoClient._retryable_write\u001b[0;34m(self, retryable, func, session)\u001b[0m\n\u001b[1;32m 1446\u001b[0m \u001b[38;5;124;03m\"\"\"Internal retryable write helper.\"\"\"\u001b[39;00m\n\u001b[1;32m 1447\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_tmp_session(session) \u001b[38;5;28;01mas\u001b[39;00m s:\n\u001b[0;32m-> 1448\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_retry_with_session\u001b[49m\u001b[43m(\u001b[49m\u001b[43mretryable\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfunc\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43ms\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m)\u001b[49m\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/pymongo/mongo_client.py:1321\u001b[0m, in \u001b[0;36mMongoClient._retry_with_session\u001b[0;34m(self, retryable, func, session, bulk)\u001b[0m\n\u001b[1;32m 1311\u001b[0m \u001b[38;5;124;03m\"\"\"Execute an operation with at most one consecutive retries\u001b[39;00m\n\u001b[1;32m 1312\u001b[0m \n\u001b[1;32m 1313\u001b[0m \u001b[38;5;124;03mReturns func()'s return value on success. On error retries the same\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 1316\u001b[0m \u001b[38;5;124;03mRe-raises any exception thrown by func().\u001b[39;00m\n\u001b[1;32m 1317\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 1318\u001b[0m retryable \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 1319\u001b[0m retryable \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39moptions\u001b[38;5;241m.\u001b[39mretry_writes \u001b[38;5;129;01mand\u001b[39;00m session \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m session\u001b[38;5;241m.\u001b[39min_transaction\n\u001b[1;32m 1320\u001b[0m )\n\u001b[0;32m-> 1321\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_retry_internal\u001b[49m\u001b[43m(\u001b[49m\u001b[43mretryable\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfunc\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msession\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mbulk\u001b[49m\u001b[43m)\u001b[49m\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/pymongo/_csot.py:105\u001b[0m, in \u001b[0;36mapply.<locals>.csot_wrapper\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 103\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m _TimeoutContext(timeout):\n\u001b[1;32m 104\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m func(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[0;32m--> 105\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/pymongo/mongo_client.py:1353\u001b[0m, in \u001b[0;36mMongoClient._retry_internal\u001b[0;34m(self, retryable, func, session, bulk)\u001b[0m\n\u001b[1;32m 1349\u001b[0m server \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_select_server(writable_server_selector, session)\n\u001b[1;32m 1350\u001b[0m supports_session \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 1351\u001b[0m session \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m server\u001b[38;5;241m.\u001b[39mdescription\u001b[38;5;241m.\u001b[39mretryable_writes_supported\n\u001b[1;32m 1352\u001b[0m )\n\u001b[0;32m-> 1353\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_get_socket(server, session) \u001b[38;5;28;01mas\u001b[39;00m sock_info:\n\u001b[1;32m 1354\u001b[0m max_wire_version \u001b[38;5;241m=\u001b[39m sock_info\u001b[38;5;241m.\u001b[39mmax_wire_version\n\u001b[1;32m 1355\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m retryable \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m supports_session:\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.10/contextlib.py:135\u001b[0m, in \u001b[0;36m_GeneratorContextManager.__enter__\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 133\u001b[0m \u001b[38;5;28;01mdel\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39margs, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mkwds, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfunc\n\u001b[1;32m 134\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 135\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mnext\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mgen\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 136\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mStopIteration\u001b[39;00m:\n\u001b[1;32m 137\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mRuntimeError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mgenerator didn\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mt yield\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;28mNone\u001b[39m\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/pymongo/mongo_client.py:1189\u001b[0m, in \u001b[0;36mMongoClient._get_socket\u001b[0;34m(self, server, session)\u001b[0m\n\u001b[1;32m 1187\u001b[0m \u001b[38;5;28;01myield\u001b[39;00m session\u001b[38;5;241m.\u001b[39m_pinned_connection\n\u001b[1;32m 1188\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m\n\u001b[0;32m-> 1189\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m server\u001b[38;5;241m.\u001b[39mget_socket(handler\u001b[38;5;241m=\u001b[39merr_handler) \u001b[38;5;28;01mas\u001b[39;00m sock_info:\n\u001b[1;32m 1190\u001b[0m \u001b[38;5;66;03m# Pin this session to the selected server or connection.\u001b[39;00m\n\u001b[1;32m 1191\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m in_txn \u001b[38;5;129;01mand\u001b[39;00m server\u001b[38;5;241m.\u001b[39mdescription\u001b[38;5;241m.\u001b[39mserver_type \u001b[38;5;129;01min\u001b[39;00m (\n\u001b[1;32m 1192\u001b[0m SERVER_TYPE\u001b[38;5;241m.\u001b[39mMongos,\n\u001b[1;32m 1193\u001b[0m SERVER_TYPE\u001b[38;5;241m.\u001b[39mLoadBalancer,\n\u001b[1;32m 1194\u001b[0m ):\n\u001b[1;32m 1195\u001b[0m session\u001b[38;5;241m.\u001b[39m_pin(server, sock_info)\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.10/contextlib.py:135\u001b[0m, in \u001b[0;36m_GeneratorContextManager.__enter__\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 133\u001b[0m \u001b[38;5;28;01mdel\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39margs, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mkwds, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfunc\n\u001b[1;32m 134\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 135\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mnext\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mgen\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 136\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mStopIteration\u001b[39;00m:\n\u001b[1;32m 137\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mRuntimeError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mgenerator didn\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mt yield\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;28mNone\u001b[39m\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/pymongo/pool.py:1406\u001b[0m, in \u001b[0;36mPool.get_socket\u001b[0;34m(self, handler)\u001b[0m\n\u001b[1;32m 1403\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39menabled_for_cmap:\n\u001b[1;32m 1404\u001b[0m listeners\u001b[38;5;241m.\u001b[39mpublish_connection_check_out_started(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39maddress)\n\u001b[0;32m-> 1406\u001b[0m sock_info \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_get_socket\u001b[49m\u001b[43m(\u001b[49m\u001b[43mhandler\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mhandler\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1408\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39menabled_for_cmap:\n\u001b[1;32m 1409\u001b[0m listeners\u001b[38;5;241m.\u001b[39mpublish_connection_checked_out(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39maddress, sock_info\u001b[38;5;241m.\u001b[39mid)\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/pymongo/pool.py:1519\u001b[0m, in \u001b[0;36mPool._get_socket\u001b[0;34m(self, handler)\u001b[0m\n\u001b[1;32m 1517\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m: \u001b[38;5;66;03m# We need to create a new connection\u001b[39;00m\n\u001b[1;32m 1518\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m-> 1519\u001b[0m sock_info \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mconnect\u001b[49m\u001b[43m(\u001b[49m\u001b[43mhandler\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mhandler\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1520\u001b[0m \u001b[38;5;28;01mfinally\u001b[39;00m:\n\u001b[1;32m 1521\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_max_connecting_cond:\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/pymongo/pool.py:1377\u001b[0m, in \u001b[0;36mPool.connect\u001b[0;34m(self, handler)\u001b[0m\n\u001b[1;32m 1374\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m handler:\n\u001b[1;32m 1375\u001b[0m handler\u001b[38;5;241m.\u001b[39mcontribute_socket(sock_info, completed_handshake\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m)\n\u001b[0;32m-> 1377\u001b[0m \u001b[43msock_info\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mauthenticate\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1378\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mBaseException\u001b[39;00m:\n\u001b[1;32m 1379\u001b[0m sock_info\u001b[38;5;241m.\u001b[39mclose_socket(ConnectionClosedReason\u001b[38;5;241m.\u001b[39mERROR)\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/pymongo/pool.py:869\u001b[0m, in \u001b[0;36mSocketInfo.authenticate\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 867\u001b[0m creds \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mopts\u001b[38;5;241m.\u001b[39m_credentials\n\u001b[1;32m 868\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m creds:\n\u001b[0;32m--> 869\u001b[0m \u001b[43mauth\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mauthenticate\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcreds\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 870\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mready \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[1;32m 871\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39menabled_for_cmap:\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/pymongo/auth.py:549\u001b[0m, in \u001b[0;36mauthenticate\u001b[0;34m(credentials, sock_info)\u001b[0m\n\u001b[1;32m 547\u001b[0m mechanism \u001b[38;5;241m=\u001b[39m credentials\u001b[38;5;241m.\u001b[39mmechanism\n\u001b[1;32m 548\u001b[0m auth_func \u001b[38;5;241m=\u001b[39m _AUTH_MAP[mechanism]\n\u001b[0;32m--> 549\u001b[0m \u001b[43mauth_func\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcredentials\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msock_info\u001b[49m\u001b[43m)\u001b[49m\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/pymongo/auth.py:475\u001b[0m, in \u001b[0;36m_authenticate_default\u001b[0;34m(credentials, sock_info)\u001b[0m\n\u001b[1;32m 473\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m _authenticate_scram(credentials, sock_info, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSCRAM-SHA-256\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 474\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 475\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_authenticate_scram\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcredentials\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msock_info\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mSCRAM-SHA-1\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 476\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 477\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m _authenticate_scram(credentials, sock_info, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSCRAM-SHA-1\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/pymongo/auth.py:201\u001b[0m, in \u001b[0;36m_authenticate_scram\u001b[0;34m(credentials, sock_info, mechanism)\u001b[0m\n\u001b[1;32m 199\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 200\u001b[0m nonce, first_bare, cmd \u001b[38;5;241m=\u001b[39m _authenticate_scram_start(credentials, mechanism)\n\u001b[0;32m--> 201\u001b[0m res \u001b[38;5;241m=\u001b[39m \u001b[43msock_info\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcommand\u001b[49m\u001b[43m(\u001b[49m\u001b[43msource\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcmd\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 203\u001b[0m server_first \u001b[38;5;241m=\u001b[39m res[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mpayload\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n\u001b[1;32m 204\u001b[0m parsed \u001b[38;5;241m=\u001b[39m _parse_scram_response(server_first)\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/pymongo/pool.py:766\u001b[0m, in \u001b[0;36mSocketInfo.command\u001b[0;34m(self, dbname, spec, read_preference, codec_options, check, allowable_errors, read_concern, write_concern, parse_write_concern_error, collation, session, client, retryable_write, publish_events, user_fields, exhaust_allowed)\u001b[0m\n\u001b[1;32m 764\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_raise_if_not_writable(unacknowledged)\n\u001b[1;32m 765\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 766\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mcommand\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 767\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 768\u001b[0m \u001b[43m \u001b[49m\u001b[43mdbname\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 769\u001b[0m \u001b[43m \u001b[49m\u001b[43mspec\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 770\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mis_mongos\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 771\u001b[0m \u001b[43m \u001b[49m\u001b[43mread_preference\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 772\u001b[0m \u001b[43m \u001b[49m\u001b[43mcodec_options\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 773\u001b[0m \u001b[43m \u001b[49m\u001b[43msession\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 774\u001b[0m \u001b[43m \u001b[49m\u001b[43mclient\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 775\u001b[0m \u001b[43m \u001b[49m\u001b[43mcheck\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 776\u001b[0m \u001b[43m \u001b[49m\u001b[43mallowable_errors\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 777\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43maddress\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 778\u001b[0m \u001b[43m \u001b[49m\u001b[43mlisteners\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 779\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmax_bson_size\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 780\u001b[0m \u001b[43m \u001b[49m\u001b[43mread_concern\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 781\u001b[0m \u001b[43m \u001b[49m\u001b[43mparse_write_concern_error\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mparse_write_concern_error\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 782\u001b[0m \u001b[43m \u001b[49m\u001b[43mcollation\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcollation\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 783\u001b[0m \u001b[43m \u001b[49m\u001b[43mcompression_ctx\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcompression_context\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 784\u001b[0m \u001b[43m \u001b[49m\u001b[43muse_op_msg\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mop_msg_enabled\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 785\u001b[0m \u001b[43m \u001b[49m\u001b[43munacknowledged\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43munacknowledged\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 786\u001b[0m \u001b[43m \u001b[49m\u001b[43muser_fields\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43muser_fields\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 787\u001b[0m \u001b[43m \u001b[49m\u001b[43mexhaust_allowed\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mexhaust_allowed\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 788\u001b[0m \u001b[43m \u001b[49m\u001b[43mwrite_concern\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mwrite_concern\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 789\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 790\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m (OperationFailure, NotPrimaryError):\n\u001b[1;32m 791\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/pymongo/network.py:166\u001b[0m, in \u001b[0;36mcommand\u001b[0;34m(sock_info, dbname, spec, is_mongos, read_preference, codec_options, session, client, check, allowable_errors, address, listeners, max_bson_size, read_concern, parse_write_concern_error, collation, compression_ctx, use_op_msg, unacknowledged, user_fields, exhaust_allowed, write_concern)\u001b[0m\n\u001b[1;32m 164\u001b[0m client\u001b[38;5;241m.\u001b[39m_process_response(response_doc, session)\n\u001b[1;32m 165\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m check:\n\u001b[0;32m--> 166\u001b[0m \u001b[43mhelpers\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_check_command_response\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 167\u001b[0m \u001b[43m \u001b[49m\u001b[43mresponse_doc\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 168\u001b[0m \u001b[43m \u001b[49m\u001b[43msock_info\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmax_wire_version\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 169\u001b[0m \u001b[43m \u001b[49m\u001b[43mallowable_errors\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 170\u001b[0m \u001b[43m \u001b[49m\u001b[43mparse_write_concern_error\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mparse_write_concern_error\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 171\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 172\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m exc:\n\u001b[1;32m 173\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m publish:\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/pymongo/helpers.py:181\u001b[0m, in \u001b[0;36m_check_command_response\u001b[0;34m(response, max_wire_version, allowable_errors, parse_write_concern_error)\u001b[0m\n\u001b[1;32m 178\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m code \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m43\u001b[39m:\n\u001b[1;32m 179\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m CursorNotFound(errmsg, code, response, max_wire_version)\n\u001b[0;32m--> 181\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m OperationFailure(errmsg, code, response, max_wire_version)\n", |
||||
"\u001b[0;31mOperationFailure\u001b[0m: Authentication failed., full error: {'ok': 0.0, 'errmsg': 'Authentication failed.', 'code': 18, 'codeName': 'AuthenticationFailed'}" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"import pymongo\n", |
||||
"\n", |
||||
"myclient = pymongo.MongoClient(\"mongodb://user:password@192.168.1.101:27017\")\n", |
||||
"# DB\n", |
||||
"\n", |
||||
"mydb = myclient[\"dev\"]\n", |
||||
"\n", |
||||
"# Collectino\n", |
||||
"\n", |
||||
"mycol = mydb[\"netdata\"]\n", |
||||
"\n", |
||||
"mydict = { \"name\": \"Peter\", \"address\": \"Lowstreet 27\" }\n", |
||||
"\n", |
||||
"x = mycol.insert_one(mydict)\n", |
||||
"\n", |
||||
"print(x.inserted_id)\n", |
||||
"\n", |
||||
"# print(mydb.list_collection_names())" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "ceedf6f6", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3 (ipykernel)", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.10.6" |
||||
}, |
||||
"widgets": { |
||||
"application/vnd.jupyter.widget-state+json": { |
||||
"state": {}, |
||||
"version_major": 2, |
||||
"version_minor": 0 |
||||
} |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 5 |
||||
} |
||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,126 @@ |
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 1, |
||||
"id": "4b1a1586-0823-4046-ab19-0fa99a0f241b", |
||||
"metadata": { |
||||
"scrolled": true, |
||||
"tags": [] |
||||
}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"Defaulting to user installation because normal site-packages is not writeable\n", |
||||
"Collecting spacy\n", |
||||
" Downloading spacy-3.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.4 MB)\n", |
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m6.4/6.4 MB\u001b[0m \u001b[31m15.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", |
||||
"\u001b[?25hCollecting thinc<8.2.0,>=8.1.0\n", |
||||
" Downloading thinc-8.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (822 kB)\n", |
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m822.5/822.5 KB\u001b[0m \u001b[31m10.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m\n", |
||||
"\u001b[?25hCollecting cymem<2.1.0,>=2.0.2\n", |
||||
" Using cached cymem-2.0.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (35 kB)\n", |
||||
"Requirement already satisfied: requests<3.0.0,>=2.13.0 in /usr/lib/python3/dist-packages (from spacy) (2.25.1)\n", |
||||
"Collecting wasabi<1.1.0,>=0.9.1\n", |
||||
" Downloading wasabi-0.10.1-py3-none-any.whl (26 kB)\n", |
||||
"Requirement already satisfied: packaging>=20.0 in /home/donaldrich/.local/lib/python3.10/site-packages (from spacy) (21.3)\n", |
||||
"Collecting spacy-legacy<3.1.0,>=3.0.9\n", |
||||
" Using cached spacy_legacy-3.0.9-py2.py3-none-any.whl (20 kB)\n", |
||||
"Requirement already satisfied: jinja2 in /usr/lib/python3/dist-packages (from spacy) (3.0.3)\n", |
||||
"Collecting langcodes<4.0.0,>=3.2.0\n", |
||||
" Using cached langcodes-3.3.0-py3-none-any.whl (181 kB)\n", |
||||
"Collecting pathy>=0.3.5\n", |
||||
" Downloading pathy-0.6.2-py3-none-any.whl (42 kB)\n", |
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m42.8/42.8 KB\u001b[0m \u001b[31m1.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", |
||||
"\u001b[?25hCollecting murmurhash<1.1.0,>=0.28.0\n", |
||||
" Using cached murmurhash-1.0.7-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (21 kB)\n", |
||||
"Collecting tqdm<5.0.0,>=4.38.0\n", |
||||
" Downloading tqdm-4.64.0-py2.py3-none-any.whl (78 kB)\n", |
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m78.4/78.4 KB\u001b[0m \u001b[31m2.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", |
||||
"\u001b[?25hCollecting preshed<3.1.0,>=3.0.2\n", |
||||
" Using cached preshed-3.0.6-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (128 kB)\n", |
||||
"Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from spacy) (59.6.0)\n", |
||||
"Collecting spacy-loggers<2.0.0,>=1.0.0\n", |
||||
" Downloading spacy_loggers-1.0.3-py3-none-any.whl (9.3 kB)\n", |
||||
"Collecting catalogue<2.1.0,>=2.0.6\n", |
||||
" Downloading catalogue-2.0.8-py3-none-any.whl (17 kB)\n", |
||||
"Requirement already satisfied: typer<0.5.0,>=0.3.0 in /home/donaldrich/.local/lib/python3.10/site-packages (from spacy) (0.4.2)\n", |
||||
"Requirement already satisfied: numpy>=1.15.0 in /usr/lib/python3/dist-packages (from spacy) (1.21.5)\n", |
||||
"Collecting srsly<3.0.0,>=2.4.3\n", |
||||
" Downloading srsly-2.4.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (460 kB)\n", |
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m460.0/460.0 KB\u001b[0m \u001b[31m10.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m\n", |
||||
"\u001b[?25hRequirement already satisfied: pydantic!=1.8,!=1.8.1,<1.10.0,>=1.7.4 in /home/donaldrich/.local/lib/python3.10/site-packages (from spacy) (1.9.1)\n", |
||||
"Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /usr/lib/python3/dist-packages (from packaging>=20.0->spacy) (2.4.7)\n", |
||||
"Collecting smart-open<6.0.0,>=5.2.1\n", |
||||
" Using cached smart_open-5.2.1-py3-none-any.whl (58 kB)\n", |
||||
"Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/donaldrich/.local/lib/python3.10/site-packages (from pydantic!=1.8,!=1.8.1,<1.10.0,>=1.7.4->spacy) (4.3.0)\n", |
||||
"Collecting blis<0.8.0,>=0.7.8\n", |
||||
" Downloading blis-0.7.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.2 MB)\n", |
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m10.2/10.2 MB\u001b[0m \u001b[31m19.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m0:01\u001b[0m\n", |
||||
"\u001b[?25hRequirement already satisfied: click<9.0.0,>=7.1.1 in /usr/lib/python3/dist-packages (from typer<0.5.0,>=0.3.0->spacy) (8.0.3)\n", |
||||
"Installing collected packages: wasabi, murmurhash, cymem, tqdm, spacy-loggers, spacy-legacy, smart-open, preshed, langcodes, catalogue, blis, srsly, pathy, thinc, spacy\n", |
||||
"Successfully installed blis-0.7.8 catalogue-2.0.8 cymem-2.0.6 langcodes-3.3.0 murmurhash-1.0.7 pathy-0.6.2 preshed-3.0.6 smart-open-5.2.1 spacy-3.4.1 spacy-legacy-3.0.9 spacy-loggers-1.0.3 srsly-2.4.4 thinc-8.1.0 tqdm-4.64.0 wasabi-0.10.1\n", |
||||
"zsh:1: command not found: python\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"!pip install -U spacy\n", |
||||
"!python -m spacy download en_core_web_sm" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "b0d80ae8-94a9-45b6-af8b-790dbb12e469", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"import spacy\n", |
||||
"from spacy import displacy\n", |
||||
"\n", |
||||
"text = \"When Sebastian Thrun started working on self-driving cars at Google in 2007, few people outside of the company took him seriously.\"\n", |
||||
"\n", |
||||
"nlp = spacy.load(\"en_core_web_sm\")\n", |
||||
"doc = nlp(text)\n", |
||||
"displacy.serve(doc, style=\"ent\")" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "b2b9b88c-343b-4839-b56a-48423773a03b", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3 (ipykernel)", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.10.5" |
||||
}, |
||||
"vscode": { |
||||
"interpreter": { |
||||
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" |
||||
} |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 5 |
||||
} |
||||
@ -0,0 +1,344 @@ |
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 1, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"default:\n", |
||||
"\u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mos\u001b[39;00m\n", |
||||
"\u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mfunction\u001b[39m(test\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1\u001b[39m):\n", |
||||
" \u001b[38;5;28;01mif\u001b[39;00m test \u001b[38;5;129;01min\u001b[39;00m [\u001b[38;5;241m3\u001b[39m,\u001b[38;5;241m4\u001b[39m]:\n", |
||||
" \u001b[38;5;28mprint\u001b[39m(test)\n", |
||||
"\n", |
||||
"emacs:\n", |
||||
"\u001b[38;5;129;01mimport\u001b[39;00m \u001b[38;5;21;01mos\u001b[39;00m\n", |
||||
"\u001b[38;5;129;01mdef\u001b[39;00m \u001b[38;5;34mfunction\u001b[39m(test\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1\u001b[39m):\n", |
||||
" \u001b[38;5;129;01mif\u001b[39;00m test \u001b[38;5;129;01min\u001b[39;00m [\u001b[38;5;241m3\u001b[39m,\u001b[38;5;241m4\u001b[39m]:\n", |
||||
" \u001b[38;5;129mprint\u001b[39m(test)\n", |
||||
"\n", |
||||
"friendly:\n", |
||||
"\u001b[38;5;22;01mimport\u001b[39;00m \u001b[38;5;31;01mos\u001b[39;00m\n", |
||||
"\u001b[38;5;22;01mdef\u001b[39;00m \u001b[38;5;18mfunction\u001b[39m(test\u001b[38;5;241m=\u001b[39m\u001b[38;5;71m1\u001b[39m):\n", |
||||
" \u001b[38;5;22;01mif\u001b[39;00m test \u001b[38;5;22;01min\u001b[39;00m [\u001b[38;5;71m3\u001b[39m,\u001b[38;5;71m4\u001b[39m]:\n", |
||||
" \u001b[38;5;22mprint\u001b[39m(test)\n", |
||||
"\n", |
||||
"friendly_grayscale:\n", |
||||
"\u001b[38;5;240;01mimport\u001b[39;00m \u001b[38;5;8;01mos\u001b[39;00m\n", |
||||
"\u001b[38;5;240;01mdef\u001b[39;00m \u001b[38;5;237mfunction\u001b[39m(test\u001b[38;5;241m=\u001b[39m\u001b[38;5;102m1\u001b[39m):\n", |
||||
" \u001b[38;5;240;01mif\u001b[39;00m test \u001b[38;5;240;01min\u001b[39;00m [\u001b[38;5;102m3\u001b[39m,\u001b[38;5;102m4\u001b[39m]:\n", |
||||
" \u001b[38;5;240mprint\u001b[39m(test)\n", |
||||
"\n", |
||||
"colorful:\n", |
||||
"\u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;31;01mos\u001b[39;00m\n", |
||||
"\u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;25;01mfunction\u001b[39;00m(test\u001b[38;5;236m=\u001b[39m\u001b[38;5;20;01m1\u001b[39;00m):\n", |
||||
" \u001b[38;5;28;01mif\u001b[39;00m test \u001b[38;5;0;01min\u001b[39;00m [\u001b[38;5;20;01m3\u001b[39;00m,\u001b[38;5;20;01m4\u001b[39;00m]:\n", |
||||
" \u001b[38;5;22mprint\u001b[39m(test)\n", |
||||
"\n", |
||||
"autumn:\n", |
||||
"\u001b[38;5;19mimport\u001b[39m \u001b[38;5;37;04mos\u001b[39;00m\n", |
||||
"\u001b[38;5;19mdef\u001b[39m \u001b[38;5;34mfunction\u001b[39m(test=\u001b[38;5;30m1\u001b[39m):\n", |
||||
" \u001b[38;5;19mif\u001b[39m test \u001b[38;5;19min\u001b[39m [\u001b[38;5;30m3\u001b[39m,\u001b[38;5;30m4\u001b[39m]:\n", |
||||
" \u001b[38;5;37mprint\u001b[39m(test)\n", |
||||
"\n", |
||||
"murphy:\n", |
||||
"\u001b[38;5;30;01mimport\u001b[39;00m \u001b[38;5;31;01mos\u001b[39;00m\n", |
||||
"\u001b[38;5;30;01mdef\u001b[39;00m \u001b[38;5;86;01mfunction\u001b[39;00m(test\u001b[38;5;236m=\u001b[39m\u001b[38;5;63;01m1\u001b[39;00m):\n", |
||||
" \u001b[38;5;30;01mif\u001b[39;00m test \u001b[38;5;0;01min\u001b[39;00m [\u001b[38;5;63;01m3\u001b[39;00m,\u001b[38;5;63;01m4\u001b[39;00m]:\n", |
||||
" \u001b[38;5;28mprint\u001b[39m(test)\n", |
||||
"\n", |
||||
"manni:\n", |
||||
"\u001b[38;5;24;01mimport\u001b[39;00m \u001b[38;5;45;01mos\u001b[39;00m\n", |
||||
"\u001b[38;5;24;01mdef\u001b[39;00m \u001b[38;5;165mfunction\u001b[39m(test\u001b[38;5;240m=\u001b[39m\u001b[38;5;202m1\u001b[39m):\n", |
||||
" \u001b[38;5;24;01mif\u001b[39;00m test \u001b[38;5;0;01min\u001b[39;00m [\u001b[38;5;202m3\u001b[39m,\u001b[38;5;202m4\u001b[39m]:\n", |
||||
" \u001b[38;5;240mprint\u001b[39m(test)\n", |
||||
"\n", |
||||
"material:\n", |
||||
"\u001b[38;5;117;03mimport\u001b[39;00m\u001b[38;5;15m \u001b[39m\u001b[38;5;221mos\u001b[39m\n", |
||||
"\u001b[38;5;139mdef\u001b[39m\u001b[38;5;15m \u001b[39m\u001b[38;5;111mfunction\u001b[39m\u001b[38;5;117m(\u001b[39m\u001b[38;5;15mtest\u001b[39m\u001b[38;5;117m=\u001b[39m\u001b[38;5;209m1\u001b[39m\u001b[38;5;117m)\u001b[39m\u001b[38;5;117m:\u001b[39m\n", |
||||
"\u001b[38;5;15m \u001b[39m\u001b[38;5;139mif\u001b[39m\u001b[38;5;15m \u001b[39m\u001b[38;5;15mtest\u001b[39m\u001b[38;5;15m \u001b[39m\u001b[38;5;117;03min\u001b[39;00m\u001b[38;5;15m \u001b[39m\u001b[38;5;117m[\u001b[39m\u001b[38;5;209m3\u001b[39m\u001b[38;5;117m,\u001b[39m\u001b[38;5;209m4\u001b[39m\u001b[38;5;117m]\u001b[39m\u001b[38;5;117m:\u001b[39m\n", |
||||
"\u001b[38;5;15m \u001b[39m\u001b[38;5;111mprint\u001b[39m\u001b[38;5;117m(\u001b[39m\u001b[38;5;15mtest\u001b[39m\u001b[38;5;117m)\u001b[39m\n", |
||||
"\n", |
||||
"monokai:\n", |
||||
"\u001b[38;5;197mimport\u001b[39m\u001b[38;5;15m \u001b[39m\u001b[38;5;15mos\u001b[39m\n", |
||||
"\u001b[38;5;81mdef\u001b[39m\u001b[38;5;15m \u001b[39m\u001b[38;5;148mfunction\u001b[39m\u001b[38;5;15m(\u001b[39m\u001b[38;5;15mtest\u001b[39m\u001b[38;5;197m=\u001b[39m\u001b[38;5;141m1\u001b[39m\u001b[38;5;15m)\u001b[39m\u001b[38;5;15m:\u001b[39m\n", |
||||
"\u001b[38;5;15m \u001b[39m\u001b[38;5;81mif\u001b[39m\u001b[38;5;15m \u001b[39m\u001b[38;5;15mtest\u001b[39m\u001b[38;5;15m \u001b[39m\u001b[38;5;197min\u001b[39m\u001b[38;5;15m \u001b[39m\u001b[38;5;15m[\u001b[39m\u001b[38;5;141m3\u001b[39m\u001b[38;5;15m,\u001b[39m\u001b[38;5;141m4\u001b[39m\u001b[38;5;15m]\u001b[39m\u001b[38;5;15m:\u001b[39m\n", |
||||
"\u001b[38;5;15m \u001b[39m\u001b[38;5;15mprint\u001b[39m\u001b[38;5;15m(\u001b[39m\u001b[38;5;15mtest\u001b[39m\u001b[38;5;15m)\u001b[39m\n", |
||||
"\n", |
||||
"perldoc:\n", |
||||
"\u001b[38;5;90;01mimport\u001b[39;00m \u001b[38;5;29;04mos\u001b[39;00m\n", |
||||
"\u001b[38;5;90;01mdef\u001b[39;00m \u001b[38;5;29mfunction\u001b[39m(test=\u001b[38;5;134m1\u001b[39m):\n", |
||||
" \u001b[38;5;90;01mif\u001b[39;00m test \u001b[38;5;90min\u001b[39m [\u001b[38;5;134m3\u001b[39m,\u001b[38;5;134m4\u001b[39m]:\n", |
||||
" \u001b[38;5;64mprint\u001b[39m(test)\n", |
||||
"\n", |
||||
"pastie:\n", |
||||
"\u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;125;01mos\u001b[39;00m\n", |
||||
"\u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;25;01mfunction\u001b[39;00m(test=\u001b[38;5;20;01m1\u001b[39;00m):\n", |
||||
" \u001b[38;5;28;01mif\u001b[39;00m test \u001b[38;5;28min\u001b[39m [\u001b[38;5;20;01m3\u001b[39;00m,\u001b[38;5;20;01m4\u001b[39;00m]:\n", |
||||
" \u001b[38;5;24mprint\u001b[39m(test)\n", |
||||
"\n", |
||||
"borland:\n", |
||||
"\u001b[38;5;18;01mimport\u001b[39;00m os\n", |
||||
"\u001b[38;5;18;01mdef\u001b[39;00m function(test=\u001b[38;5;21m1\u001b[39m):\n", |
||||
" \u001b[38;5;18;01mif\u001b[39;00m test \u001b[01min\u001b[00m [\u001b[38;5;21m3\u001b[39m,\u001b[38;5;21m4\u001b[39m]:\n", |
||||
" print(test)\n", |
||||
"\n", |
||||
"trac:\n", |
||||
"\u001b[01mimport\u001b[00m \u001b[38;5;240mos\u001b[39m\n", |
||||
"\u001b[01mdef\u001b[00m \u001b[38;5;88;01mfunction\u001b[39;00m(test\u001b[01m=\u001b[00m\u001b[38;5;30m1\u001b[39m):\n", |
||||
" \u001b[01mif\u001b[00m test \u001b[01min\u001b[00m [\u001b[38;5;30m3\u001b[39m,\u001b[38;5;30m4\u001b[39m]:\n", |
||||
" \u001b[38;5;246mprint\u001b[39m(test)\n", |
||||
"\n", |
||||
"native:\n", |
||||
"\u001b[38;5;70;01mimport\u001b[39;00m\u001b[38;5;252m \u001b[39m\u001b[38;5;75;04mos\u001b[39;00m\n", |
||||
"\u001b[38;5;70;01mdef\u001b[39;00m\u001b[38;5;252m \u001b[39m\u001b[38;5;75mfunction\u001b[39m\u001b[38;5;252m(\u001b[39m\u001b[38;5;252mtest\u001b[39m\u001b[38;5;252m=\u001b[39m\u001b[38;5;75m1\u001b[39m\u001b[38;5;252m)\u001b[39m\u001b[38;5;252m:\u001b[39m\n", |
||||
"\u001b[38;5;252m \u001b[39m\u001b[38;5;70;01mif\u001b[39;00m\u001b[38;5;252m \u001b[39m\u001b[38;5;252mtest\u001b[39m\u001b[38;5;252m \u001b[39m\u001b[38;5;70;01min\u001b[39;00m\u001b[38;5;252m \u001b[39m\u001b[38;5;252m[\u001b[39m\u001b[38;5;75m3\u001b[39m\u001b[38;5;252m,\u001b[39m\u001b[38;5;75m4\u001b[39m\u001b[38;5;252m]\u001b[39m\u001b[38;5;252m:\u001b[39m\n", |
||||
"\u001b[38;5;252m \u001b[39m\u001b[38;5;38mprint\u001b[39m\u001b[38;5;252m(\u001b[39m\u001b[38;5;252mtest\u001b[39m\u001b[38;5;252m)\u001b[39m\n", |
||||
"\n", |
||||
"fruity:\n", |
||||
"\u001b[38;5;202;01mimport\u001b[39;00m\u001b[38;5;15m \u001b[39m\u001b[38;5;15mos\u001b[39m\n", |
||||
"\u001b[38;5;202;01mdef\u001b[39;00m\u001b[38;5;15m \u001b[39m\u001b[38;5;198;01mfunction\u001b[39;00m\u001b[38;5;15m(\u001b[39m\u001b[38;5;15mtest\u001b[39m\u001b[38;5;15m=\u001b[39m\u001b[38;5;33;01m1\u001b[39;00m\u001b[38;5;15m)\u001b[39m\u001b[38;5;15m:\u001b[39m\n", |
||||
"\u001b[38;5;15m \u001b[39m\u001b[38;5;202;01mif\u001b[39;00m\u001b[38;5;15m \u001b[39m\u001b[38;5;15mtest\u001b[39m\u001b[38;5;15m \u001b[39m\u001b[38;5;15min\u001b[39m\u001b[38;5;15m \u001b[39m\u001b[38;5;15m[\u001b[39m\u001b[38;5;33;01m3\u001b[39;00m\u001b[38;5;15m,\u001b[39m\u001b[38;5;33;01m4\u001b[39;00m\u001b[38;5;15m]\u001b[39m\u001b[38;5;15m:\u001b[39m\n", |
||||
"\u001b[38;5;15m \u001b[39m\u001b[38;5;15mprint\u001b[39m\u001b[38;5;15m(\u001b[39m\u001b[38;5;15mtest\u001b[39m\u001b[38;5;15m)\u001b[39m\n", |
||||
"\n", |
||||
"bw:\n", |
||||
"\u001b[01mimport\u001b[00m \u001b[01mos\u001b[00m\n", |
||||
"\u001b[01mdef\u001b[00m function(test=1):\n", |
||||
" \u001b[01mif\u001b[00m test \u001b[01min\u001b[00m [3,4]:\n", |
||||
" print(test)\n", |
||||
"\n", |
||||
"vim:\n", |
||||
"\u001b[38;5;5mimport\u001b[39m\u001b[38;5;252m \u001b[39m\u001b[38;5;252mos\u001b[39m\n", |
||||
"\u001b[38;5;3mdef\u001b[39m\u001b[38;5;252m \u001b[39m\u001b[38;5;252mfunction\u001b[39m\u001b[38;5;252m(\u001b[39m\u001b[38;5;252mtest\u001b[39m\u001b[38;5;68m=\u001b[39m\u001b[38;5;5m1\u001b[39m\u001b[38;5;252m)\u001b[39m\u001b[38;5;252m:\u001b[39m\n", |
||||
"\u001b[38;5;252m \u001b[39m\u001b[38;5;3mif\u001b[39m\u001b[38;5;252m \u001b[39m\u001b[38;5;252mtest\u001b[39m\u001b[38;5;252m \u001b[39m\u001b[38;5;3min\u001b[39m\u001b[38;5;252m \u001b[39m\u001b[38;5;252m[\u001b[39m\u001b[38;5;5m3\u001b[39m\u001b[38;5;252m,\u001b[39m\u001b[38;5;5m4\u001b[39m\u001b[38;5;252m]\u001b[39m\u001b[38;5;252m:\u001b[39m\n", |
||||
"\u001b[38;5;252m \u001b[39m\u001b[38;5;5mprint\u001b[39m\u001b[38;5;252m(\u001b[39m\u001b[38;5;252mtest\u001b[39m\u001b[38;5;252m)\u001b[39m\n", |
||||
"\n", |
||||
"vs:\n", |
||||
"\u001b[38;5;21mimport\u001b[39m os\n", |
||||
"\u001b[38;5;21mdef\u001b[39m function(test=1):\n", |
||||
" \u001b[38;5;21mif\u001b[39m test \u001b[38;5;21min\u001b[39m [3,4]:\n", |
||||
" print(test)\n", |
||||
"\n", |
||||
"tango:\n", |
||||
"\u001b[38;5;24;01mimport\u001b[39;00m \u001b[38;5;0mos\u001b[39m\n", |
||||
"\u001b[38;5;24;01mdef\u001b[39;00m \u001b[38;5;0mfunction\u001b[39m\u001b[38;5;0;01m(\u001b[39;00m\u001b[38;5;0mtest\u001b[39m\u001b[38;5;166;01m=\u001b[39;00m\u001b[38;5;20;01m1\u001b[39;00m\u001b[38;5;0;01m)\u001b[39;00m\u001b[38;5;0;01m:\u001b[39;00m\n", |
||||
" \u001b[38;5;24;01mif\u001b[39;00m \u001b[38;5;0mtest\u001b[39m \u001b[38;5;24;01min\u001b[39;00m \u001b[38;5;0;01m[\u001b[39;00m\u001b[38;5;20;01m3\u001b[39;00m\u001b[38;5;0;01m,\u001b[39;00m\u001b[38;5;20;01m4\u001b[39;00m\u001b[38;5;0;01m]\u001b[39;00m\u001b[38;5;0;01m:\u001b[39;00m\n", |
||||
" \u001b[38;5;24mprint\u001b[39m\u001b[38;5;0;01m(\u001b[39;00m\u001b[38;5;0mtest\u001b[39m\u001b[38;5;0;01m)\u001b[39;00m\n", |
||||
"\n", |
||||
"rrt:\n", |
||||
"\u001b[38;5;9mimport\u001b[39m\u001b[38;5;253m \u001b[39m\u001b[38;5;253mos\u001b[39m\n", |
||||
"\u001b[38;5;9mdef\u001b[39m\u001b[38;5;253m \u001b[39m\u001b[38;5;11mfunction\u001b[39m\u001b[38;5;253m(\u001b[39m\u001b[38;5;253mtest\u001b[39m\u001b[38;5;253m=\u001b[39m\u001b[38;5;253m1\u001b[39m\u001b[38;5;253m)\u001b[39m\u001b[38;5;253m:\u001b[39m\n", |
||||
"\u001b[38;5;253m \u001b[39m\u001b[38;5;9mif\u001b[39m\u001b[38;5;253m \u001b[39m\u001b[38;5;253mtest\u001b[39m\u001b[38;5;253m \u001b[39m\u001b[38;5;253min\u001b[39m\u001b[38;5;253m \u001b[39m\u001b[38;5;253m[\u001b[39m\u001b[38;5;253m3\u001b[39m\u001b[38;5;253m,\u001b[39m\u001b[38;5;253m4\u001b[39m\u001b[38;5;253m]\u001b[39m\u001b[38;5;253m:\u001b[39m\n", |
||||
"\u001b[38;5;253m \u001b[39m\u001b[38;5;253mprint\u001b[39m\u001b[38;5;253m(\u001b[39m\u001b[38;5;253mtest\u001b[39m\u001b[38;5;253m)\u001b[39m\n", |
||||
"\n", |
||||
"xcode:\n", |
||||
"\u001b[38;5;126mimport\u001b[39m \u001b[38;5;0mos\u001b[39m\n", |
||||
"\u001b[38;5;126mdef\u001b[39m \u001b[38;5;0mfunction\u001b[39m(\u001b[38;5;0mtest\u001b[39m\u001b[38;5;0m=\u001b[39m\u001b[38;5;20m1\u001b[39m):\n", |
||||
" \u001b[38;5;126mif\u001b[39m \u001b[38;5;0mtest\u001b[39m \u001b[38;5;0min\u001b[39m [\u001b[38;5;20m3\u001b[39m,\u001b[38;5;20m4\u001b[39m]:\n", |
||||
" \u001b[38;5;126mprint\u001b[39m(\u001b[38;5;0mtest\u001b[39m)\n", |
||||
"\n", |
||||
"igor:\n", |
||||
"\u001b[38;5;21mimport\u001b[39m os\n", |
||||
"\u001b[38;5;21mdef\u001b[39m \u001b[38;5;130mfunction\u001b[39m(test=1):\n", |
||||
" \u001b[38;5;21mif\u001b[39m test in [3,4]:\n", |
||||
" print(test)\n", |
||||
"\n", |
||||
"paraiso-light:\n", |
||||
"\u001b[38;5;79mimport\u001b[39m\u001b[38;5;235m \u001b[39m\u001b[38;5;220mos\u001b[39m\n", |
||||
"\u001b[38;5;97mdef\u001b[39m\u001b[38;5;235m \u001b[39m\u001b[38;5;39mfunction\u001b[39m\u001b[38;5;235m(\u001b[39m\u001b[38;5;235mtest\u001b[39m\u001b[38;5;79m=\u001b[39m\u001b[38;5;208m1\u001b[39m\u001b[38;5;235m)\u001b[39m\u001b[38;5;235m:\u001b[39m\n", |
||||
"\u001b[38;5;235m \u001b[39m\u001b[38;5;97mif\u001b[39m\u001b[38;5;235m \u001b[39m\u001b[38;5;235mtest\u001b[39m\u001b[38;5;235m \u001b[39m\u001b[38;5;79min\u001b[39m\u001b[38;5;235m \u001b[39m\u001b[38;5;235m[\u001b[39m\u001b[38;5;208m3\u001b[39m\u001b[38;5;235m,\u001b[39m\u001b[38;5;208m4\u001b[39m\u001b[38;5;235m]\u001b[39m\u001b[38;5;235m:\u001b[39m\n", |
||||
"\u001b[38;5;235m \u001b[39m\u001b[38;5;235mprint\u001b[39m\u001b[38;5;235m(\u001b[39m\u001b[38;5;235mtest\u001b[39m\u001b[38;5;235m)\u001b[39m\n", |
||||
"\n", |
||||
"paraiso-dark:\n", |
||||
"\u001b[38;5;79mimport\u001b[39m\u001b[38;5;7m \u001b[39m\u001b[38;5;220mos\u001b[39m\n", |
||||
"\u001b[38;5;97mdef\u001b[39m\u001b[38;5;7m \u001b[39m\u001b[38;5;39mfunction\u001b[39m\u001b[38;5;7m(\u001b[39m\u001b[38;5;7mtest\u001b[39m\u001b[38;5;79m=\u001b[39m\u001b[38;5;208m1\u001b[39m\u001b[38;5;7m)\u001b[39m\u001b[38;5;7m:\u001b[39m\n", |
||||
"\u001b[38;5;7m \u001b[39m\u001b[38;5;97mif\u001b[39m\u001b[38;5;7m \u001b[39m\u001b[38;5;7mtest\u001b[39m\u001b[38;5;7m \u001b[39m\u001b[38;5;79min\u001b[39m\u001b[38;5;7m \u001b[39m\u001b[38;5;7m[\u001b[39m\u001b[38;5;208m3\u001b[39m\u001b[38;5;7m,\u001b[39m\u001b[38;5;208m4\u001b[39m\u001b[38;5;7m]\u001b[39m\u001b[38;5;7m:\u001b[39m\n", |
||||
"\u001b[38;5;7m \u001b[39m\u001b[38;5;7mprint\u001b[39m\u001b[38;5;7m(\u001b[39m\u001b[38;5;7mtest\u001b[39m\u001b[38;5;7m)\u001b[39m\n", |
||||
"\n", |
||||
"lovelace:\n", |
||||
"\u001b[38;5;25mimport\u001b[39m \u001b[38;5;29mos\u001b[39m\n", |
||||
"\u001b[38;5;25mdef\u001b[39m \u001b[38;5;95mfunction\u001b[39m\u001b[38;5;102m(\u001b[39mtest\u001b[38;5;241m=\u001b[39m\u001b[38;5;238m1\u001b[39m\u001b[38;5;102m)\u001b[39m\u001b[38;5;102m:\u001b[39m\n", |
||||
" \u001b[38;5;25mif\u001b[39m test \u001b[38;5;133min\u001b[39m \u001b[38;5;102m[\u001b[39m\u001b[38;5;238m3\u001b[39m\u001b[38;5;102m,\u001b[39m\u001b[38;5;238m4\u001b[39m\u001b[38;5;102m]\u001b[39m\u001b[38;5;102m:\u001b[39m\n", |
||||
" \u001b[38;5;65mprint\u001b[39m\u001b[38;5;102m(\u001b[39mtest\u001b[38;5;102m)\u001b[39m\n", |
||||
"\n", |
||||
"algol:\n", |
||||
"\u001b[01;04mimport\u001b[00m \u001b[38;5;241;01;03mos\u001b[39;00m\n", |
||||
"\u001b[01;04mdef\u001b[00m \u001b[38;5;241;01;03mfunction\u001b[39;00m(test=1):\n", |
||||
" \u001b[01;04mif\u001b[00m test \u001b[01min\u001b[00m [3,4]:\n", |
||||
" \u001b[01;03mprint\u001b[00m(test)\n", |
||||
"\n", |
||||
"algol_nu:\n", |
||||
"\u001b[01mimport\u001b[00m \u001b[38;5;241;01;03mos\u001b[39;00m\n", |
||||
"\u001b[01mdef\u001b[00m \u001b[38;5;241;01;03mfunction\u001b[39;00m(test=1):\n", |
||||
" \u001b[01mif\u001b[00m test \u001b[01min\u001b[00m [3,4]:\n", |
||||
" \u001b[01;03mprint\u001b[00m(test)\n", |
||||
"\n", |
||||
"arduino:\n", |
||||
"\u001b[38;5;64mimport\u001b[39m \u001b[38;5;239mos\u001b[39m\n", |
||||
"\u001b[38;5;64mdef\u001b[39m \u001b[38;5;166mfunction\u001b[39m(\u001b[38;5;239mtest\u001b[39m\u001b[38;5;64m=\u001b[39m\u001b[38;5;101m1\u001b[39m):\n", |
||||
" \u001b[38;5;64mif\u001b[39m \u001b[38;5;239mtest\u001b[39m \u001b[38;5;64min\u001b[39m [\u001b[38;5;101m3\u001b[39m,\u001b[38;5;101m4\u001b[39m]:\n", |
||||
" \u001b[38;5;64mprint\u001b[39m(\u001b[38;5;239mtest\u001b[39m)\n", |
||||
"\n", |
||||
"rainbow_dash:\n", |
||||
"\u001b[38;5;26;01mimport\u001b[39;00m\u001b[38;5;239m \u001b[39mos\n", |
||||
"\u001b[38;5;26;01mdef\u001b[39;00m\u001b[38;5;239m \u001b[39m\u001b[38;5;208;01mfunction\u001b[39;00m(test\u001b[38;5;26m=\u001b[39m\u001b[38;5;55;01m1\u001b[39;00m):\n", |
||||
"\u001b[38;5;239m \u001b[39m\u001b[38;5;26;01mif\u001b[39;00m\u001b[38;5;239m \u001b[39mtest\u001b[38;5;239m \u001b[39m\u001b[38;5;26;01min\u001b[39;00m\u001b[38;5;239m \u001b[39m[\u001b[38;5;55;01m3\u001b[39;00m,\u001b[38;5;55;01m4\u001b[39;00m]:\n", |
||||
"\u001b[38;5;239m \u001b[39m\u001b[38;5;55;01mprint\u001b[39;00m(test)\n", |
||||
"\n", |
||||
"abap:\n", |
||||
"\u001b[38;5;21mimport\u001b[39m \u001b[38;5;0mos\u001b[39m\n", |
||||
"\u001b[38;5;21mdef\u001b[39m \u001b[38;5;0mfunction\u001b[39m(\u001b[38;5;0mtest\u001b[39m=\u001b[38;5;75m1\u001b[39m):\n", |
||||
" \u001b[38;5;21mif\u001b[39m \u001b[38;5;0mtest\u001b[39m \u001b[38;5;21min\u001b[39m [\u001b[38;5;75m3\u001b[39m,\u001b[38;5;75m4\u001b[39m]:\n", |
||||
" \u001b[38;5;0mprint\u001b[39m(\u001b[38;5;0mtest\u001b[39m)\n", |
||||
"\n", |
||||
"solarized-dark:\n", |
||||
"\u001b[38;5;166mimport\u001b[39m\u001b[38;5;245m \u001b[39m\u001b[38;5;32mos\u001b[39m\n", |
||||
"\u001b[38;5;100mdef\u001b[39m\u001b[38;5;245m \u001b[39m\u001b[38;5;32mfunction\u001b[39m\u001b[38;5;245m(\u001b[39m\u001b[38;5;245mtest\u001b[39m\u001b[38;5;242m=\u001b[39m\u001b[38;5;36m1\u001b[39m\u001b[38;5;245m)\u001b[39m\u001b[38;5;245m:\u001b[39m\n", |
||||
"\u001b[38;5;245m \u001b[39m\u001b[38;5;100mif\u001b[39m\u001b[38;5;245m \u001b[39m\u001b[38;5;245mtest\u001b[39m\u001b[38;5;245m \u001b[39m\u001b[38;5;100min\u001b[39m\u001b[38;5;245m \u001b[39m\u001b[38;5;245m[\u001b[39m\u001b[38;5;36m3\u001b[39m\u001b[38;5;245m,\u001b[39m\u001b[38;5;36m4\u001b[39m\u001b[38;5;245m]\u001b[39m\u001b[38;5;245m:\u001b[39m\n", |
||||
"\u001b[38;5;245m \u001b[39m\u001b[38;5;32mprint\u001b[39m\u001b[38;5;245m(\u001b[39m\u001b[38;5;245mtest\u001b[39m\u001b[38;5;245m)\u001b[39m\n", |
||||
"\n", |
||||
"solarized-light:\n", |
||||
"\u001b[38;5;166mimport\u001b[39m\u001b[38;5;66m \u001b[39m\u001b[38;5;32mos\u001b[39m\n", |
||||
"\u001b[38;5;100mdef\u001b[39m\u001b[38;5;66m \u001b[39m\u001b[38;5;32mfunction\u001b[39m\u001b[38;5;66m(\u001b[39m\u001b[38;5;66mtest\u001b[39m\u001b[38;5;247m=\u001b[39m\u001b[38;5;36m1\u001b[39m\u001b[38;5;66m)\u001b[39m\u001b[38;5;66m:\u001b[39m\n", |
||||
"\u001b[38;5;66m \u001b[39m\u001b[38;5;100mif\u001b[39m\u001b[38;5;66m \u001b[39m\u001b[38;5;66mtest\u001b[39m\u001b[38;5;66m \u001b[39m\u001b[38;5;100min\u001b[39m\u001b[38;5;66m \u001b[39m\u001b[38;5;66m[\u001b[39m\u001b[38;5;36m3\u001b[39m\u001b[38;5;66m,\u001b[39m\u001b[38;5;36m4\u001b[39m\u001b[38;5;66m]\u001b[39m\u001b[38;5;66m:\u001b[39m\n", |
||||
"\u001b[38;5;66m \u001b[39m\u001b[38;5;32mprint\u001b[39m\u001b[38;5;66m(\u001b[39m\u001b[38;5;66mtest\u001b[39m\u001b[38;5;66m)\u001b[39m\n", |
||||
"\n", |
||||
"sas:\n", |
||||
"\u001b[38;5;21mimport\u001b[39m os\n", |
||||
"\u001b[38;5;21mdef\u001b[39m \u001b[01;03mfunction\u001b[00m(test=\u001b[38;5;29;01m1\u001b[39;00m):\n", |
||||
" \u001b[38;5;21mif\u001b[39m test in [\u001b[38;5;29;01m3\u001b[39;00m,\u001b[38;5;29;01m4\u001b[39;00m]:\n", |
||||
" \u001b[38;5;21mprint\u001b[39m(test)\n", |
||||
"\n", |
||||
"stata:\n", |
||||
"\u001b[38;5;60;01mimport\u001b[39;00m\u001b[38;5;233m \u001b[39mos\n", |
||||
"\u001b[38;5;60;01mdef\u001b[39;00m\u001b[38;5;233m \u001b[39m\u001b[38;5;21mfunction\u001b[39m(test=\u001b[38;5;21m1\u001b[39m):\n", |
||||
"\u001b[38;5;233m \u001b[39m\u001b[38;5;60;01mif\u001b[39;00m\u001b[38;5;233m \u001b[39mtest\u001b[38;5;233m \u001b[39min\u001b[38;5;233m \u001b[39m[\u001b[38;5;21m3\u001b[39m,\u001b[38;5;21m4\u001b[39m]:\n", |
||||
"\u001b[38;5;233m \u001b[39mprint(test)\n", |
||||
"\n", |
||||
"stata-light:\n", |
||||
"\u001b[38;5;60;01mimport\u001b[39;00m\u001b[38;5;233m \u001b[39mos\n", |
||||
"\u001b[38;5;60;01mdef\u001b[39;00m\u001b[38;5;233m \u001b[39m\u001b[38;5;21mfunction\u001b[39m(test=\u001b[38;5;21m1\u001b[39m):\n", |
||||
"\u001b[38;5;233m \u001b[39m\u001b[38;5;60;01mif\u001b[39;00m\u001b[38;5;233m \u001b[39mtest\u001b[38;5;233m \u001b[39min\u001b[38;5;233m \u001b[39m[\u001b[38;5;21m3\u001b[39m,\u001b[38;5;21m4\u001b[39m]:\n", |
||||
"\u001b[38;5;233m \u001b[39mprint(test)\n", |
||||
"\n", |
||||
"stata-dark:\n", |
||||
"\u001b[38;5;103;01mimport\u001b[39;00m\u001b[38;5;252m \u001b[39m\u001b[38;5;252mos\u001b[39m\n", |
||||
"\u001b[38;5;103;01mdef\u001b[39;00m\u001b[38;5;252m \u001b[39m\u001b[38;5;63mfunction\u001b[39m\u001b[38;5;252m(\u001b[39m\u001b[38;5;252mtest\u001b[39m\u001b[38;5;252m=\u001b[39m\u001b[38;5;74m1\u001b[39m\u001b[38;5;252m)\u001b[39m\u001b[38;5;252m:\u001b[39m\n", |
||||
"\u001b[38;5;252m \u001b[39m\u001b[38;5;103;01mif\u001b[39;00m\u001b[38;5;252m \u001b[39m\u001b[38;5;252mtest\u001b[39m\u001b[38;5;252m \u001b[39m\u001b[38;5;252min\u001b[39m\u001b[38;5;252m \u001b[39m\u001b[38;5;252m[\u001b[39m\u001b[38;5;74m3\u001b[39m\u001b[38;5;252m,\u001b[39m\u001b[38;5;74m4\u001b[39m\u001b[38;5;252m]\u001b[39m\u001b[38;5;252m:\u001b[39m\n", |
||||
"\u001b[38;5;252m \u001b[39m\u001b[38;5;252mprint\u001b[39m\u001b[38;5;252m(\u001b[39m\u001b[38;5;252mtest\u001b[39m\u001b[38;5;252m)\u001b[39m\n", |
||||
"\n", |
||||
"inkpot:\n", |
||||
"\u001b[38;5;105mimport\u001b[39m\u001b[38;5;181m \u001b[39m\u001b[38;5;9mos\u001b[39m\n", |
||||
"\u001b[38;5;105mdef\u001b[39m\u001b[38;5;181m \u001b[39m\u001b[38;5;140mfunction\u001b[39m\u001b[38;5;181m(\u001b[39m\u001b[38;5;181mtest\u001b[39m\u001b[38;5;241m=\u001b[39m\u001b[38;5;215m1\u001b[39m\u001b[38;5;181m)\u001b[39m\u001b[38;5;181m:\u001b[39m\n", |
||||
"\u001b[38;5;181m \u001b[39m\u001b[38;5;105mif\u001b[39m\u001b[38;5;181m \u001b[39m\u001b[38;5;181mtest\u001b[39m\u001b[38;5;181m \u001b[39m\u001b[38;5;241min\u001b[39m\u001b[38;5;181m \u001b[39m\u001b[38;5;181m[\u001b[39m\u001b[38;5;215m3\u001b[39m\u001b[38;5;181m,\u001b[39m\u001b[38;5;215m4\u001b[39m\u001b[38;5;181m]\u001b[39m\u001b[38;5;181m:\u001b[39m\n", |
||||
"\u001b[38;5;181m \u001b[39m\u001b[38;5;105mprint\u001b[39m\u001b[38;5;181m(\u001b[39m\u001b[38;5;181mtest\u001b[39m\u001b[38;5;181m)\u001b[39m\n", |
||||
"\n", |
||||
"zenburn:\n", |
||||
"\u001b[38;5;223mimport\u001b[39m\u001b[38;5;188m \u001b[39m\u001b[38;5;188mos\u001b[39m\n", |
||||
"\u001b[38;5;223mdef\u001b[39m\u001b[38;5;188m \u001b[39m\u001b[38;5;228mfunction\u001b[39m\u001b[38;5;230m(\u001b[39m\u001b[38;5;188mtest\u001b[39m\u001b[38;5;230m=\u001b[39m\u001b[38;5;116m1\u001b[39m\u001b[38;5;230m)\u001b[39m\u001b[38;5;230m:\u001b[39m\n", |
||||
"\u001b[38;5;188m \u001b[39m\u001b[38;5;223mif\u001b[39m\u001b[38;5;188m \u001b[39m\u001b[38;5;188mtest\u001b[39m\u001b[38;5;188m \u001b[39m\u001b[38;5;230min\u001b[39m\u001b[38;5;188m \u001b[39m\u001b[38;5;230m[\u001b[39m\u001b[38;5;116m3\u001b[39m\u001b[38;5;230m,\u001b[39m\u001b[38;5;116m4\u001b[39m\u001b[38;5;230m]\u001b[39m\u001b[38;5;230m:\u001b[39m\n", |
||||
"\u001b[38;5;188m \u001b[39m\u001b[38;5;228mprint\u001b[39m\u001b[38;5;230m(\u001b[39m\u001b[38;5;188mtest\u001b[39m\u001b[38;5;230m)\u001b[39m\n", |
||||
"\n", |
||||
"gruvbox-dark:\n", |
||||
"\u001b[38;5;203mimport\u001b[39m\u001b[38;5;253m \u001b[39m\u001b[38;5;108mos\u001b[39m\n", |
||||
"\u001b[38;5;203mdef\u001b[39m\u001b[38;5;253m \u001b[39m\u001b[38;5;108mfunction\u001b[39m\u001b[38;5;253m(\u001b[39m\u001b[38;5;253mtest\u001b[39m\u001b[38;5;253m=\u001b[39m\u001b[38;5;174m1\u001b[39m\u001b[38;5;253m)\u001b[39m\u001b[38;5;253m:\u001b[39m\n", |
||||
"\u001b[38;5;253m \u001b[39m\u001b[38;5;203mif\u001b[39m\u001b[38;5;253m \u001b[39m\u001b[38;5;253mtest\u001b[39m\u001b[38;5;253m \u001b[39m\u001b[38;5;203min\u001b[39m\u001b[38;5;253m \u001b[39m\u001b[38;5;253m[\u001b[39m\u001b[38;5;174m3\u001b[39m\u001b[38;5;253m,\u001b[39m\u001b[38;5;174m4\u001b[39m\u001b[38;5;253m]\u001b[39m\u001b[38;5;253m:\u001b[39m\n", |
||||
"\u001b[38;5;253m \u001b[39m\u001b[38;5;208mprint\u001b[39m\u001b[38;5;253m(\u001b[39m\u001b[38;5;253mtest\u001b[39m\u001b[38;5;253m)\u001b[39m\n", |
||||
"\n", |
||||
"gruvbox-light:\n", |
||||
"\u001b[38;5;124mimport\u001b[39m \u001b[38;5;65mos\u001b[39m\n", |
||||
"\u001b[38;5;124mdef\u001b[39m \u001b[38;5;65mfunction\u001b[39m(test=\u001b[38;5;95m1\u001b[39m):\n", |
||||
" \u001b[38;5;124mif\u001b[39m test \u001b[38;5;124min\u001b[39m [\u001b[38;5;95m3\u001b[39m,\u001b[38;5;95m4\u001b[39m]:\n", |
||||
" \u001b[38;5;130mprint\u001b[39m(test)\n", |
||||
"\n", |
||||
"dracula:\n", |
||||
"\u001b[38;5;212mimport\u001b[39m\u001b[38;5;15m \u001b[39m\u001b[38;5;15mos\u001b[39m\n", |
||||
"\u001b[38;5;212mdef\u001b[39m\u001b[38;5;15m \u001b[39m\u001b[38;5;84mfunction\u001b[39m\u001b[38;5;15m(\u001b[39m\u001b[38;5;15mtest\u001b[39m\u001b[38;5;212m=\u001b[39m\u001b[38;5;215m1\u001b[39m\u001b[38;5;15m)\u001b[39m\u001b[38;5;15m:\u001b[39m\n", |
||||
"\u001b[38;5;15m \u001b[39m\u001b[38;5;212mif\u001b[39m\u001b[38;5;15m \u001b[39m\u001b[38;5;15mtest\u001b[39m\u001b[38;5;15m \u001b[39m\u001b[38;5;212min\u001b[39m\u001b[38;5;15m \u001b[39m\u001b[38;5;15m[\u001b[39m\u001b[38;5;215m3\u001b[39m\u001b[38;5;15m,\u001b[39m\u001b[38;5;215m4\u001b[39m\u001b[38;5;15m]\u001b[39m\u001b[38;5;15m:\u001b[39m\n", |
||||
"\u001b[38;5;15m \u001b[39m\u001b[38;5;117;03mprint\u001b[39;00m\u001b[38;5;15m(\u001b[39m\u001b[38;5;15mtest\u001b[39m\u001b[38;5;15m)\u001b[39m\n", |
||||
"\n", |
||||
"one-dark:\n", |
||||
"\u001b[38;5;176mimport\u001b[39m\u001b[38;5;249m \u001b[39m\u001b[38;5;168mos\u001b[39m\n", |
||||
"\u001b[38;5;176mdef\u001b[39m\u001b[38;5;249m \u001b[39m\u001b[38;5;75;01mfunction\u001b[39;00m\u001b[38;5;249m(\u001b[39m\u001b[38;5;168mtest\u001b[39m\u001b[38;5;73m=\u001b[39m\u001b[38;5;173m1\u001b[39m\u001b[38;5;249m)\u001b[39m\u001b[38;5;249m:\u001b[39m\n", |
||||
"\u001b[38;5;249m \u001b[39m\u001b[38;5;176mif\u001b[39m\u001b[38;5;249m \u001b[39m\u001b[38;5;168mtest\u001b[39m\u001b[38;5;249m \u001b[39m\u001b[38;5;73min\u001b[39m\u001b[38;5;249m \u001b[39m\u001b[38;5;249m[\u001b[39m\u001b[38;5;173m3\u001b[39m\u001b[38;5;249m,\u001b[39m\u001b[38;5;173m4\u001b[39m\u001b[38;5;249m]\u001b[39m\u001b[38;5;249m:\u001b[39m\n", |
||||
"\u001b[38;5;249m \u001b[39m\u001b[38;5;180mprint\u001b[39m\u001b[38;5;249m(\u001b[39m\u001b[38;5;168mtest\u001b[39m\u001b[38;5;249m)\u001b[39m\n", |
||||
"\n", |
||||
"lilypond:\n", |
||||
"\u001b[01mimport\u001b[00m os\n", |
||||
"\u001b[01mdef\u001b[00m function(test=\u001b[38;5;94m1\u001b[39m):\n", |
||||
" \u001b[01mif\u001b[00m test in [\u001b[38;5;94m3\u001b[39m,\u001b[38;5;94m4\u001b[39m]:\n", |
||||
" print(test)\n", |
||||
"\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"from pygments.styles import get_all_styles\n", |
||||
"from pygments.formatters import Terminal256Formatter\n", |
||||
"from pygments.lexers import PythonLexer\n", |
||||
"from pygments import highlight\n", |
||||
"\n", |
||||
"code = \"\"\"\n", |
||||
"import os\n", |
||||
"def function(test=1):\n", |
||||
" if test in [3,4]:\n", |
||||
" print(test)\n", |
||||
"\"\"\"\n", |
||||
"for style in get_all_styles():\n", |
||||
" highlighted_code = highlight(code, PythonLexer(),\n", |
||||
" Terminal256Formatter(style=style))\n", |
||||
" print(f\"{style}:\\n{highlighted_code}\")" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 2, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"['default', 'emacs', 'friendly', 'friendly_grayscale', 'colorful', 'autumn', 'murphy', 'manni', 'material', 'monokai', 'perldoc', 'pastie', 'borland', 'trac', 'native', 'fruity', 'bw', 'vim', 'vs', 'tango', 'rrt', 'xcode', 'igor', 'paraiso-light', 'paraiso-dark', 'lovelace', 'algol', 'algol_nu', 'arduino', 'rainbow_dash', 'abap', 'solarized-dark', 'solarized-light', 'sas', 'stata', 'stata-light', 'stata-dark', 'inkpot', 'zenburn', 'gruvbox-dark', 'gruvbox-light', 'dracula', 'one-dark', 'lilypond']\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"from pygments.styles import get_all_styles\n", |
||||
"\n", |
||||
"print(list(get_all_styles()))" |
||||
] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3.8.9 64-bit", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.10.6" |
||||
}, |
||||
"orig_nbformat": 4, |
||||
"vscode": { |
||||
"interpreter": { |
||||
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" |
||||
} |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 2 |
||||
} |
||||
@ -0,0 +1,187 @@ |
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 25, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"Node.js\n", |
||||
"Node.js - Cross-Platform\n", |
||||
"Frontend Development\n", |
||||
"iOS\n", |
||||
"Android\n", |
||||
"IoT & Hybrid Apps\n", |
||||
"Electron\n", |
||||
"Cordova\n", |
||||
"React Native\n", |
||||
"Xamarin\n", |
||||
"Linux\n", |
||||
"Linux - Containers\n", |
||||
"Linux - eBPF\n", |
||||
"Linux - Arch-based Projects\n", |
||||
"Linux - AppImage\n", |
||||
"macOS - Screensavers\n", |
||||
"macOS - Apps\n", |
||||
"macOS - Open Source Apps\n", |
||||
"watchOS\n", |
||||
"JVM\n", |
||||
"Salesforce\n", |
||||
"Amazon Web Services\n", |
||||
"Windows\n", |
||||
"IPFS\n", |
||||
"Fuse\n", |
||||
"Heroku\n", |
||||
"Raspberry Pi\n", |
||||
"Qt\n", |
||||
"WebExtensions\n", |
||||
"Smart TV\n", |
||||
"GNOME\n", |
||||
"KDE\n" |
||||
] |
||||
}, |
||||
{ |
||||
"ename": "InvalidName", |
||||
"evalue": "collection names must not start or end with '.': '.NET'", |
||||
"output_type": "error", |
||||
"traceback": [ |
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
||||
"\u001b[0;31mInvalidName\u001b[0m Traceback (most recent call last)", |
||||
"Input \u001b[0;32mIn [25]\u001b[0m, in \u001b[0;36m<cell line: 18>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 28\u001b[0m link \u001b[38;5;241m=\u001b[39m string\u001b[38;5;241m.\u001b[39mreplace(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m/\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m-\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 30\u001b[0m mydb \u001b[38;5;241m=\u001b[39m myclient[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mawesome-lists\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n\u001b[0;32m---> 31\u001b[0m mycol \u001b[38;5;241m=\u001b[39m \u001b[43mmydb\u001b[49m\u001b[43m[\u001b[49m\u001b[43mtitle\u001b[49m\u001b[43m]\u001b[49m\n\u001b[1;32m 33\u001b[0m one_list \u001b[38;5;241m=\u001b[39m requests\u001b[38;5;241m.\u001b[39mget(\n\u001b[1;32m 34\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhttps://raw.githubusercontent.com/lockys/awesome.json/master/repo-json/\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 35\u001b[0m \u001b[38;5;241m+\u001b[39m link \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m.json\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 36\u001b[0m headers\u001b[38;5;241m=\u001b[39m{\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAccept\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mapplication/vnd.github.v3+json\u001b[39m\u001b[38;5;124m\"\u001b[39m},\n\u001b[1;32m 37\u001b[0m )\n\u001b[1;32m 38\u001b[0m \u001b[38;5;28mprint\u001b[39m(title)\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/pymongo/database.py:237\u001b[0m, in \u001b[0;36mDatabase.__getitem__\u001b[0;34m(self, name)\u001b[0m\n\u001b[1;32m 229\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__getitem__\u001b[39m(\u001b[38;5;28mself\u001b[39m, name: \u001b[38;5;28mstr\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCollection[_DocumentType]\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[1;32m 230\u001b[0m \u001b[38;5;124;03m\"\"\"Get a collection of this database by name.\u001b[39;00m\n\u001b[1;32m 231\u001b[0m \n\u001b[1;32m 232\u001b[0m \u001b[38;5;124;03m Raises InvalidName if an invalid collection name is used.\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 235\u001b[0m \u001b[38;5;124;03m - `name`: the name of the collection to get\u001b[39;00m\n\u001b[1;32m 236\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m--> 237\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mCollection\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mname\u001b[49m\u001b[43m)\u001b[49m\n", |
||||
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/pymongo/collection.py:212\u001b[0m, in \u001b[0;36mCollection.__init__\u001b[0;34m(self, database, name, create, codec_options, read_preference, write_concern, read_concern, session, **kwargs)\u001b[0m\n\u001b[1;32m 210\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m InvalidName(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcollection names must not contain \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m$\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m: \u001b[39m\u001b[38;5;132;01m%r\u001b[39;00m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;241m%\u001b[39m name)\n\u001b[1;32m 211\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m name[\u001b[38;5;241m0\u001b[39m] \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01mor\u001b[39;00m name[\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m] \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[0;32m--> 212\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m InvalidName(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcollection names must not start or end with \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m: \u001b[39m\u001b[38;5;132;01m%r\u001b[39;00m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;241m%\u001b[39m name)\n\u001b[1;32m 213\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\x00\u001b[39;00m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m name:\n\u001b[1;32m 214\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m InvalidName(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcollection names must not contain the null character\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", |
||||
"\u001b[0;31mInvalidName\u001b[0m: collection names must not start or end with '.': '.NET'" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"import json\n", |
||||
"import pprint\n", |
||||
"import requests\n", |
||||
"import pymongo\n", |
||||
"\n", |
||||
"myclient = pymongo.MongoClient(\n", |
||||
" \"mongodb://donaldrich:ibanez69@192.168.1.101:27017\")\n", |
||||
"# DB\n", |
||||
"\n", |
||||
"data = requests.get(\n", |
||||
" \"https://raw.githubusercontent.com/lockys/Awesome.json/master/awesome/awesome.json?ref=master\",\n", |
||||
" headers={\"Accept\": \"application/vnd.github.v3+json\"},\n", |
||||
")\n", |
||||
"#\n", |
||||
"\n", |
||||
"repos = data.json()\n", |
||||
"\n", |
||||
"for x in repos.values():\n", |
||||
" for z in x:\n", |
||||
" try:\n", |
||||
" string = z['repo']\n", |
||||
"# if len(z['name']) > 0:\n", |
||||
"# title = z['name']\n", |
||||
"# else:\n", |
||||
"# title = \"none\"\n", |
||||
"# # print(count)\n", |
||||
" title = z['name']\n", |
||||
" title = title.replace(\".\", \"\")\n", |
||||
" link = string.replace(\"/\", \"-\")\n", |
||||
"\n", |
||||
" mydb = myclient[\"awesome-lists\"]\n", |
||||
" mycol = mydb[title]\n", |
||||
"\n", |
||||
" one_list = requests.get(\n", |
||||
" \"https://raw.githubusercontent.com/lockys/awesome.json/master/repo-json/\"\n", |
||||
" + link + \".json\",\n", |
||||
" headers={\"Accept\": \"application/vnd.github.v3+json\"},\n", |
||||
" )\n", |
||||
" print(title)\n", |
||||
" for x in one_list.json():\n", |
||||
" try:\n", |
||||
" mydict = x\n", |
||||
"\n", |
||||
"# pprint.pprint(mydict)\n", |
||||
"\n", |
||||
" new = mycol.insert_one(mydict)\n", |
||||
"\n", |
||||
" # print(new.inserted_id)\n", |
||||
" except:\n", |
||||
" print(x)\n", |
||||
" except ValueError as error:\n", |
||||
" print(z)\n", |
||||
"# print(\"invalid json: %s\" % error)\n" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 13, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"63136ab944dfc9e0de996f01\n", |
||||
"['test']\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"import pymongo\n", |
||||
"\n", |
||||
"myclient = pymongo.MongoClient(\"mongodb://donaldrich:ibanez69@192.168.1.101:27017\")\n", |
||||
"# DB\n", |
||||
"\n", |
||||
"mydb = myclient[\"awesome-lists\"]\n", |
||||
"\n", |
||||
"# Collectinon\n", |
||||
"\n", |
||||
"mycol = mydb[\"test\"]\n", |
||||
"\n", |
||||
"mydict = {\"name\": \"Peter\", \"address\": \"Lowstreet 27\"}\n", |
||||
"\n", |
||||
"x = mycol.insert_one(mydict)\n", |
||||
"\n", |
||||
"print(x.inserted_id)\n", |
||||
"\n", |
||||
"print(mydb.list_collection_names())" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"!pip install pymongo" |
||||
] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3 (ipykernel)", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.10.5" |
||||
}, |
||||
"vscode": { |
||||
"interpreter": { |
||||
"hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1" |
||||
} |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 2 |
||||
} |
||||
@ -0,0 +1,53 @@ |
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"from minio import Minio\n", |
||||
"from minio.error import S3Error\n", |
||||
"\n", |
||||
"\n", |
||||
"def main():\n", |
||||
"\n", |
||||
" client = Minio(\n", |
||||
" \"minio_endpoint\",\n", |
||||
" access_key=\"key\",\n", |
||||
" secret_key=\"secret\",\n", |
||||
" )\n", |
||||
"\n", |
||||
" # Make 'asiatrip' bucket if not exist.\n", |
||||
" found = client.bucket_exists(\"bucket\")\n", |
||||
" if not found:\n", |
||||
" client.make_bucket(\"bucket\")\n", |
||||
" else:\n", |
||||
" print(\"Bucket already exists\")\n", |
||||
"\n", |
||||
" client.fput_object(\n", |
||||
" \"bucket\", \"bucket_file\", \"local_file_path\",\n", |
||||
" )\n", |
||||
" print(\n", |
||||
" \"'local_file_path' is successfully uploaded as \"\n", |
||||
" \"object 'bucket_file' to bucket 'bucket'.\"\n", |
||||
" )\n", |
||||
"\n", |
||||
"\n", |
||||
"if __name__ == \"__main__\":\n", |
||||
" try:\n", |
||||
" main()\n", |
||||
" except S3Error as exc:\n", |
||||
" print(\"error occurred.\", exc)" |
||||
] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"language_info": { |
||||
"name": "python" |
||||
}, |
||||
"orig_nbformat": 4 |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 2 |
||||
} |
||||
@ -0,0 +1,236 @@ |
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 9, |
||||
"id": "22005864-a267-4819-b083-935a85452b39", |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"Requirement already satisfied: pymongo in /opt/conda/lib/python3.10/site-packages (4.2.0)\r\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"!pip install pymongo" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 10, |
||||
"id": "d1690099-dbf9-4d75-946c-c556c13ec34d", |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"630855c7014e9a17ccd6bd03\n", |
||||
"['customers']\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"import pymongo\n", |
||||
"\n", |
||||
"myclient = pymongo.MongoClient(\"mongodb://donaldrich:ibanez69@mongo:27017\")\n", |
||||
"# DB\n", |
||||
"\n", |
||||
"mydb = myclient[\"mydatabase\"]\n", |
||||
"\n", |
||||
"# Collectino\n", |
||||
"\n", |
||||
"mycol = mydb[\"customers\"]\n", |
||||
"\n", |
||||
"mydict = { \"name\": \"Peter\", \"address\": \"Lowstreet 27\" }\n", |
||||
"\n", |
||||
"x = mycol.insert_one(mydict)\n", |
||||
"\n", |
||||
"print(x.inserted_id)\n", |
||||
"\n", |
||||
"print(mydb.list_collection_names())" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "markdown", |
||||
"id": "d97181c9-08bb-47c0-a8a3-50f8ea878a15", |
||||
"metadata": {}, |
||||
"source": [ |
||||
"# hjhj" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 5, |
||||
"id": "54535d13-e279-44bc-bd9d-52d14cb550fb", |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"[]\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"# DB\n", |
||||
"\n", |
||||
"mydb = myclient[\"mydatabase\"]\n", |
||||
"\n", |
||||
"# Collectino\n", |
||||
"\n", |
||||
"mycol = mydb[\"customers\"]\n", |
||||
"\n", |
||||
"print(mydb.list_collection_names())" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "markdown", |
||||
"id": "7b7a6e52-4de9-4f6d-91b4-b3716baba323", |
||||
"metadata": {}, |
||||
"source": [] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "7ed477f1-9044-498c-9d3e-5021df5bdc93", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"mydict = { \"name\": \"Peter\", \"address\": \"Lowstreet 27\" }\n", |
||||
"\n", |
||||
"x = mycol.insert_one(mydict)\n", |
||||
"\n", |
||||
"print(x.inserted_id)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "markdown", |
||||
"id": "efb52832-dc7d-4e4c-b70c-d29b923f02db", |
||||
"metadata": {}, |
||||
"source": [] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "430085cf-e0b4-4a12-b382-90f9351e5490", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"mylist = [\n", |
||||
" { \"_id\": 1, \"name\": \"John\", \"address\": \"Highway 37\"},\n", |
||||
" { \"_id\": 2, \"name\": \"Peter\", \"address\": \"Lowstreet 27\"},\n", |
||||
" { \"_id\": 3, \"name\": \"Amy\", \"address\": \"Apple st 652\"},\n", |
||||
" { \"_id\": 4, \"name\": \"Hannah\", \"address\": \"Mountain 21\"},\n", |
||||
" { \"_id\": 5, \"name\": \"Michael\", \"address\": \"Valley 345\"},\n", |
||||
" { \"_id\": 6, \"name\": \"Sandy\", \"address\": \"Ocean blvd 2\"},\n", |
||||
" { \"_id\": 7, \"name\": \"Betty\", \"address\": \"Green Grass 1\"},\n", |
||||
" { \"_id\": 8, \"name\": \"Richard\", \"address\": \"Sky st 331\"},\n", |
||||
" { \"_id\": 9, \"name\": \"Susan\", \"address\": \"One way 98\"},\n", |
||||
" { \"_id\": 10, \"name\": \"Vicky\", \"address\": \"Yellow Garden 2\"},\n", |
||||
" { \"_id\": 11, \"name\": \"Ben\", \"address\": \"Park Lane 38\"},\n", |
||||
" { \"_id\": 12, \"name\": \"William\", \"address\": \"Central st 954\"},\n", |
||||
" { \"_id\": 13, \"name\": \"Chuck\", \"address\": \"Main Road 989\"},\n", |
||||
" { \"_id\": 14, \"name\": \"Viola\", \"address\": \"Sideway 1633\"}\n", |
||||
"]\n", |
||||
"\n", |
||||
"x = mycol.insert_many(mylist)\n", |
||||
"\n", |
||||
"#print list of the _id values of the inserted documents:\n", |
||||
"print(x.inserted_ids)c" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "9a107bb3-0a12-4000-98b0-ac72b0b07731", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"myquery = { \"address\": \"Park Lane 38\" }\n", |
||||
"\n", |
||||
"mydoc = mycol.find(myquery)\n", |
||||
"\n", |
||||
"for x in mydoc:\n", |
||||
" print(x)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "191814c5-990e-4c30-9c5f-363fc479e734", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"import pymongo\n", |
||||
"\n", |
||||
"myclient = pymongo.MongoClient(\"mongodb://localhost:27017/\")\n", |
||||
"mydb = myclient[\"mydatabase\"]\n", |
||||
"mycol = mydb[\"customers\"]\n", |
||||
"\n", |
||||
"myquery = { \"address\": \"Mountain 21\" }\n", |
||||
"\n", |
||||
"mycol.delete_one(myquery)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "024256e0-4c13-4820-812b-c9cb7d7ff53b", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"mycol.drop()" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "62487b99-8edc-4179-a33b-28a0536afd1e", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"import pymongo\n", |
||||
"\n", |
||||
"myclient = pymongo.MongoClient(\"mongodb://localhost:27017/\")\n", |
||||
"mydb = myclient[\"mydatabase\"]\n", |
||||
"mycol = mydb[\"customers\"]\n", |
||||
"\n", |
||||
"for x in mycol.find({},{ \"_id\": 0, \"name\": 1, \"address\": 1 }):\n", |
||||
" print(x)" |
||||
] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3 (ipykernel)", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.10.5" |
||||
}, |
||||
"widgets": { |
||||
"application/vnd.jupyter.widget-state+json": { |
||||
"state": {}, |
||||
"version_major": 2, |
||||
"version_minor": 0 |
||||
} |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 5 |
||||
} |
||||
@ -0,0 +1 @@ |
||||
{"data":{"layout-restorer:data":{"main":{"dock":{"type":"tab-area","currentIndex":2,"widgets":["notebook:projects/secrets/jupyter-notebooks/data_transfer/Add Container Inventory to Directus.ipynb","notebook:projects/secrets/jupyter-notebooks/data_transfer/Add Homebrew Inventory to Directusa.ipynb","notebook:projects/secrets/jupyter-notebooks/storage/Untitled.ipynb","help-doc:https://docs.python.org/3.10","setting-editor:setting-editor","notebook:projects/secrets/jupyter-notebooks/data_transfer/Add Inventories to wiki.ipynb","notebook:projects/secrets/jupyter-notebooks/data_transfer/Directus query.ipynb"]},"current":"setting-editor:setting-editor"},"down":{"size":0,"widgets":[]},"left":{"collapsed":false,"current":"filebrowser","widgets":["filebrowser","running-sessions","git-sessions","@jupyterlab/toc:plugin","extensionmanager.main-view"]},"right":{"collapsed":true,"widgets":["jp-property-inspector","debugger-sidebar"]},"relativeSizes":[0.33482089182629515,0.6651791081737048,0]},"setting-editor:setting-editor":{"data":{}},"file-browser-filebrowser:cwd":{"path":"projects/secrets/jupyter-notebooks/storage"},"notebook:projects/secrets/jupyter-notebooks/data_transfer/Add Container Inventory to Directus.ipynb":{"data":{"path":"projects/secrets/jupyter-notebooks/data_transfer/Add Container Inventory to Directus.ipynb","factory":"Notebook"}},"notebook:projects/secrets/jupyter-notebooks/data_transfer/Add Homebrew Inventory to Directusa.ipynb":{"data":{"path":"projects/secrets/jupyter-notebooks/data_transfer/Add Homebrew Inventory to Directusa.ipynb","factory":"Notebook"}},"notebook:projects/secrets/jupyter-notebooks/data_transfer/Add Inventories to wiki.ipynb":{"data":{"path":"projects/secrets/jupyter-notebooks/data_transfer/Add Inventories to wiki.ipynb","factory":"Notebook"}},"notebook:projects/secrets/jupyter-notebooks/data_transfer/Directus query.ipynb":{"data":{"path":"projects/secrets/jupyter-notebooks/data_transfer/Directus query.ipynb","factory":"Notebook"}},"notebook:projects/secrets/jupyter-notebooks/storage/Untitled.ipynb":{"data":{"path":"projects/secrets/jupyter-notebooks/storage/Untitled.ipynb","factory":"Notebook"}},"help-doc:https://docs.python.org/3.10":{"data":{"url":"https://docs.python.org/3.10","text":"Python Reference"}},"help-doc:https://jupyter.org/documentation":{"data":{"url":"https://jupyter.org/documentation","text":"Jupyter Reference"}},"help-doc:https://jupyterlab.readthedocs.io/en/3.4.x/":{"data":{"url":"https://jupyterlab.readthedocs.io/en/3.4.x/","text":"JupyterLab Reference"}}},"metadata":{"id":"new-workspace","last_modified":"2022-08-26T06:51:28.885170+00:00","created":"2022-08-26T06:51:28.885170+00:00"}} |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,777 @@ |
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 26, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"Nodejs\n", |
||||
"Nodejs - Cross-Platform\n", |
||||
"Frontend Development\n", |
||||
"iOS\n", |
||||
"Android\n", |
||||
"IoT & Hybrid Apps\n", |
||||
"Electron\n", |
||||
"Cordova\n", |
||||
"React Native\n", |
||||
"Xamarin\n", |
||||
"Linux\n", |
||||
"Linux - Containers\n", |
||||
"Linux - eBPF\n", |
||||
"Linux - Arch-based Projects\n", |
||||
"Linux - AppImage\n", |
||||
"macOS - Screensavers\n", |
||||
"macOS - Apps\n", |
||||
"macOS - Open Source Apps\n", |
||||
"watchOS\n", |
||||
"JVM\n", |
||||
"Salesforce\n", |
||||
"Amazon Web Services\n", |
||||
"Windows\n", |
||||
"IPFS\n", |
||||
"Fuse\n", |
||||
"Heroku\n", |
||||
"Raspberry Pi\n", |
||||
"Qt\n", |
||||
"WebExtensions\n", |
||||
"Smart TV\n", |
||||
"GNOME\n", |
||||
"KDE\n", |
||||
"NET\n", |
||||
"NET - Core\n", |
||||
"NET - Roslyn\n", |
||||
"Amazon Alexa\n", |
||||
"DigitalOcean\n", |
||||
"Flutter\n", |
||||
"Home Assistant\n", |
||||
"IBM Cloud\n", |
||||
"Firebase\n", |
||||
"Robot Operating System 20\n", |
||||
"Adafruit IO\n", |
||||
"Cloudflare\n", |
||||
"Actions on Google\n", |
||||
"ESP\n", |
||||
"Deno\n", |
||||
"DOS\n", |
||||
"Nix\n", |
||||
"Integration\n", |
||||
"Node-RED\n", |
||||
"Low Code\n", |
||||
"Capacitor\n", |
||||
"ArcGIS Developer\n", |
||||
"JavaScript\n", |
||||
"JavaScript - Promises\n", |
||||
"JavaScript - Standard Style\n", |
||||
"JavaScript - Must Watch Talks\n", |
||||
"JavaScript - Tips\n", |
||||
"JavaScript - Network Layer\n", |
||||
"JavaScript - Micro npm Packages\n", |
||||
"JavaScript - Mad Science npm Packages\n", |
||||
"JavaScript - Maintenance Modules\n", |
||||
"JavaScript - npm\n", |
||||
"JavaScript - AVA\n", |
||||
"JavaScript - ESLint\n", |
||||
"JavaScript - Functional Programming\n", |
||||
"JavaScript - Observables\n", |
||||
"JavaScript - npm scripts\n", |
||||
"JavaScript - 30 Seconds of Code\n", |
||||
"JavaScript - Ponyfills\n", |
||||
"Swift\n", |
||||
"Swift - Education\n", |
||||
"Swift - Playgrounds\n", |
||||
"Python\n", |
||||
"Python - Asyncio\n", |
||||
"Python - Scientific Audio\n", |
||||
"Python - CircuitPython\n", |
||||
"Python - Data Science\n", |
||||
"Python - Typing\n", |
||||
"Python - MicroPython\n", |
||||
"Rust\n", |
||||
"Haskell\n", |
||||
"PureScript\n", |
||||
"Go\n", |
||||
"Scala\n", |
||||
"Scala - Scala Native\n", |
||||
"Ruby\n", |
||||
"Clojure\n", |
||||
"ClojureScript\n", |
||||
"Elixir\n", |
||||
"Elm\n", |
||||
"Erlang\n", |
||||
"Julia\n", |
||||
"Lua\n", |
||||
"C\n", |
||||
"C/C++\n", |
||||
"R\n", |
||||
"R - Learning\n", |
||||
"D\n", |
||||
"Common Lisp\n", |
||||
"Common Lisp - Learning\n", |
||||
"Perl\n", |
||||
"Groovy\n", |
||||
"Dart\n", |
||||
"Java\n", |
||||
"Java - RxJava\n", |
||||
"Kotlin\n", |
||||
"OCaml\n", |
||||
"ColdFusion\n", |
||||
"Fortran\n", |
||||
"PHP\n", |
||||
"PHP - Composer\n", |
||||
"Pascal\n", |
||||
"AutoHotkey\n", |
||||
"AutoIt\n", |
||||
"Crystal\n", |
||||
"Frege\n", |
||||
"CMake\n", |
||||
"ActionScript 3\n", |
||||
"Eta\n", |
||||
"Idris\n", |
||||
"Ada/SPARK\n", |
||||
"Q#\n", |
||||
"Imba\n", |
||||
"Vala\n", |
||||
"Coq\n", |
||||
"V\n", |
||||
"Zig\n", |
||||
"ES6 Tools\n", |
||||
"Web Performance Optimization\n", |
||||
"Web Tools\n", |
||||
"CSS\n", |
||||
"CSS - Critical-Path Tools\n", |
||||
"CSS - Scalability\n", |
||||
"CSS - Must-Watch Talks\n", |
||||
"CSS - Protips\n", |
||||
"CSS - Frameworks\n", |
||||
"React\n", |
||||
"React - Relay\n", |
||||
"React - React Hooks\n", |
||||
"Web Components\n", |
||||
"Polymer\n", |
||||
"Angular\n", |
||||
"Backbone\n", |
||||
"HTML5\n", |
||||
"SVG\n", |
||||
"Canvas\n", |
||||
"KnockoutJS\n", |
||||
"Dojo Toolkit\n", |
||||
"Inspiration\n", |
||||
"Ember\n", |
||||
"Android UI\n", |
||||
"iOS UI\n", |
||||
"Meteor\n", |
||||
"BEM\n", |
||||
"Flexbox\n", |
||||
"Web Typography\n", |
||||
"Web Accessibility\n", |
||||
"Material Design\n", |
||||
"D3\n", |
||||
"Emails\n", |
||||
"jQuery\n", |
||||
"jQuery - Tips\n", |
||||
"Web Audio\n", |
||||
"Offline-First\n", |
||||
"Static Website Services\n", |
||||
"Cyclejs\n", |
||||
"Text Editing\n", |
||||
"Motion UI Design\n", |
||||
"Vuejs\n", |
||||
"Marionettejs\n", |
||||
"Aurelia\n", |
||||
"Charting\n", |
||||
"Ionic Framework 2\n", |
||||
"Chrome DevTools\n", |
||||
"PostCSS\n", |
||||
"Draftjs\n", |
||||
"Service Workers\n", |
||||
"Progressive Web Apps\n", |
||||
"choo\n", |
||||
"Redux\n", |
||||
"Browserify\n", |
||||
"Sass\n", |
||||
"Ant Design\n", |
||||
"Less\n", |
||||
"WebGL\n", |
||||
"Preact\n", |
||||
"Progressive Enhancement\n", |
||||
"Nextjs\n", |
||||
"lit\n", |
||||
"JAMstack\n", |
||||
"WordPress-Gatsby\n", |
||||
"Mobile Web Development\n", |
||||
"Storybook\n", |
||||
"Blazor\n", |
||||
"PageSpeed Metrics\n", |
||||
"Tailwind CSS\n", |
||||
"Seed\n", |
||||
"Web Performance Budget\n", |
||||
"Web Animation\n", |
||||
"Yew\n", |
||||
"Material-UI\n", |
||||
"Building Blocks for Web Apps\n", |
||||
"Svelte\n", |
||||
"Design systems\n", |
||||
"Inertiajs\n", |
||||
"MDBootstrap\n", |
||||
"Flask\n", |
||||
"Docker\n", |
||||
"Vagrant\n", |
||||
"Pyramid\n", |
||||
"Play1 Framework\n", |
||||
"CakePHP\n", |
||||
"Symfony\n", |
||||
"Symfony - Education\n", |
||||
"Laravel\n", |
||||
"Laravel - Education\n", |
||||
"Laravel - TALL Stack\n", |
||||
"Rails\n", |
||||
"Rails - Gems\n", |
||||
"Phalcon\n", |
||||
"Useful htaccess Snippets\n", |
||||
"nginx\n", |
||||
"Dropwizard\n", |
||||
"Kubernetes\n", |
||||
"Lumen\n", |
||||
"Serverless Framework\n", |
||||
"Apache Wicket\n", |
||||
"Vertx\n", |
||||
"Terraform\n", |
||||
"Vapor\n", |
||||
"Dash\n", |
||||
"FastAPI\n", |
||||
"CDK\n", |
||||
"IAM\n", |
||||
"Slim\n", |
||||
"Fiber\n", |
||||
"University Courses\n", |
||||
"Data Science\n", |
||||
"Data Science - Tutorials\n", |
||||
"Machine Learning\n", |
||||
"Machine Learning - Tutorials\n", |
||||
"Machine Learning - ML with Ruby\n", |
||||
"Machine Learning - Core ML Models\n", |
||||
"Machine Learning - H2O\n", |
||||
"Machine Learning - Software Engineering for Machine Learning\n", |
||||
"Machine Learning - AI in Finance\n", |
||||
"Machine Learning - JAX\n", |
||||
"Machine Learning - XAI\n", |
||||
"Speech and Natural Language Processing\n", |
||||
"Speech and Natural Language Processing - Spanish\n", |
||||
"Speech and Natural Language Processing - NLP with Ruby\n", |
||||
"Speech and Natural Language Processing - Question Answering\n", |
||||
"Speech and Natural Language Processing - Natural Language Generation\n", |
||||
"Linguistics\n", |
||||
"Cryptography\n", |
||||
"Cryptography - Papers\n", |
||||
"Computer Vision\n", |
||||
"Deep Learning\n", |
||||
"Deep Learning - TensorFlow\n", |
||||
"Deep Learning - TensorFlowjs\n", |
||||
"Deep Learning - TensorFlow Lite\n", |
||||
"Deep Learning - Papers\n", |
||||
"Deep Learning - Education\n", |
||||
"Deep Vision\n", |
||||
"Open Source Society University\n", |
||||
"Functional Programming\n", |
||||
"Empirical Software Engineering\n", |
||||
"Static Analysis & Code Quality\n", |
||||
"Information Retrieval\n", |
||||
"Quantum Computing\n", |
||||
"Theoretical Computer Science\n", |
||||
"Conversational AI\n", |
||||
"Big Data\n", |
||||
"Public Datasets\n", |
||||
"Hadoop\n", |
||||
"Data Engineering\n", |
||||
"Streaming\n", |
||||
"Apache Spark\n", |
||||
"Qlik\n", |
||||
"Splunk\n", |
||||
"Papers We Love\n", |
||||
"Talks\n", |
||||
"Algorithms\n", |
||||
"Algorithms - Education\n", |
||||
"Algorithm Visualizations\n", |
||||
"Artificial Intelligence\n", |
||||
"Search Engine Optimization\n", |
||||
"Competitive Programming\n", |
||||
"Math\n", |
||||
"Recursion Schemes\n", |
||||
"Audit Algorithms\n", |
||||
"AGI & CoCoSci\n", |
||||
"Free Programming Books\n", |
||||
"Go Books\n", |
||||
"R Books\n", |
||||
"Mind Expanding Books\n", |
||||
"Book Authoring\n", |
||||
"Elixir Books\n", |
||||
"Sublime Text\n", |
||||
"Vim\n", |
||||
"Neovim\n", |
||||
"Emacs\n", |
||||
"Atom\n", |
||||
"Visual Studio Code\n", |
||||
"Game Development\n", |
||||
"Game Talks\n", |
||||
"Godot\n", |
||||
"Open Source Games\n", |
||||
"Unity\n", |
||||
"Chess\n", |
||||
"LÖVE\n", |
||||
"PICO-8\n", |
||||
"Game Boy Development\n", |
||||
"Construct 2\n", |
||||
"Gideros\n", |
||||
"Minecraft\n", |
||||
"Game Datasets\n", |
||||
"Haxe Game Development\n", |
||||
"libGDX\n", |
||||
"PlayCanvas\n", |
||||
"Game Remakes\n", |
||||
"Flame\n", |
||||
"Discord Communities\n", |
||||
"CHIP-8\n", |
||||
"Games of Coding\n", |
||||
"Esports\n", |
||||
"Quick Look Plugins\n", |
||||
"Dev Env\n", |
||||
"Dotfiles\n", |
||||
"Shell\n", |
||||
"Fish\n", |
||||
"Command-Line Apps\n", |
||||
"ZSH Plugins\n", |
||||
"GitHub\n", |
||||
"GitHub - Browser Extensions\n", |
||||
"GitHub - Cheat Sheet\n", |
||||
"GitHub - Pinned Gists\n", |
||||
"Git Cheat Sheet & Git Flow\n", |
||||
"Git Tips\n", |
||||
"Git Add-ons\n", |
||||
"Git Hooks\n", |
||||
"SSH\n", |
||||
"FOSS for Developers\n", |
||||
"Hyper\n", |
||||
"PowerShell\n", |
||||
"Alfred Workflows\n", |
||||
"Terminals Are Sexy\n", |
||||
"GitHub Actions\n", |
||||
"Science Fiction\n", |
||||
"Fantasy\n", |
||||
"Podcasts\n", |
||||
"Email Newsletters\n", |
||||
"IT Quotes\n", |
||||
"Database\n", |
||||
"MySQL\n", |
||||
"SQLAlchemy\n", |
||||
"InfluxDB\n", |
||||
"Neo4j\n", |
||||
"MongoDB\n", |
||||
"RethinkDB\n", |
||||
"TinkerPop\n", |
||||
"PostgreSQL\n", |
||||
"CouchDB\n", |
||||
"HBase\n", |
||||
"NoSQL Guides\n", |
||||
"Database Tools\n", |
||||
"TypeDB\n", |
||||
"Cassandra\n", |
||||
"TDengine\n", |
||||
"Creative Commons Media\n", |
||||
"Fonts\n", |
||||
"Codeface\n", |
||||
"Stock Resources\n", |
||||
"GIF\n", |
||||
"Music\n", |
||||
"Open Source Documents\n", |
||||
"Audio Visualization\n", |
||||
"Broadcasting\n", |
||||
"Pixel Art\n", |
||||
"FFmpeg\n", |
||||
"Icons\n", |
||||
"Audiovisual\n", |
||||
"VLC\n", |
||||
"CLI Workshoppers\n", |
||||
"Learn to Program\n", |
||||
"Speaking\n", |
||||
"Tech Videos\n", |
||||
"Dive into Machine Learning\n", |
||||
"Computer History\n", |
||||
"Programming for Kids\n", |
||||
"Educational Games\n", |
||||
"JavaScript Learning\n", |
||||
"CSS Learning\n", |
||||
"Product Management\n", |
||||
"Roadmaps\n", |
||||
"YouTubers\n", |
||||
"Application Security\n", |
||||
"Security\n", |
||||
"CTF\n", |
||||
"Cyber Security University\n", |
||||
"Malware Analysis\n", |
||||
"Android Security\n", |
||||
"Hacking\n", |
||||
"Hacking Spots\n", |
||||
"Honeypots\n", |
||||
"Incident Response\n", |
||||
"Vehicle Security and Car Hacking\n", |
||||
"Web Security\n", |
||||
"Lockpicking\n", |
||||
"Cybersecurity Blue Team\n", |
||||
"Fuzzing\n", |
||||
"Embedded and IoT Security\n", |
||||
"GDPR\n", |
||||
"DevSecOps\n", |
||||
"Executable Packing\n", |
||||
"Malware Persistence\n", |
||||
"EVM Security\n", |
||||
"Umbraco\n", |
||||
"Refinery CMS\n", |
||||
"Wagtail\n", |
||||
"Textpattern\n", |
||||
"Drupal\n", |
||||
"Craft CMS\n", |
||||
"Sitecore\n", |
||||
"Silverstripe CMS\n", |
||||
"Directus\n", |
||||
"Plone\n", |
||||
"Robotics\n", |
||||
"Internet of Things\n", |
||||
"Electronics\n", |
||||
"Bluetooth Beacons\n", |
||||
"Electric Guitar Specifications\n", |
||||
"Plotters\n", |
||||
"Robotic Tooling\n", |
||||
"LIDAR\n", |
||||
"Open Hardware\n", |
||||
"Open Companies\n", |
||||
"Places to Post Your Startup\n", |
||||
"OKR Methodology\n", |
||||
"Leading and Managing\n", |
||||
"Indie\n", |
||||
"Tools of the Trade\n", |
||||
"Clean Tech\n", |
||||
"Wardley Maps\n", |
||||
"Social Enterprise\n", |
||||
"Engineering Team Management\n", |
||||
"Developer-First Products\n", |
||||
"Billing\n", |
||||
"Slack\n", |
||||
"Slack - Communities\n", |
||||
"Remote Jobs\n", |
||||
"Productivity\n", |
||||
"Niche Job Boards\n", |
||||
"Programming Interviews\n", |
||||
"Code Review\n", |
||||
"Creative Technology\n", |
||||
"Internships\n", |
||||
"Software-Defined Networking\n", |
||||
"Network Analysis\n", |
||||
"PCAPTools\n", |
||||
"Real-Time Communications\n", |
||||
"SNMP\n", |
||||
"Bitcoin\n", |
||||
"Ripple\n", |
||||
"Non-Financial Blockchain\n", |
||||
"Mastodon\n", |
||||
"Ethereum\n", |
||||
"Blockchain AI\n", |
||||
"EOSIO\n", |
||||
"Corda\n", |
||||
"Waves\n", |
||||
"Substrate\n", |
||||
"Golem\n", |
||||
"Stacks\n", |
||||
"Algorand\n", |
||||
"Computational Neuroscience\n", |
||||
"Digital History\n", |
||||
"Scientific Writing\n", |
||||
"Creative Tech Events\n", |
||||
"Events in Italy\n", |
||||
"Events in the Netherlands\n", |
||||
"Testing\n", |
||||
"Visual Regression Testing\n", |
||||
"Selenium\n", |
||||
"Appium\n", |
||||
"TAP\n", |
||||
"JMeter\n", |
||||
"k6\n", |
||||
"Playwright\n", |
||||
"Quality Assurance Roadmap\n", |
||||
"Gatling\n", |
||||
"JSON\n", |
||||
"JSON - GeoJSON\n", |
||||
"JSON - Datasets\n", |
||||
"CSV\n", |
||||
"Discounts for Student Developers\n", |
||||
"Radio\n", |
||||
"Awesome\n", |
||||
"{'name': 'Awesome', 'url': 'https://github.com/sindresorhus/awesome', 'repo': 'sindresorhus/awesome', 'cate': 'Miscellaneous'}\n", |
||||
"Analytics\n", |
||||
"REST\n", |
||||
"Continuous Integration and Continuous Delivery\n", |
||||
"Services Engineering\n", |
||||
"Free for Developers\n", |
||||
"Answers\n", |
||||
"Sketch\n", |
||||
"Boilerplate Projects\n", |
||||
"Readme\n", |
||||
"Design and Development Guides\n", |
||||
"Software Engineering Blogs\n", |
||||
"Self Hosted\n", |
||||
"FOSS Production Apps\n", |
||||
"Gulp\n", |
||||
"AMA\n", |
||||
"AMA - Answers\n", |
||||
"Open Source Photography\n", |
||||
"OpenGL\n", |
||||
"GraphQL\n", |
||||
"Urban & Regional Planning\n", |
||||
"Transit\n", |
||||
"Research Tools\n", |
||||
"Data Visualization\n", |
||||
"Microservices\n", |
||||
"Unicode\n", |
||||
"Unicode - Code Points\n", |
||||
"Beginner-Friendly Projects\n", |
||||
"Katas\n", |
||||
"Tools for Activism\n", |
||||
"Citizen Science\n", |
||||
"MQTT\n", |
||||
"For Girls\n", |
||||
"Vorpal\n", |
||||
"Vulkan\n", |
||||
"LaTeX\n", |
||||
"Economics\n", |
||||
"Funny Markov Chains\n", |
||||
"Bioinformatics\n", |
||||
"Cheminformatics\n", |
||||
"Colorful\n", |
||||
"Steam\n", |
||||
"Bots\n", |
||||
"Site Reliability Engineering\n", |
||||
"Empathy in Engineering\n", |
||||
"DTrace\n", |
||||
"Userscripts\n", |
||||
"Pokémon\n", |
||||
"ChatOps\n", |
||||
"Falsehood\n", |
||||
"Domain-Driven Design\n", |
||||
"Quantified Self\n", |
||||
"SaltStack\n", |
||||
"Web Design\n", |
||||
"Creative Coding\n", |
||||
"No-Login Web Apps\n", |
||||
"Free Software\n", |
||||
"Framer\n", |
||||
"Markdown\n", |
||||
"Dev Fun\n", |
||||
"Healthcare\n", |
||||
"Magento 2\n", |
||||
"TikZ\n", |
||||
"Neuroscience\n", |
||||
"Ad-Free\n", |
||||
"Esolangs\n", |
||||
"Prometheus\n", |
||||
"Homematic\n", |
||||
"Ledger\n", |
||||
"Web Monetization\n", |
||||
"Uncopyright\n", |
||||
"Crypto Currency Tools & Algorithms\n", |
||||
"Diversity\n", |
||||
"Open Source Supporters\n", |
||||
"Design Principles\n", |
||||
"Theravada\n", |
||||
"inspectIT\n", |
||||
"Open Source Maintainers\n", |
||||
"Calculators\n", |
||||
"Captcha\n", |
||||
"Jupyter\n", |
||||
"FIRST Robotics Competition\n", |
||||
"Humane Technology\n", |
||||
"Speakers\n", |
||||
"Board Games\n", |
||||
"Software Patreons\n", |
||||
"Parasite\n", |
||||
"Food\n", |
||||
"Mental Health\n", |
||||
"Bitcoin Payment Processors\n", |
||||
"Scientific Computing\n", |
||||
"Amazon Sellers\n", |
||||
"Agriculture\n", |
||||
"Product Design\n", |
||||
"Prisma\n", |
||||
"Software Architecture\n", |
||||
"Connectivity Data and Reports\n", |
||||
"Stacks\n", |
||||
"Cytodata\n", |
||||
"IRC\n", |
||||
"Advertising\n", |
||||
"Earth\n", |
||||
"Naming\n", |
||||
"Biomedical Information Extraction\n", |
||||
"Web Archiving\n", |
||||
"WP-CLI\n", |
||||
"Credit Modeling\n", |
||||
"Ansible\n", |
||||
"Biological Visualizations\n", |
||||
"QR Code\n", |
||||
"Veganism\n", |
||||
"Translations\n", |
||||
"Scriptable\n", |
||||
"WebXR\n", |
||||
"OpenStreetMap\n", |
||||
"Computational Biology\n", |
||||
"All Awesome Lists\n", |
||||
"{'name': 'All Awesome Lists', 'url': 'https://github.com/topics/awesome', 'repo': 'topics/awesome', 'cate': 'Related'}\n", |
||||
"Awesome Indexed\n", |
||||
"{'name': 'Awesome Indexed', 'url': 'https://awesome-indexed.mathew-davies.co.uk', 'repo': 'undefined/undefined', 'cate': 'Related'}\n", |
||||
"Awesome Search\n", |
||||
"{'name': 'Awesome Search', 'url': 'https://awesomelists.top', 'repo': 'undefined/undefined', 'cate': 'Related'}\n", |
||||
"StumbleUponAwesome\n", |
||||
"Awesome CLI\n", |
||||
"Awesome Viewer\n", |
||||
"{'name': 'Awesome Viewer', 'url': 'https://awesome.digitalbunker.dev', 'repo': 'undefined/undefined', 'cate': 'Related'}\n", |
||||
"Track Awesome List\n", |
||||
"{'name': 'Track Awesome List', 'url': 'https://www.trackawesomelist.com', 'repo': 'undefined/undefined', 'cate': 'Related'}\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"import json\n", |
||||
"import pprint\n", |
||||
"import requests\n", |
||||
"import pymongo\n", |
||||
"\n", |
||||
"myclient = pymongo.MongoClient(\n", |
||||
" \"mongodb://user:pass@192.168.1.101:27017\")\n", |
||||
"# DB\n", |
||||
"\n", |
||||
"data = requests.get(\n", |
||||
" \"https://raw.githubusercontent.com/lockys/Awesome.json/master/awesome/awesome.json?ref=master\",\n", |
||||
" headers={\"Accept\": \"application/vnd.github.v3+json\"},\n", |
||||
")\n", |
||||
"#\n", |
||||
"\n", |
||||
"repos = data.json()\n", |
||||
"\n", |
||||
"for x in repos.values():\n", |
||||
" for z in x:\n", |
||||
" try:\n", |
||||
" string = z['repo']\n", |
||||
"# if len(z['name']) > 0:\n", |
||||
"# title = z['name']\n", |
||||
"# else:\n", |
||||
"# title = \"none\"\n", |
||||
"# # print(count)\n", |
||||
" title = z['name']\n", |
||||
" title = title.replace(\".\", \"\")\n", |
||||
" link = string.replace(\"/\", \"-\")\n", |
||||
"\n", |
||||
" mydb = myclient[\"awesome-lists\"]\n", |
||||
" mycol = mydb[title]\n", |
||||
"\n", |
||||
" one_list = requests.get(\n", |
||||
" \"https://raw.githubusercontent.com/lockys/awesome.json/master/repo-json/\"\n", |
||||
" + link + \".json\",\n", |
||||
" headers={\"Accept\": \"application/vnd.github.v3+json\"},\n", |
||||
" )\n", |
||||
" print(title)\n", |
||||
" for x in one_list.json():\n", |
||||
" try:\n", |
||||
" mydict = x\n", |
||||
"\n", |
||||
"# pprint.pprint(mydict)\n", |
||||
"\n", |
||||
" new = mycol.insert_one(mydict)\n", |
||||
"\n", |
||||
" # print(new.inserted_id)\n", |
||||
" except:\n", |
||||
" print(x)\n", |
||||
" except ValueError as error:\n", |
||||
" print(z)\n", |
||||
"# print(\"invalid json: %s\" % error)\n" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 13, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"63136ab944dfc9e0de996f01\n", |
||||
"['test']\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"import pymongo\n", |
||||
"\n", |
||||
"myclient = pymongo.MongoClient(\"mongodb://user:pass@192.168.1.101:27017\")\n", |
||||
"# DB\n", |
||||
"\n", |
||||
"mydb = myclient[\"awesome-lists\"]\n", |
||||
"\n", |
||||
"# Collectinon\n", |
||||
"\n", |
||||
"mycol = mydb[\"test\"]\n", |
||||
"\n", |
||||
"mydict = {\"name\": \"Peter\", \"address\": \"Lowstreet 27\"}\n", |
||||
"\n", |
||||
"x = mycol.insert_one(mydict)\n", |
||||
"\n", |
||||
"print(x.inserted_id)\n", |
||||
"\n", |
||||
"print(mydb.list_collection_names())" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"!pip install pymongo" |
||||
] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3 (ipykernel)", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.10.6" |
||||
}, |
||||
"vscode": { |
||||
"interpreter": { |
||||
"hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1" |
||||
} |
||||
}, |
||||
"widgets": { |
||||
"application/vnd.jupyter.widget-state+json": { |
||||
"state": {}, |
||||
"version_major": 2, |
||||
"version_minor": 0 |
||||
} |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 4 |
||||
} |
||||
@ -0,0 +1,241 @@ |
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 9, |
||||
"id": "22005864-a267-4819-b083-935a85452b39", |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"Requirement already satisfied: pymongo in /opt/conda/lib/python3.10/site-packages (4.2.0)\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"!pip install pymongo" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 10, |
||||
"id": "d1690099-dbf9-4d75-946c-c556c13ec34d", |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"630855c7014e9a17ccd6bd03\n", |
||||
"['customers']\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"import pymongo\n", |
||||
"\n", |
||||
"myclient = pymongo.MongoClient(\"mongodb://user:pass@mongo:27017\")\n", |
||||
"# DB\n", |
||||
"\n", |
||||
"mydb = myclient[\"mydatabase\"]\n", |
||||
"\n", |
||||
"# Collectino\n", |
||||
"\n", |
||||
"mycol = mydb[\"customers\"]\n", |
||||
"\n", |
||||
"mydict = { \"name\": \"Peter\", \"address\": \"Lowstreet 27\" }\n", |
||||
"\n", |
||||
"x = mycol.insert_one(mydict)\n", |
||||
"\n", |
||||
"print(x.inserted_id)\n", |
||||
"\n", |
||||
"print(mydb.list_collection_names())" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "markdown", |
||||
"id": "d97181c9-08bb-47c0-a8a3-50f8ea878a15", |
||||
"metadata": {}, |
||||
"source": [ |
||||
"# hjhj" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 5, |
||||
"id": "54535d13-e279-44bc-bd9d-52d14cb550fb", |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"[]\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"# DB\n", |
||||
"\n", |
||||
"mydb = myclient[\"mydatabase\"]\n", |
||||
"\n", |
||||
"# Collectino\n", |
||||
"\n", |
||||
"mycol = mydb[\"customers\"]\n", |
||||
"\n", |
||||
"print(mydb.list_collection_names())" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "markdown", |
||||
"id": "7b7a6e52-4de9-4f6d-91b4-b3716baba323", |
||||
"metadata": {}, |
||||
"source": [] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "7ed477f1-9044-498c-9d3e-5021df5bdc93", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"mydict = { \"name\": \"Peter\", \"address\": \"Lowstreet 27\" }\n", |
||||
"\n", |
||||
"x = mycol.insert_one(mydict)\n", |
||||
"\n", |
||||
"print(x.inserted_id)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "markdown", |
||||
"id": "efb52832-dc7d-4e4c-b70c-d29b923f02db", |
||||
"metadata": {}, |
||||
"source": [] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "430085cf-e0b4-4a12-b382-90f9351e5490", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"mylist = [\n", |
||||
" { \"_id\": 1, \"name\": \"John\", \"address\": \"Highway 37\"},\n", |
||||
" { \"_id\": 2, \"name\": \"Peter\", \"address\": \"Lowstreet 27\"},\n", |
||||
" { \"_id\": 3, \"name\": \"Amy\", \"address\": \"Apple st 652\"},\n", |
||||
" { \"_id\": 4, \"name\": \"Hannah\", \"address\": \"Mountain 21\"},\n", |
||||
" { \"_id\": 5, \"name\": \"Michael\", \"address\": \"Valley 345\"},\n", |
||||
" { \"_id\": 6, \"name\": \"Sandy\", \"address\": \"Ocean blvd 2\"},\n", |
||||
" { \"_id\": 7, \"name\": \"Betty\", \"address\": \"Green Grass 1\"},\n", |
||||
" { \"_id\": 8, \"name\": \"Richard\", \"address\": \"Sky st 331\"},\n", |
||||
" { \"_id\": 9, \"name\": \"Susan\", \"address\": \"One way 98\"},\n", |
||||
" { \"_id\": 10, \"name\": \"Vicky\", \"address\": \"Yellow Garden 2\"},\n", |
||||
" { \"_id\": 11, \"name\": \"Ben\", \"address\": \"Park Lane 38\"},\n", |
||||
" { \"_id\": 12, \"name\": \"William\", \"address\": \"Central st 954\"},\n", |
||||
" { \"_id\": 13, \"name\": \"Chuck\", \"address\": \"Main Road 989\"},\n", |
||||
" { \"_id\": 14, \"name\": \"Viola\", \"address\": \"Sideway 1633\"}\n", |
||||
"]\n", |
||||
"\n", |
||||
"x = mycol.insert_many(mylist)\n", |
||||
"\n", |
||||
"#print list of the _id values of the inserted documents:\n", |
||||
"print(x.inserted_ids)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "9a107bb3-0a12-4000-98b0-ac72b0b07731", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"myquery = { \"address\": \"Park Lane 38\" }\n", |
||||
"\n", |
||||
"mydoc = mycol.find(myquery)\n", |
||||
"\n", |
||||
"for x in mydoc:\n", |
||||
" print(x)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "191814c5-990e-4c30-9c5f-363fc479e734", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"import pymongo\n", |
||||
"\n", |
||||
"myclient = pymongo.MongoClient(\"mongodb://localhost:27017/\")\n", |
||||
"mydb = myclient[\"mydatabase\"]\n", |
||||
"mycol = mydb[\"customers\"]\n", |
||||
"\n", |
||||
"myquery = { \"address\": \"Mountain 21\" }\n", |
||||
"\n", |
||||
"mycol.delete_one(myquery)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "024256e0-4c13-4820-812b-c9cb7d7ff53b", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"mycol.drop()" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "62487b99-8edc-4179-a33b-28a0536afd1e", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"import pymongo\n", |
||||
"\n", |
||||
"myclient = pymongo.MongoClient(\"mongodb://localhost:27017/\")\n", |
||||
"mydb = myclient[\"mydatabase\"]\n", |
||||
"mycol = mydb[\"customers\"]\n", |
||||
"\n", |
||||
"for x in mycol.find({},{ \"_id\": 0, \"name\": 1, \"address\": 1 }):\n", |
||||
" print(x)" |
||||
] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3 (ipykernel)", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.10.6" |
||||
}, |
||||
"vscode": { |
||||
"interpreter": { |
||||
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" |
||||
} |
||||
}, |
||||
"widgets": { |
||||
"application/vnd.jupyter.widget-state+json": { |
||||
"state": {}, |
||||
"version_major": 2, |
||||
"version_minor": 0 |
||||
} |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 5 |
||||
} |
||||
@ -0,0 +1,96 @@ |
||||
{ |
||||
"data": { |
||||
"layout-restorer:data": { |
||||
"main": { |
||||
"dock": { |
||||
"type": "tab-area", |
||||
"currentIndex": 2, |
||||
"widgets": [ |
||||
"notebook:projects/secrets/jupyter-notebooks/data_transfer/Add Container Inventory to Directus.ipynb", |
||||
"notebook:projects/secrets/jupyter-notebooks/data_transfer/Add Homebrew Inventory to Directusa.ipynb", |
||||
"notebook:projects/secrets/jupyter-notebooks/storage/Untitled.ipynb", |
||||
"help-doc:https://docs.python.org/3.10", |
||||
"setting-editor:setting-editor", |
||||
"notebook:projects/secrets/jupyter-notebooks/data_transfer/Add Inventories to wiki.ipynb", |
||||
"notebook:projects/secrets/jupyter-notebooks/data_transfer/Directus query.ipynb" |
||||
] |
||||
}, |
||||
"current": "setting-editor:setting-editor" |
||||
}, |
||||
"down": { "size": 0, "widgets": [] }, |
||||
"left": { |
||||
"collapsed": false, |
||||
"current": "filebrowser", |
||||
"widgets": [ |
||||
"filebrowser", |
||||
"running-sessions", |
||||
"git-sessions", |
||||
"@jupyterlab/toc:plugin", |
||||
"extensionmanager.main-view" |
||||
] |
||||
}, |
||||
"right": { |
||||
"collapsed": true, |
||||
"widgets": ["jp-property-inspector", "debugger-sidebar"] |
||||
}, |
||||
"relativeSizes": [0.33482089182629515, 0.6651791081737048, 0] |
||||
}, |
||||
"setting-editor:setting-editor": { "data": {} }, |
||||
"file-browser-filebrowser:cwd": { |
||||
"path": "projects/secrets/jupyter-notebooks/storage" |
||||
}, |
||||
"notebook:projects/secrets/jupyter-notebooks/data_transfer/Add Container Inventory to Directus.ipynb": { |
||||
"data": { |
||||
"path": "projects/secrets/jupyter-notebooks/data_transfer/Add Container Inventory to Directus.ipynb", |
||||
"factory": "Notebook" |
||||
} |
||||
}, |
||||
"notebook:projects/secrets/jupyter-notebooks/data_transfer/Add Homebrew Inventory to Directusa.ipynb": { |
||||
"data": { |
||||
"path": "projects/secrets/jupyter-notebooks/data_transfer/Add Homebrew Inventory to Directusa.ipynb", |
||||
"factory": "Notebook" |
||||
} |
||||
}, |
||||
"notebook:projects/secrets/jupyter-notebooks/data_transfer/Add Inventories to wiki.ipynb": { |
||||
"data": { |
||||
"path": "projects/secrets/jupyter-notebooks/data_transfer/Add Inventories to wiki.ipynb", |
||||
"factory": "Notebook" |
||||
} |
||||
}, |
||||
"notebook:projects/secrets/jupyter-notebooks/data_transfer/Directus query.ipynb": { |
||||
"data": { |
||||
"path": "projects/secrets/jupyter-notebooks/data_transfer/Directus query.ipynb", |
||||
"factory": "Notebook" |
||||
} |
||||
}, |
||||
"notebook:projects/secrets/jupyter-notebooks/storage/Untitled.ipynb": { |
||||
"data": { |
||||
"path": "projects/secrets/jupyter-notebooks/storage/Untitled.ipynb", |
||||
"factory": "Notebook" |
||||
} |
||||
}, |
||||
"help-doc:https://docs.python.org/3.10": { |
||||
"data": { |
||||
"url": "https://docs.python.org/3.10", |
||||
"text": "Python Reference" |
||||
} |
||||
}, |
||||
"help-doc:https://jupyter.org/documentation": { |
||||
"data": { |
||||
"url": "https://jupyter.org/documentation", |
||||
"text": "Jupyter Reference" |
||||
} |
||||
}, |
||||
"help-doc:https://jupyterlab.readthedocs.io/en/3.4.x/": { |
||||
"data": { |
||||
"url": "https://jupyterlab.readthedocs.io/en/3.4.x/", |
||||
"text": "JupyterLab Reference" |
||||
} |
||||
} |
||||
}, |
||||
"metadata": { |
||||
"id": "new-workspace", |
||||
"last_modified": "2022-08-26T06:51:28.885170+00:00", |
||||
"created": "2022-08-26T06:51:28.885170+00:00" |
||||
} |
||||
} |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,158 @@ |
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "markdown", |
||||
"id": "f1543948-4781-4f50-849e-1e8b9786b7bb", |
||||
"metadata": {}, |
||||
"source": [ |
||||
"# Splash" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "markdown", |
||||
"id": "18805201-1cec-439d-bb09-ac9beba683b2", |
||||
"metadata": {}, |
||||
"source": [ |
||||
"render.json\n", |
||||
"Return a json-encoded dictionary with information about javascript-rendered webpage. It can include HTML, PNG and other information, based on arguments passed.\n", |
||||
"\n", |
||||
"Arguments:\n", |
||||
"\n", |
||||
"Same as render.jpeg plus the following ones:\n", |
||||
"\n", |
||||
"html : integer : optional\n", |
||||
"Whether to include HTML in output. Possible values are 1 (include) and 0 (exclude). Default is 0.\n", |
||||
"png : integer : optional\n", |
||||
"Whether to include PNG in output. Possible values are 1 (include) and 0 (exclude). Default is 0.\n", |
||||
"jpeg : integer : optional\n", |
||||
"Whether to include JPEG in output. Possible values are 1 (include) and 0 (exclude). Default is 0.\n", |
||||
"iframes : integer : optional\n", |
||||
"Whether to include information about child frames in output. Possible values are 1 (include) and 0 (exclude). Default is 0.\n", |
||||
"script : integer : optional\n", |
||||
"Whether to include the result of the executed javascript final statement in output (see Executing custom Javascript code within page context). Possible values are 1 (include) and 0 (exclude). Default is 0.\n", |
||||
"console : integer : optional\n", |
||||
"Whether to include the executed javascript console messages in output. Possible values are 1 (include) and 0 (exclude). Default is 0.\n", |
||||
"history : integer : optional\n", |
||||
"Whether to include the history of requests/responses for webpage main frame. Possible values are 1 (include) and 0 (exclude). Default is 0.\n", |
||||
"\n", |
||||
"Use it to get HTTP status codes and headers. Only information about “main” requests/responses is returned (i.e. information about related resources like images and AJAX queries is not returned). To get information about all requests and responses use ‘har’ argument.\n", |
||||
"\n", |
||||
"har : integer : optional\n", |
||||
"Whether to include HAR in output. Possible values are 1 (include) and 0 (exclude). Default is 0. If this option is ON the result will contain the same data as render.har provides under ‘har’ key.\n", |
||||
"\n", |
||||
"By default, request and response contents are not included. To enable each, use ‘request_body’ and ‘response_body’ options respectively.\n", |
||||
"\n", |
||||
"request_body : int : optional\n", |
||||
"Possible values are 1 and 0. When request_body=1, request content is included in HAR records. Default is request_body=0. This option has no effect when both ‘har’ and ‘history’ are 0.\n", |
||||
"response_body : int : optiona" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "8aaec01c-4b87-4949-8787-e9dec8b2e5dd", |
||||
"metadata": { |
||||
"execution": { |
||||
"iopub.execute_input": "2021-10-26T03:50:20.355782Z", |
||||
"iopub.status.busy": "2021-10-26T03:50:20.355387Z", |
||||
"iopub.status.idle": "2021-10-26T03:50:20.870039Z", |
||||
"shell.execute_reply": "2021-10-26T03:50:20.855218Z", |
||||
"shell.execute_reply.started": "2021-10-26T03:50:20.355743Z" |
||||
}, |
||||
"tags": [] |
||||
}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"import json\n", |
||||
"import pprint\n", |
||||
"\n", |
||||
"import requests\n", |
||||
"\n", |
||||
"# script = \"\"\"\n", |
||||
"# splash:go(args.url)\n", |
||||
"# return splash:png()\n", |
||||
"# \"\"\"\n", |
||||
"\n", |
||||
"\n", |
||||
"resp = requests.post(\n", |
||||
" \"https://kong.donavanaldrich.com/splash\",\n", |
||||
" json={\n", |
||||
" \"url\": \"http://example.com\",\n", |
||||
" \"history\": 1,\n", |
||||
" \"html\": 1,\n", |
||||
" \"request_body\": 1,\n", |
||||
" \"har\": 1,\n", |
||||
" },\n", |
||||
")\n", |
||||
"png_data = resp.content\n", |
||||
"\n", |
||||
"pp = pprint.PrettyPrinter(indent=4, sort_dicts=True)\n", |
||||
"pp.pprint(png_data)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "1630de92-c015-43a3-b747-9d29ca5afba2", |
||||
"metadata": { |
||||
"execution": { |
||||
"iopub.execute_input": "2021-10-26T04:36:51.911804Z", |
||||
"iopub.status.busy": "2021-10-26T04:36:51.911422Z", |
||||
"iopub.status.idle": "2021-10-26T04:36:55.323679Z", |
||||
"shell.execute_reply": "2021-10-26T04:36:55.322189Z", |
||||
"shell.execute_reply.started": "2021-10-26T04:36:51.911765Z" |
||||
}, |
||||
"tags": [] |
||||
}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"# json: {url: \"http://example.com\", history: 1, html: 1, request_body: 1, har: 1}\n", |
||||
"# !http POST https://kong.donavanaldrich.com/splash < json\n", |
||||
"\n", |
||||
"\n", |
||||
"!http POST https://kong.donavanaldrich.com/splash url=http://example.com har:=1 html:=1 png:=1 history:=1 console:=1" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "bc1283f7-19f8-4430-9ae6-19a74c419a91", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3 (ipykernel)", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.10.6" |
||||
}, |
||||
"vscode": { |
||||
"interpreter": { |
||||
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" |
||||
} |
||||
}, |
||||
"widgets": { |
||||
"application/vnd.jupyter.widget-state+json": { |
||||
"state": {}, |
||||
"version_major": 2, |
||||
"version_minor": 0 |
||||
} |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 5 |
||||
} |
||||
@ -0,0 +1,179 @@ |
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 8, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"<!DOCTYPE html><html><head>\n", |
||||
" <title>Example Domain</title>\n", |
||||
"\n", |
||||
" <meta charset=\"utf-8\">\n", |
||||
" <meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\">\n", |
||||
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n", |
||||
" <style type=\"text/css\">\n", |
||||
" body {\n", |
||||
" background-color: #f0f0f2;\n", |
||||
" margin: 0;\n", |
||||
" padding: 0;\n", |
||||
" font-family: -apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", \"Open Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n", |
||||
" \n", |
||||
" }\n", |
||||
" div {\n", |
||||
" width: 600px;\n", |
||||
" margin: 5em auto;\n", |
||||
" padding: 2em;\n", |
||||
" background-color: #fdfdff;\n", |
||||
" border-radius: 0.5em;\n", |
||||
" box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);\n", |
||||
" }\n", |
||||
" a:link, a:visited {\n", |
||||
" color: #38488f;\n", |
||||
" text-decoration: none;\n", |
||||
" }\n", |
||||
" @media (max-width: 700px) {\n", |
||||
" div {\n", |
||||
" margin: 0 auto;\n", |
||||
" width: auto;\n", |
||||
" }\n", |
||||
" }\n", |
||||
" </style> \n", |
||||
"</head>\n", |
||||
"\n", |
||||
"<body>\n", |
||||
"<div>\n", |
||||
" <h1>Example Domain</h1>\n", |
||||
" <p>This domain is for use in illustrative examples in documents. You may use this\n", |
||||
" domain in literature without prior coordination or asking for permission.</p>\n", |
||||
" <p><a href=\"https://www.iana.org/domains/example\">More information...</a></p>\n", |
||||
"</div>\n", |
||||
"\n", |
||||
"\n", |
||||
"</body></html>" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"!curl -X POST http://192.168.1.101:3148/content \\\n", |
||||
"-H 'Cache-Control: no-cache' -H 'Content-Type: application/json' -d '{\"url\": \"https://example.com/\" }'" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 15, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"{'allowFileProtocol': False,\n", |
||||
" 'chromeRefreshTime': 1800000,\n", |
||||
" 'connectionTimeout': 600000,\n", |
||||
" 'disabledFeatures': [],\n", |
||||
" 'enableAPIGet': False,\n", |
||||
" 'enableCors': False,\n", |
||||
" 'enableHeapdump': False,\n", |
||||
" 'errorAlertURL': None,\n", |
||||
" 'exitOnHealthFailure': False,\n", |
||||
" 'functionBuiltIns': ['url'],\n", |
||||
" 'functionEnableIncognitoMode': False,\n", |
||||
" 'functionEnvVars': [],\n", |
||||
" 'functionExternals': ['lighthouse', 'node-pdftk', 'sharp'],\n", |
||||
" 'healthFailureURL': None,\n", |
||||
" 'host': '0.0.0.0',\n", |
||||
" 'keepAlive': False,\n", |
||||
" 'maxCPU': 99,\n", |
||||
" 'maxConcurrentSessions': 10,\n", |
||||
" 'maxMemory': 99,\n", |
||||
" 'maxQueueLength': 20,\n", |
||||
" 'metricsJSONPath': None,\n", |
||||
" 'port': 3000,\n", |
||||
" 'prebootChrome': False,\n", |
||||
" 'queuedAlertURL': None,\n", |
||||
" 'rejectAlertURL': None,\n", |
||||
" 'sessionCheckFailURL': None,\n", |
||||
" 'singleRun': False,\n", |
||||
" 'socketBehavior': 'http',\n", |
||||
" 'timeoutAlertURL': None,\n", |
||||
" 'token': None,\n", |
||||
" 'workspaceDir': '/home/browserless'}\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"import requests\n", |
||||
"import pprint\n", |
||||
"response = requests.get('http://192.168.1.101:3148/config')\n", |
||||
"\n", |
||||
"pprint.pprint(response.json())\n", |
||||
"\n", |
||||
"\n" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 16, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"{'error': 0,\n", |
||||
" 'maxConcurrent': 1,\n", |
||||
" 'maxTime': 600000,\n", |
||||
" 'meanTime': 7610.974683544304,\n", |
||||
" 'minTime': 0,\n", |
||||
" 'queued': 0,\n", |
||||
" 'rejected': 0,\n", |
||||
" 'sessionTimes': [590, 600000, 947, 407],\n", |
||||
" 'successful': 3,\n", |
||||
" 'timedout': 1,\n", |
||||
" 'totalTime': 601944,\n", |
||||
" 'unhealthy': 0}\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"import requests\n", |
||||
"import pprint\n", |
||||
"\n", |
||||
"response = requests.get('http://192.168.1.101:3148/metrics/total')\n", |
||||
"\n", |
||||
"pprint.pprint(response.json())" |
||||
] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3.10.4 64-bit", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.10.4" |
||||
}, |
||||
"orig_nbformat": 4, |
||||
"vscode": { |
||||
"interpreter": { |
||||
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" |
||||
} |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 2 |
||||
} |
||||
@ -0,0 +1,153 @@ |
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "d1a0256a-ff3e-4aad-9e6f-f4267db5175b", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"!pip install photon\n" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 22, |
||||
"id": "3efdc58b-bf19-4138-b75c-afa610af01d5", |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stderr", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"Exception in thread Thread-41 (jscanner):\n", |
||||
"Traceback (most recent call last):\n", |
||||
" File \"/opt/conda/lib/python3.10/threading.py\", line 1016, in _bootstrap_inner\n", |
||||
" self.run()\n", |
||||
" File \"/opt/conda/lib/python3.10/threading.py\", line 953, in run\n", |
||||
" self._target(*self._args, **self._kwargs)\n", |
||||
" File \"/home/jovyan/.local/lib/python3.10/site-packages/photon/photon.py\", line 208, in jscanner\n", |
||||
" response = requester(url, delay, domain_name, user_agents, cookie, timeout) # make request to the url\n", |
||||
" File \"/home/jovyan/.local/lib/python3.10/site-packages/photon/photon.py\", line 58, in requester\n", |
||||
" if 'text/html' in response.headers['content-type']:\n", |
||||
" File \"/opt/conda/lib/python3.10/site-packages/requests/structures.py\", line 52, in __getitem__\n", |
||||
" return self._store[key.lower()][1]\n", |
||||
"KeyError: 'content-type'\n" |
||||
] |
||||
}, |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"{'custom': [],\n", |
||||
" 'endpoints': ['https://caddyserver.com',\n", |
||||
" 'https://twitter.com/githubstatus',\n", |
||||
" 'http://www.w3.org/1999/xhtml',\n", |
||||
" 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd',\n", |
||||
" 'https://static.cloudflareinsights.com/beacon.min.js/v652eace1692a40cfa3763df669d7439c1639079717194',\n", |
||||
" 'https://help.github.com/pages/',\n", |
||||
" 'http://www.w3.org/1999/xlink',\n", |
||||
" 'http://www.w3.org/2000/svg',\n", |
||||
" 'https://githubstatus.com',\n", |
||||
" 'https://www.iana.org/domains/example'],\n", |
||||
" 'external': ['https://www.iana.org/domains/example'],\n", |
||||
" 'failed': [],\n", |
||||
" 'files': [],\n", |
||||
" 'fuzzable': [],\n", |
||||
" 'intel': ['select2@4.1.0-rc.0'],\n", |
||||
" 'internal': ['https://homelab.donavanaldrich.com/#/home/links',\n", |
||||
" 'http://example.com',\n", |
||||
" 'https://donavanaldrich.com/api',\n", |
||||
" 'https://raw.githubusercontent.com/awesome-selfhosted/awesome-selfhosted/master/README.md'],\n", |
||||
" 'keys': [],\n", |
||||
" 'robots': [],\n", |
||||
" 'scripts': ['https://raw.githubusercontent.com/awesome-selfhosted/awesome-selfhosted/master/README.md/api-selector.js',\n", |
||||
" 'http://example.com/api-selector.js',\n", |
||||
" 'https://homelab.donavanaldrich.com/#/home/links/api-selector.js',\n", |
||||
" 'https://donavanaldrich.com/api/api-selector.js']}\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"# import photon\n", |
||||
"# result = photon.crawl('https://donavanaldrich.com/api')\n", |
||||
"# print(result.results())\n", |
||||
"\n", |
||||
"import photon\n", |
||||
"import pprint\n", |
||||
"results = photon.crawl('https://homelab.donavanaldrich.com/#/home/links')\n", |
||||
"pprint.pprint(results)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "564f5e9c-dfe8-46a1-a9fc-4c5a5e5781bb", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"import os\n", |
||||
"my_value = os.environ[\"MY_ENVIRONMENT_VARIABLE\"]" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "f0d0b4d4", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "60d3a171", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"%lsmagic" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"id": "009fc04c", |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3 (ipykernel)", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.10.6" |
||||
}, |
||||
"vscode": { |
||||
"interpreter": { |
||||
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" |
||||
} |
||||
}, |
||||
"widgets": { |
||||
"application/vnd.jupyter.widget-state+json": { |
||||
"state": {}, |
||||
"version_major": 2, |
||||
"version_minor": 0 |
||||
} |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 5 |
||||
} |
||||
Loading…
Reference in new issue