mirror of
https://github.com/SinTan1729/random.git
synced 2025-04-19 09:10:00 -05:00
fix: A syntax error
This commit is contained in:
parent
c0cce90f40
commit
9a0f38c994
1 changed files with 23 additions and 24 deletions
|
@ -10,51 +10,50 @@ import subprocess
|
||||||
import time
|
import time
|
||||||
|
|
||||||
# Check if the build script exists
|
# Check if the build script exists
|
||||||
if not os.path.isfile('lure.sh'):
|
if not os.path.isfile("lure.sh"):
|
||||||
print("Couldn't find a lure.sh file in the current directory.")
|
print("Couldn't find a lure.sh file in the current directory.")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
with open('lure.sh', 'r') as script_file:
|
with open("lure.sh", "r") as script_file:
|
||||||
script = script_file.readlines()
|
script = script_file.readlines()
|
||||||
|
|
||||||
vars = {}
|
vars = {}
|
||||||
for line in script:
|
for line in script:
|
||||||
if '=' not in line or '\t' in line:
|
if "=" not in line or "\t" in line:
|
||||||
continue
|
continue
|
||||||
var, val = line.strip('\n').split('=')
|
var, val = line.strip("\n").split("=")
|
||||||
vars[var] = val.strip('""').strip("''")
|
vars[var] = val.strip('""').strip("''")
|
||||||
|
|
||||||
for src_type in [k for k in vars.keys() if "sources" in k]:
|
for src_type in [k for k in vars.keys() if "sources" in k]:
|
||||||
suffix = src_type.split('_')[1]
|
suffix = src_type.split("_")[1]
|
||||||
if suffix != "":
|
if suffix != "":
|
||||||
suffix = "_" + suffix
|
suffix = "_" + suffix
|
||||||
|
|
||||||
# Read all the links
|
# Read all the links
|
||||||
links = [link.strip('""').strip("''")
|
links = [link.strip('""').strip("''") for link in vars[src_type].strip("()").split()]
|
||||||
for link in vars[src_type].strip('()').split()]
|
|
||||||
|
|
||||||
# Get the old sums
|
# Get the old sums
|
||||||
old_sums = vars["checksums"+suffix].strip('()').split()
|
old_sums = vars["checksums" + suffix].strip("()").split()
|
||||||
old_sums = [sum.strip('""').strip("''") for sum in old_sums]
|
old_sums = [sum.strip('""').strip("''") for sum in old_sums]
|
||||||
|
|
||||||
checksums = []
|
checksums = []
|
||||||
for i, link in enumerate(links):
|
for i, link in enumerate(links):
|
||||||
if old_sums[i] == 'SKIP':
|
if old_sums[i] == "SKIP":
|
||||||
checksums.append('SKIP')
|
checksums.append("SKIP")
|
||||||
continue
|
continue
|
||||||
# Try to do variable expansions (works up to one level, should be enough)
|
# Try to do variable expansions (works up to one level, should be enough)
|
||||||
to_replace = list(set(re.findall('(\${.+?})', link)))
|
to_replace = list(set(re.findall("(${.+?})", link)))
|
||||||
for str in to_replace:
|
for str in to_replace:
|
||||||
str_clean = str.strip('${}')
|
str_clean = str.strip("${}")
|
||||||
link = link.replace(str, vars[str_clean])
|
link = link.replace(str, vars[str_clean])
|
||||||
|
|
||||||
filename = subprocess.run(
|
filename = subprocess.run(
|
||||||
['curl', '-sLO', '-w', '%{filename_effective}', link], stdout=subprocess.PIPE)
|
["curl", "-sLO", "-w", "%{filename_effective}", link], stdout=subprocess.PIPE
|
||||||
filename = filename.stdout.decode('utf-8')
|
)
|
||||||
|
filename = filename.stdout.decode("utf-8")
|
||||||
|
|
||||||
checksum = subprocess.run(
|
checksum = subprocess.run(["sha256sum", filename], stdout=subprocess.PIPE)
|
||||||
['sha256sum', filename], stdout=subprocess.PIPE)
|
checksum = checksum.stdout.decode("utf-8").split()[0]
|
||||||
checksum = checksum.stdout.decode('utf-8').split()[0]
|
|
||||||
checksums.append(checksum)
|
checksums.append(checksum)
|
||||||
|
|
||||||
# Build the output line
|
# Build the output line
|
||||||
|
@ -66,10 +65,10 @@ for src_type in [k for k in vars.keys() if "sources" in k]:
|
||||||
|
|
||||||
timestamp = "{}".format(int(time.time()))
|
timestamp = "{}".format(int(time.time()))
|
||||||
|
|
||||||
with open(timestamp, 'w') as tempfile:
|
with open(timestamp, "w") as tempfile:
|
||||||
tempfile.writelines(script)
|
tempfile.writelines(script)
|
||||||
|
|
||||||
os.rename('lure.sh', "lure-"+timestamp+".sh")
|
os.rename("lure.sh", "lure-" + timestamp + ".sh")
|
||||||
os.rename(timestamp, 'lure.sh')
|
os.rename(timestamp, "lure.sh")
|
||||||
|
|
||||||
print("Done!")
|
print("Done!")
|
||||||
|
|
Loading…
Reference in a new issue