-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.py
More file actions
36 lines (31 loc) · 1.45 KB
/
update.py
File metadata and controls
36 lines (31 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from os import path as opath, environ as env
from logging import FileHandler, StreamHandler, INFO, basicConfig, error as log_error, info as log_info
from logging.handlers import RotatingFileHandler
from subprocess import run as srun
from dotenv import load_dotenv
basicConfig(
level=INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s [%(filename)s:%(lineno)d]",
datefmt="%d-%b-%y %I:%M:%S %p",
handlers=[
RotatingFileHandler("log.txt", maxBytes=50000000, backupCount=10),
StreamHandler(),
],
)
UPSTREAM_REPO = env.get('UPSTREAM_REPO', "https://github.com/5MysterySD/UploadEver-TBot")
UPSTREAM_BRANCH = env.get('UPSTREAM_BRANCH', "main")
if UPSTREAM_REPO is not None:
if opath.exists('.git'):
srun(["rm", "-rf", ".git"])
update = srun([f"git init -q \
&& git config --global user.email mysterysd.sd@gmail.com \
&& git config --global user.name tele-leechx \
&& git add . \
&& git commit -sm update -q \
&& git remote add origin {UPSTREAM_REPO} \
&& git fetch origin -q \
&& git reset --hard origin/{UPSTREAM_BRANCH} -q"], shell=True)
if update.returncode == 0:
log_info(f'Successfully updated with latest commit from {UPSTREAM_REPO}')
else:
log_error(f'Something went wrong while updating, check {UPSTREAM_REPO} if valid or not!')