This commit is contained in:
Vladislav 2026-07-27 02:03:52 -04:00
parent 7dd8c520bc
commit d58a92e1e8
2 changed files with 196 additions and 98 deletions

View File

@ -41,6 +41,7 @@
" for cell in nb.get(\"cells\", []):\n", " for cell in nb.get(\"cells\", []):\n",
" if cell.get(\"cell_type\") == \"code\":\n", " if cell.get(\"cell_type\") == \"code\":\n",
" cell[\"outputs\"] = []\n", " cell[\"outputs\"] = []\n",
" cell[\"display_name\"] = \".venv\"\n",
" cell[\"execution_count\"] = None\n", " cell[\"execution_count\"] = None\n",
" p.write_text(json.dumps(nb, ensure_ascii=False, indent=1) + \"\\n\", encoding=\"utf-8\")\n", " p.write_text(json.dumps(nb, ensure_ascii=False, indent=1) + \"\\n\", encoding=\"utf-8\")\n",
"\n", "\n",
@ -49,7 +50,8 @@
"EOF\n", "EOF\n",
"\n", "\n",
"chmod +x .git/hooks/pre-commit\n" "chmod +x .git/hooks/pre-commit\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -97,7 +99,8 @@
" load_env('env')\n", " load_env('env')\n",
"except:\n", "except:\n",
" load_env('env_example')" " load_env('env_example')"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -119,7 +122,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!kubectl create secret docker-registry regcred --docker-server=$REGISTRY_HOST --docker-username='user' --docker-password=$REGISTRY_PASS --docker-email=\"$(git config --global --get user.email)\"" "!kubectl create secret docker-registry regcred --docker-server=$REGISTRY_HOST --docker-username='user' --docker-password=$REGISTRY_PASS --docker-email=\"$(git config --global --get user.email)\""
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -133,7 +137,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!docker login $REGISTRY_HOST -u 'user' -p $REGISTRY_PASS" "!docker login $REGISTRY_HOST -u 'user' -p $REGISTRY_PASS"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -155,7 +160,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!docker pull $REGISTRY_HOST/python:3.13-alpine" "!docker pull $REGISTRY_HOST/python:3.13-alpine"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -169,7 +175,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!docker pull $REGISTRY_HOST/python:3.13-slim" "!docker pull $REGISTRY_HOST/python:3.13-slim"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -209,7 +216,8 @@
" f.write('\\n\\n'.join(app))\n", " f.write('\\n\\n'.join(app))\n",
"\n", "\n",
"build()" "build()"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -231,7 +239,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!docker build -t $REGISTRY_HOST/avtopost-api:latest ." "!docker build -t $REGISTRY_HOST/avtopost-api:latest ."
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -245,7 +254,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!docker image push $REGISTRY_HOST/avtopost-api:latest" "!docker image push $REGISTRY_HOST/avtopost-api:latest"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -259,7 +269,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!kubectl rollout restart deployments/kultmost-api -n kultmost" "!kubectl rollout restart deployments/kultmost-api -n kultmost"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -281,7 +292,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!kubectl rollout restart deployments/vk-celery -n kultmost" "!kubectl rollout restart deployments/vk-celery -n kultmost"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -295,7 +307,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!kubectl rollout restart deployments/email-celery -n kultmost" "!kubectl rollout restart deployments/email-celery -n kultmost"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -318,7 +331,8 @@
"source": [ "source": [
"!docker build -t $REGISTRY_HOST/ssh-tunnel:2 tunnel/\n", "!docker build -t $REGISTRY_HOST/ssh-tunnel:2 tunnel/\n",
"!docker push $REGISTRY_HOST/ssh-tunnel:2" "!docker push $REGISTRY_HOST/ssh-tunnel:2"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -332,7 +346,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!kubectl create secret generic ssh-id-rsa --from-file=id_rsa=/home/user/.ssh/id_rsa -n kultmost" "!kubectl create secret generic ssh-id-rsa --from-file=id_rsa=/home/user/.ssh/id_rsa -n kultmost"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -346,7 +361,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!kubectl apply -n kultmost -f k8s/stunnel.yaml" "!kubectl apply -n kultmost -f k8s/stunnel.yaml"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -360,7 +376,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!envsubst < k8s/prod.yaml | kubectl apply -n kultmost -f -" "!envsubst < k8s/prod.yaml | kubectl apply -n kultmost -f -"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -374,7 +391,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!envsubst < k8s/kultmost.yaml | kubectl apply -n kultmost -f -" "!envsubst < k8s/kultmost.yaml | kubectl apply -n kultmost -f -"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -388,7 +406,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!envsubst < k8s/mq.yaml | kubectl apply -n kultmost -f -" "!envsubst < k8s/mq.yaml | kubectl apply -n kultmost -f -"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -402,7 +421,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!envsubst < k8s/gitea.yaml | kubectl apply -n gitea -f -" "!envsubst < k8s/gitea.yaml | kubectl apply -n gitea -f -"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -416,7 +436,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!echo " "!echo "
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -441,7 +462,8 @@
"echo \"$INIT_SSH'bash -s' <<'SCRIPT'\"\n", "echo \"$INIT_SSH'bash -s' <<'SCRIPT'\"\n",
"echo \"kubectl create secret docker-registry regcred --docker-server=$REGISTRY_HOST --docker-username='user' --docker-password=$REGISTRY_PASS --docker-email=\\\"$(git config --global --get user.email)\\\" && clear && history -c && history -w\"\n", "echo \"kubectl create secret docker-registry regcred --docker-server=$REGISTRY_HOST --docker-username='user' --docker-password=$REGISTRY_PASS --docker-email=\\\"$(git config --global --get user.email)\\\" && clear && history -c && history -w\"\n",
"echo \"SCRIPT\"" "echo \"SCRIPT\""
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -464,7 +486,8 @@
"echo \"clear\"\n", "echo \"clear\"\n",
"echo \"history -c\"\n", "echo \"history -c\"\n",
"echo \"history -w\"" "echo \"history -w\""
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -486,7 +509,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"#!rsync -avz ./static kultmost:/var/www/static/" "#!rsync -avz ./static kultmost:/var/www/static/"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -500,7 +524,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!echo $(git branch --show-current)" "!echo $(git branch --show-current)"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -514,7 +539,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!rsync -avh --exclude-from=.rsyncignore --exclude=.venv/ . kultmost:/app/$(git branch --show-current)/" "!rsync -avh --exclude-from=.rsyncignore --exclude=.venv/ . kultmost:/app/$(git branch --show-current)/"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -552,7 +578,8 @@
"EOF\n", "EOF\n",
"\n", "\n",
"ssh kultmost 'systemctl daemon-reload && systemctl enable --now production.service && systemctl status --no-pager -l production.service'\n" "ssh kultmost 'systemctl daemon-reload && systemctl enable --now production.service && systemctl status --no-pager -l production.service'\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -582,7 +609,8 @@
"EOF\n", "EOF\n",
"\n", "\n",
"ssh kultmost 'systemctl daemon-reload && systemctl enable --now fastapi.service && systemctl status --no-pager -l fastapi.service'\n" "ssh kultmost 'systemctl daemon-reload && systemctl enable --now fastapi.service && systemctl status --no-pager -l fastapi.service'\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -620,7 +648,8 @@
"EOF\n", "EOF\n",
"\n", "\n",
"ssh kultmost 'systemctl daemon-reload && systemctl enable --now staging.service && systemctl status --no-pager -l staging.service'\n" "ssh kultmost 'systemctl daemon-reload && systemctl enable --now staging.service && systemctl status --no-pager -l staging.service'\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -642,7 +671,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!ssh kultmost 'systemctl restart production.service'" "!ssh kultmost 'systemctl restart production.service'"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -656,7 +686,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!ssh kultmost 'systemctl status production.service'" "!ssh kultmost 'systemctl status production.service'"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -670,7 +701,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!ssh kultmost 'systemctl restart fastapi.service'" "!ssh kultmost 'systemctl restart fastapi.service'"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -684,7 +716,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!ssh kultmost 'systemctl status fastapi.service'" "!ssh kultmost 'systemctl status fastapi.service'"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -722,7 +755,8 @@
"EOF\n", "EOF\n",
"\n", "\n",
"ssh kultmost 'systemctl daemon-reload && systemctl enable --now vk-celery.service && systemctl status --no-pager -l vk-celery.service'\n" "ssh kultmost 'systemctl daemon-reload && systemctl enable --now vk-celery.service && systemctl status --no-pager -l vk-celery.service'\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -736,7 +770,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!ssh kultmost 'systemctl restart vk-celery.service'" "!ssh kultmost 'systemctl restart vk-celery.service'"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -750,7 +785,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!ssh kultmost 'systemctl status vk-celery.service'" "!ssh kultmost 'systemctl status vk-celery.service'"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -780,7 +816,8 @@
"EOF\n", "EOF\n",
"\n", "\n",
"ssh kultmost 'systemctl daemon-reload && systemctl enable --now email-celery.service && systemctl status --no-pager -l email-celery.service'\n" "ssh kultmost 'systemctl daemon-reload && systemctl enable --now email-celery.service && systemctl status --no-pager -l email-celery.service'\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -794,7 +831,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!ssh kultmost 'systemctl restart email-celery.service'" "!ssh kultmost 'systemctl restart email-celery.service'"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -808,7 +846,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!ssh kultmost 'systemctl status email-celery.service'" "!ssh kultmost 'systemctl status email-celery.service'"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -830,7 +869,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# !scp kultmost:/etc/nginx/sites-enabled/default nginx_conf " "# !scp kultmost:/etc/nginx/sites-enabled/default nginx_conf "
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -846,7 +886,8 @@
"!scp nginx_conf kultmost:/tmp/default\n", "!scp nginx_conf kultmost:/tmp/default\n",
"!ssh kultmost 'sudo mv /tmp/default /etc/nginx/sites-enabled/default'\n", "!ssh kultmost 'sudo mv /tmp/default /etc/nginx/sites-enabled/default'\n",
"!ssh kultmost 'nginx -t'" "!ssh kultmost 'nginx -t'"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -860,7 +901,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!ssh kultmost 'nginx -s reload'" "!ssh kultmost 'nginx -s reload'"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -885,7 +927,8 @@
"sudo usermod -a -G microk8s $USER\n", "sudo usermod -a -G microk8s $USER\n",
"newgrp microk8s\n", "newgrp microk8s\n",
"microk8s status" "microk8s status"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -901,7 +944,8 @@
"curl -LO https://cert-manager.io/public-keys/cert-manager-keyring-2021-09-20-1020CF3C033D4F35BAE1C19E1226061C665DF13E.gpg\n", "curl -LO https://cert-manager.io/public-keys/cert-manager-keyring-2021-09-20-1020CF3C033D4F35BAE1C19E1226061C665DF13E.gpg\n",
"helm install cert-manager oci://quay.io/jetstack/charts/cert-manager --version v1.20.2 --namespace cert-manager --create-namespace --verify --keyring ./cert-manager-keyring-2021-09-20-1020CF3C033D4F35BAE1C19E1226061C665DF13E.gpg --set crds.enabled=true\n", "helm install cert-manager oci://quay.io/jetstack/charts/cert-manager --version v1.20.2 --namespace cert-manager --create-namespace --verify --keyring ./cert-manager-keyring-2021-09-20-1020CF3C033D4F35BAE1C19E1226061C665DF13E.gpg --set crds.enabled=true\n",
"microk8s helm install cert-manager oci://quay.io/jetstack/charts/cert-manager --version v1.20.2 --namespace cert-manager --create-namespace --verify --keyring ./cert-manager-keyring-2021-09-20-1020CF3C033D4F35BAE1C19E1226061C665DF13E.gpg --set crds.enabled=true" "microk8s helm install cert-manager oci://quay.io/jetstack/charts/cert-manager --version v1.20.2 --namespace cert-manager --create-namespace --verify --keyring ./cert-manager-keyring-2021-09-20-1020CF3C033D4F35BAE1C19E1226061C665DF13E.gpg --set crds.enabled=true"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -1122,7 +1166,8 @@
"\n", "\n",
"sss = await element_create(pc, tablet, mob)\n", "sss = await element_create(pc, tablet, mob)\n",
"sss.innerHTML" "sss.innerHTML"
] ],
"display_name": ".venv"
} }
], ],
"metadata": { "metadata": {

161
vk.ipynb
View File

@ -48,7 +48,8 @@
" load_env('env')\n", " load_env('env')\n",
"except:\n", "except:\n",
" load_env('env_example')" " load_env('env_example')"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -80,7 +81,8 @@
"from fastapi import APIRouter,Depends\n", "from fastapi import APIRouter,Depends\n",
"from fastapi.responses import RedirectResponse\n", "from fastapi.responses import RedirectResponse\n",
"from images import insert_logo\n" "from images import insert_logo\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -98,7 +100,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"celery_app_vk = Celery('vk', broker=f'{redis_uri}1', backend=f'{redis_uri}1', task_track_started=True )\n" "celery_app_vk = Celery('vk', broker=f'{redis_uri}1', backend=f'{redis_uri}1', task_track_started=True )\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -108,7 +111,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"token_manager = TokenManager()\n" "token_manager = TokenManager()\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -130,7 +134,8 @@
"async def oauth_callback(code: str, state: str, device_id: str = None):\n", "async def oauth_callback(code: str, state: str, device_id: str = None):\n",
" token_data = await token_manager.get_token(code=code, state=state, device_id=device_id)\n", " token_data = await token_manager.get_token(code=code, state=state, device_id=device_id)\n",
" return RedirectResponse(url='/profile/social', status_code=status.HTTP_303_SEE_OTHER)\n" " return RedirectResponse(url='/profile/social', status_code=status.HTTP_303_SEE_OTHER)\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -160,7 +165,8 @@
" images[_id] = (\"photo\", (name, background, \"image/jpeg\"))\n", " images[_id] = (\"photo\", (name, background, \"image/jpeg\"))\n",
" \n", " \n",
" return images\n" " return images\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -234,7 +240,8 @@
" await mongo_client[db_name][item.get('col')].update_one({'_id': ObjectId(item.get('_id'))}, update_spec)\n", " await mongo_client[db_name][item.get('col')].update_one({'_id': ObjectId(item.get('_id'))}, update_spec)\n",
" return {\"ok\": True}\n", " return {\"ok\": True}\n",
"\n" "\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -310,7 +317,8 @@
" await mongo_client[db_name][item.get('col')].update_one({'_id': ObjectId(item.get('_id'))}, update_spec)\n", " await mongo_client[db_name][item.get('col')].update_one({'_id': ObjectId(item.get('_id'))}, update_spec)\n",
" return {\"ok\": True}\n", " return {\"ok\": True}\n",
"\n" "\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -364,7 +372,8 @@
" )\n", " )\n",
"\n", "\n",
" return {\"ok\": True}\n" " return {\"ok\": True}\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -399,7 +408,8 @@
" \n", " \n",
" except Exception as exc:\n", " except Exception as exc:\n",
" raise self.retry(exc=exc)\n" " raise self.retry(exc=exc)\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -434,7 +444,8 @@
" \n", " \n",
" except Exception as exc:\n", " except Exception as exc:\n",
" raise self.retry(exc=exc)\n" " raise self.retry(exc=exc)\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -469,7 +480,8 @@
" \n", " \n",
" except Exception as exc:\n", " except Exception as exc:\n",
" raise self.retry(exc=exc)\n" " raise self.retry(exc=exc)\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -500,7 +512,8 @@
"# timeout=100\n", "# timeout=100\n",
"# ).json()\n", "# ).json()\n",
"# await asyncio.sleep(1)\n" "# await asyncio.sleep(1)\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -531,7 +544,8 @@
"\n", "\n",
" with open(f'{filename_without_extension}.py', 'w') as f:\n", " with open(f'{filename_without_extension}.py', 'w') as f:\n",
" f.write('\\n\\n'.join(app))\n" " f.write('\\n\\n'.join(app))\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -545,7 +559,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!celery -A vk.celery_app_vk worker --loglevel=info" "!celery -A vk.celery_app_vk worker --loglevel=info"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -559,7 +574,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!docker build -t registry.spiritofweb.ru/avtopost-api:latest ." "!docker build -t registry.spiritofweb.ru/avtopost-api:latest ."
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -573,7 +589,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!sudo docker image push registry.spiritofweb.ru/avtopost-api:latest" "!sudo docker image push registry.spiritofweb.ru/avtopost-api:latest"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -587,7 +604,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!kubectl rollout restart deployments/vk-celery -n kultmost" "!kubectl rollout restart deployments/vk-celery -n kultmost"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -601,7 +619,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!echo $REGISTRY_HOST" "!echo $REGISTRY_HOST"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -619,7 +638,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"stop" "stop"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -629,7 +649,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"user_id = '681684390000000000000000'" "user_id = '681684390000000000000000'"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -640,7 +661,8 @@
"source": [ "source": [
"await redis_client.delete(f\"access_token:{user_id}\")\n", "await redis_client.delete(f\"access_token:{user_id}\")\n",
"await redis_client.delete(f\"tokens:{user_id}\")" "await redis_client.delete(f\"tokens:{user_id}\")"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -664,7 +686,8 @@
" },\n", " },\n",
" upsert=True,\n", " upsert=True,\n",
")\n" ")\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -674,7 +697,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"import token_manager as tm" "import token_manager as tm"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -685,7 +709,8 @@
"source": [ "source": [
"from token_manager import TokenManager\n", "from token_manager import TokenManager\n",
"token_manager = TokenManager()" "token_manager = TokenManager()"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -697,7 +722,8 @@
"token_manager = TokenManager()\n", "token_manager = TokenManager()\n",
"access_token = await token_manager.get_access_token('644fa8bb0000000000000000')\n", "access_token = await token_manager.get_access_token('644fa8bb0000000000000000')\n",
"access_token" "access_token"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -708,7 +734,8 @@
"source": [ "source": [
"item ={'_id': '6a21559cca3ad8a73b652bcb', 'db': 'competitions', 'col': 'competitions'} \n", "item ={'_id': '6a21559cca3ad8a73b652bcb', 'db': 'competitions', 'col': 'competitions'} \n",
"file_ids = ['681684390000000000000000', '6a21559cca3ad8a73b652bc6']" "file_ids = ['681684390000000000000000', '6a21559cca3ad8a73b652bc6']"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -719,7 +746,8 @@
"source": [ "source": [
"docs =[ doc async for doc in mongo_client['social']['social'].find({'user_id':'681684390000000000000000'})]\n", "docs =[ doc async for doc in mongo_client['social']['social'].find({'user_id':'681684390000000000000000'})]\n",
"doc = docs[1]" "doc = docs[1]"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -729,7 +757,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"competition = await competitions_col.find_one({'_id':ObjectId('6a21559cca3ad8a73b652bcb')})" "competition = await competitions_col.find_one({'_id':ObjectId('6a21559cca3ad8a73b652bcb')})"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -739,7 +768,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"images = await get_images(db_name, file_ids, sign_avatar)" "images = await get_images(db_name, file_ids, sign_avatar)"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -781,7 +811,8 @@
" })\n", " })\n",
" res = resp.json()\n", " res = resp.json()\n",
" res.update({'doc': doc})" " res.update({'doc': doc})"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -791,7 +822,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"res" "res"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -858,7 +890,8 @@
" update_spec = {\"$push\": {\"vk\": res}}\n", " update_spec = {\"$push\": {\"vk\": res}}\n",
" await mongo_client[db_name][item.get('col')].update_one({'_id': ObjectId(item.get('_id'))}, update_spec)\n", " await mongo_client[db_name][item.get('col')].update_one({'_id': ObjectId(item.get('_id'))}, update_spec)\n",
" return {\"ok\": True}\n" " return {\"ok\": True}\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -897,7 +930,8 @@
" })\n", " })\n",
" print(resp_wall.json())\n", " print(resp_wall.json())\n",
" \n" " \n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -907,7 +941,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"await competitions_col.find_one({'_id': competition['_id']})" "await competitions_col.find_one({'_id': competition['_id']})"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -922,7 +957,8 @@
" \"$push\": {\"vk\": resp_wall.json()}\n", " \"$push\": {\"vk\": resp_wall.json()}\n",
" },\n", " },\n",
" )" " )"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -937,7 +973,8 @@
" \"v\": \"5.199\",\n", " \"v\": \"5.199\",\n",
" })\n", " })\n",
"resp.json()['response'][0]" "resp.json()['response'][0]"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -947,7 +984,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"[doc async for doc in mongo_client['social']['social'].find({'user_id':competition['user']['id']})]" "[doc async for doc in mongo_client['social']['social'].find({'user_id':competition['user']['id']})]"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -965,7 +1003,8 @@
"})\n", "})\n",
"\n", "\n",
"z.json()['response']" "z.json()['response']"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -975,7 +1014,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"#!pip freeze > requirements.txt" "#!pip freeze > requirements.txt"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -995,7 +1035,8 @@
" \"body\": \"group_id=191599084&user_id=392892935&role=moderator&is_contact=0&contact_position=&contact_phone=&contact_email=&permissions=&access_token=vk1.a.-kG07OUZgX5FrxtsQrU5QJh8HaP_suYXkqcg\",\n", " \"body\": \"group_id=191599084&user_id=392892935&role=moderator&is_contact=0&contact_position=&contact_phone=&contact_email=&permissions=&access_token=vk1.a.-kG07OUZgX5FrxtsQrU5QJh8HaP_suYXkqcg\",\n",
" \"method\": \"POST\",\n", " \"method\": \"POST\",\n",
"});" "});"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -1013,7 +1054,8 @@
"VK_CLIENT_ID = 51852444\n", "VK_CLIENT_ID = 51852444\n",
"SCOPES = 'offline,wall,photos,groups'\n", "SCOPES = 'offline,wall,photos,groups'\n",
"redirect_uri = 'https://oauth.vk.ru/blank.html'" "redirect_uri = 'https://oauth.vk.ru/blank.html'"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -1044,7 +1086,8 @@
"url = f'{AUTHORIZE_URL}?responsetype_item=code&client_id={VK_CLIENT_ID}&scope={SCOPES}&redirect_uri={redirect_uri}&state={state}&code_challenge={code_challenge}&code_challenge_method=S256'\n", "url = f'{AUTHORIZE_URL}?responsetype_item=code&client_id={VK_CLIENT_ID}&scope={SCOPES}&redirect_uri={redirect_uri}&state={state}&code_challenge={code_challenge}&code_challenge_method=S256'\n",
"\n", "\n",
"print(f\"\\n\\n{url}\\n\\n\")" "print(f\"\\n\\n{url}\\n\\n\")"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -1056,7 +1099,8 @@
"\n", "\n",
"code='vk2.a.---'\n", "code='vk2.a.---'\n",
"device_id=''" "device_id=''"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -1067,7 +1111,8 @@
"source": [ "source": [
"refresh_token = \"vk2.a.-----\"\n", "refresh_token = \"vk2.a.-----\"\n",
"device_id = \"-\"\n" "device_id = \"-\"\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -1086,7 +1131,8 @@
" 'state': os.urandom(32).hex(),\n", " 'state': os.urandom(32).hex(),\n",
"})\n", "})\n",
"z.json()" "z.json()"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -1097,7 +1143,8 @@
"source": [ "source": [
"CLIENT_ID = 51852444\n", "CLIENT_ID = 51852444\n",
"OAUTH_URL = 'https://id.vk.com/oauth2/auth'" "OAUTH_URL = 'https://id.vk.com/oauth2/auth'"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -1118,7 +1165,8 @@
" 'redirect_uri': 'https://oauth.vk.com/blank.html'\n", " 'redirect_uri': 'https://oauth.vk.com/blank.html'\n",
"})\n", "})\n",
"r.json()\n" "r.json()\n"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -1139,7 +1187,8 @@
"\n", "\n",
"z=T()\n", "z=T()\n",
"z.json()" "z.json()"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -1150,7 +1199,8 @@
"source": [ "source": [
"refresh_token=r.json()['refresh_token']\n", "refresh_token=r.json()['refresh_token']\n",
"refresh_token" "refresh_token"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -1169,7 +1219,8 @@
" 'state': os.urandom(32).hex(),\n", " 'state': os.urandom(32).hex(),\n",
"})\n", "})\n",
"z.json()" "z.json()"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -1179,7 +1230,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"print(f'\\n\\n{z.json()['refresh_token']}\\n\\n')" "print(f'\\n\\n{z.json()['refresh_token']}\\n\\n')"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -1189,7 +1241,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"users.search" "users.search"
] ],
"display_name": ".venv"
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -1561,7 +1614,7 @@
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": ".venv", "display_name": ".venv (3.14.6.final.0)",
"language": "python", "language": "python",
"name": "python3" "name": "python3"
}, },