replace-bot/utils/misc.py

24 lines
521 B
Python
Raw Permalink Normal View History

2022-10-07 17:50:42 +03:00
import os
import sys
from typing import Union
import git
class Update:
def __init__(self, name: Union[str, None] = None) -> None:
self.name = name or 'origin'
print(f"Name: {self.name}")
def git_update(self):
repo = git.Repo('.')
r = git.Remote(repo, self.name)
r.pull()
@staticmethod
def restart_bot():
2022-10-09 15:59:54 +03:00
if len(sys.argv) >= 2 and sys.argv[1] == 'restart':
2022-10-09 15:24:23 +03:00
return
os.execvp(sys.executable, [sys.executable, sys.argv[0], 'restart'])