1
0
mirror of https://github.com/MarkParker5/STARK.git synced 2025-02-17 11:55:35 +02:00
STARK/Raspi/gitpull.py

28 lines
1.2 KiB
Python

from .Raspi import *
import os
from Command import Callback, Response
import config
################################################################################
def reboot(params):
if params['bool']:
os.system('sudo reboot')
return Response(text = '', voice = '')
reboot_cb = Callback(['$bool',])
reboot_cb.setStart(reboot)
@Raspi.background(answer = 'Проверяю обновления...', voice = 'Проверяю обновления')
def method(params, finish_event):
os.system('git -C '+config.path+' remote update')
if not 'git pull' in os.popen('git -C '+config.path+' status -uno').read():
finish_event.set()
return Response(text = text, voice = voice)
os.system('git -C '+config.path+' pull')
finish_event.set()
voice = text = 'Обновления скачаны. Перезагрузиться?'
return Response(text = text, voice = voice, callback = reboot_cb)
patterns = ['* обновись *', '* можешь обновиться *', '* обнови себя *', '* скачай обновлени* *', '* провер* обновлени* *']
gitpull = Raspi('git pull archie.git', [], patterns)
gitpull.setStart(method)