1
0
Fork 0
forked from bioeb_org/ub4tg

shlex totally fucked up updater, trying use file as input via pipe

This commit is contained in:
Your Name 2024-12-19 01:55:50 +03:00
parent c4633d4e02
commit 46add00fbf

View file

@ -1,7 +1,6 @@
from loguru import logger
import os
import asyncio
import shlex
async def git_notifications_update():
@ -14,14 +13,16 @@ async def git_notifications_update():
logger.info('Checking for updates...')
fetching_git = os.system('git fetch')
if fetching_git == 0:
os.system("printf 'For apply tap button Get update and restart bot\nChanges:\n' > upd_info")
commits = os.popen(
"git log --pretty=format:'%h %s%n%b' HEAD..origin/$(git rev-parse --abbrev-ref HEAD)").read()
os.popen(
"git log --pretty=format:'%h %s%n%b' HEAD..origin/$(git rev-parse --abbrev-ref HEAD) >> upd_info")
if len(commits) <= 5:
logger.info('updates not found, nothing to do')
else:
commits = shlex.quote(commits)
os.system(
f"termux-notification -i ub4tgupd --title 'ub4tg: update avalaible!' --content 'For apply tap button Get update and restart bot\nChanges:\n{commits}' --button1 'Get update' --button1-action 'termux-notification-remove ub4tgupd; cd {cwd}; git pull; termux-toast 'ub4tg updated, now restart it for apply update'")
f"cat upd_info | termux-notification -i ub4tgupd --title 'ub4tg: update avalaible!' --button1 'Get update' --button1-action 'termux-notification-remove ub4tgupd; cd {cwd}; git pull; termux-toast 'ub4tg updated, now restart it for apply update'")
else:
os.system(
"termux-toast '[ub4tg]: failed fetching update, maybe connection error, check console log for more info'")