|
from os import path as opath, getenv |
|
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(), |
|
], |
|
) |
|
load_dotenv('config.env', override=True) |
|
|
|
UPSTREAM_REPO = getenv('UPSTREAM_REPO', "https://JackFrost003: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@github.com/JackFrost003/Bypass_bot") |
|
UPSTREAM_BRANCH = getenv('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 jackfro03@gmail.com \ |
|
&& git config --global user.name JackFrost003 \ |
|
&& 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('Successfully updated with latest commit from UPSTREAM_REPO') |
|
else: |
|
log_error('Something went wrong while updating, check UPSTREAM_REPO if valid or not!') |
|
|