fix updater
This commit is contained in:
parent
1e25e4f9c5
commit
871a3ddf64
1 changed files with 7 additions and 2 deletions
|
@ -5,6 +5,8 @@ import asyncio
|
||||||
|
|
||||||
async def git_notifications_update():
|
async def git_notifications_update():
|
||||||
logger.info('module for checking updates started')
|
logger.info('module for checking updates started')
|
||||||
|
cwd = os.getcwd()
|
||||||
|
os.chdir(cwd)
|
||||||
while True:
|
while True:
|
||||||
termux_api = os.system('termux-api-start')
|
termux_api = os.system('termux-api-start')
|
||||||
if termux_api == 0:
|
if termux_api == 0:
|
||||||
|
@ -12,7 +14,9 @@ async def git_notifications_update():
|
||||||
fetching_git = os.system('git fetch')
|
fetching_git = os.system('git fetch')
|
||||||
if fetching_git == 0:
|
if fetching_git == 0:
|
||||||
commits = os.popen('git log --oneline HEAD..origin/$(git rev-parse --abbrev-ref HEAD)').read()
|
commits = os.popen('git log --oneline HEAD..origin/$(git rev-parse --abbrev-ref HEAD)').read()
|
||||||
cwd = os.getcwd()
|
if len(commits) <= 5:
|
||||||
|
logger.info('updates not found, nothing to do')
|
||||||
|
else:
|
||||||
os.system(f"termux-notification --title 'ub4tg: update avalaible!' --content 'For apply tap button Get update and restart bot\nChanges:\n{commits}' --button1 'Get update' --button1-action 'cd {cwd}; git pull'")
|
os.system(f"termux-notification --title 'ub4tg: update avalaible!' --content 'For apply tap button Get update and restart bot\nChanges:\n{commits}' --button1 'Get update' --button1-action 'cd {cwd}; git pull'")
|
||||||
else:
|
else:
|
||||||
os.system("termux-toast '[ub4tg]: failed fetching update, maybe connection error'")
|
os.system("termux-toast '[ub4tg]: failed fetching update, maybe connection error'")
|
||||||
|
@ -20,4 +24,5 @@ async def git_notifications_update():
|
||||||
logger.warning('For getting updates via notifications, you should:')
|
logger.warning('For getting updates via notifications, you should:')
|
||||||
logger.warning('pkg install termux-api')
|
logger.warning('pkg install termux-api')
|
||||||
logger.warning('download the apk: https://f-droid.org/repo/com.termux.api_51.apk')
|
logger.warning('download the apk: https://f-droid.org/repo/com.termux.api_51.apk')
|
||||||
|
logger.debug('next update will be check after 6 hours')
|
||||||
await asyncio.sleep(6 * 60 * 60)
|
await asyncio.sleep(6 * 60 * 60)
|
||||||
|
|
Loading…
Reference in a new issue