-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.py
53 lines (44 loc) · 1.58 KB
/
update.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os
import subprocess
import requests
import logging
from dotenv import load_dotenv
if os.path.exists('log.txt'):
with open('log.txt', 'r+') as f:
f.truncate(0)
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[logging.FileHandler('log.txt'), logging.StreamHandler()],
level=logging.INFO)
CONFIG_FILE_URL = os.environ.get('CONFIG_FILE_URL', None)
try:
if len(CONFIG_FILE_URL) == 0:
raise TypeError
try:
res = requests.get(CONFIG_FILE_URL)
if res.status_code == 200:
with open('config.env', 'wb+') as f:
f.write(res.content)
f.close()
else:
logging.error(f"Failed to download config.env {res.status_code}")
except Exception as e:
logging.error(str(e))
except TypeError:
pass
load_dotenv('config.env', override=True)
UPSTREAM_REPO = os.environ.get('UPSTREAM_REPO', None)
try:
if len(UPSTREAM_REPO) == 0:
raise TypeError
except TypeError:
UPSTREAM_REPO = "https://github.com/badboy7310/MirLeech"
if os.path.exists('.git'):
subprocess.run(["rm", "-rf", ".git"])
subprocess.run([f"git init -q \
&& git config --global user.email e.anastayyar@gmail.com \
&& git config --global user.name mltb \
&& git add . \
&& git commit -sm update -q \
&& git remote add origin {UPSTREAM_REPO} \
&& git fetch origin -q \
&& git reset --hard origin/master -q"], shell=True)