adding a playground notebook to mockup the backend workers
parent
dbf7c39400
commit
a9670d1145
|
@ -0,0 +1,200 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "b276f988-0f92-4ac0-b440-523252f841e9",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Playing around with Machine to Machine API access"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "5efb08d1-b0f6-4f64-b87a-f2f5afd4c050",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Let's do some EagleEye setup"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d8ced614-480a-4341-bc40-6c66e16b54cd",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from EagleEyev3 import *\n",
|
||||
"from settings import config"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "091f1c2f-6bff-40e2-a0e8-d22d5f0ccd31",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"een = EagleEyev3(config)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "2aaf14a9-f206-4909-a85f-fc736e964592",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Let's do some DB setup"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "12364fa5-fa06-419a-9d1c-b44f02c9ac63",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import sqlite3"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d8ca6f35-ee80-4463-aab1-3c83e72068f0",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"con = sqlite3.connect('instance/project.db')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "a8c9679c-37e1-4091-998d-08fc83f9c53b",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"cur = con.cursor()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "80f58426-168f-47e1-b4f6-164cd5c6840a",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Login as a user with their refresh_token and query their cameras"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "954c5d7b-db09-483e-a5f0-a59fb5733c34",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"refresh_token = ''"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "a3cd64b9-3e3c-4f02-971c-1b4436a776ea",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"een.login_tokens(code=None, cascade=True, refresh_token=refresh_token)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "bdfde2f6-28b1-4623-8528-1492de00b83d",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"een.get_list_of_cameras()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "10fbd562-919c-4946-bb63-a1531a919920",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "6adf2661-8d10-477e-9f76-d0f67b4857ac",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Poke around in the DB"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d5faf8e2-bfa9-4e85-8713-355973daf3aa",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for row in cur.execute('SELECT * FROM download WHERE camera_id = 53 limit 10'):\n",
|
||||
" print( row[0] )"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "77a703da-8e9e-4e6e-90e7-1113d537362d",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"\"\"\"\n",
|
||||
"SELECT\n",
|
||||
"\tuser.email,\n",
|
||||
"\tcamera.name,\n",
|
||||
"\tdownload.url,\n",
|
||||
"\tcount(download.url)\n",
|
||||
"FROM\n",
|
||||
"\tcamera\n",
|
||||
"\tJOIN download ON download.camera_id = camera.id\n",
|
||||
"\tJOIN USER ON camera.user_id = user.id\n",
|
||||
"WHERE\n",
|
||||
"\tdownload.status = 'new'\n",
|
||||
"GROUP BY\n",
|
||||
"\tcamera.name\n",
|
||||
"ORDER BY\n",
|
||||
"\tcount(download.url)\n",
|
||||
"\tDESC;\n",
|
||||
"\"\"\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "4ae3e95f-845a-4e3e-b0f8-24a4edf56b95",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "flask2",
|
||||
"language": "python",
|
||||
"name": "flask2"
|
||||
},
|
||||
"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.11.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
Loading…
Reference in New Issue