Skip to content

Commit

Permalink
Revert renaming 7z path var
Browse files Browse the repository at this point in the history
Variables can not start with a number
  • Loading branch information
theChaosCoder committed May 6, 2020
1 parent 8d77ca3 commit 3dced1c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions avsupdaterepo.py
Expand Up @@ -56,10 +56,10 @@

args = parser.parse_args()

7z_path = '7z'
cmd7zip_path = '7z.exe'
try:
with winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\7-Zip', reserved=0, access=winreg.KEY_READ) as regkey:
7z_path = winreg.QueryValueEx(regkey, 'Path')[0] + '7z.exe'
cmd7zip_path = winreg.QueryValueEx(regkey, 'Path')[0] + '7z.exe'
except:
pass

Expand Down Expand Up @@ -124,7 +124,7 @@ def fetch_url_to_cache(url, name, tag_name, desc = None, use_basename = False):
return cache_path

def list_archive_files(fn):
result = subprocess.run([7z_path, "l", "-ba", fn], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
result = subprocess.run([cmd7zip_path, "l", "-ba", fn], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
result.check_returncode()
l = {}
lines = result.stdout.decode('utf-8').splitlines()
Expand Down Expand Up @@ -152,7 +152,7 @@ def decompress_and_hash(archivefn, fn, insttype):
existing_files = list_archive_files(archivefn)
for fn_guess in generate_fn_candidates(fn, insttype):
if fn_guess in existing_files:
result = subprocess.run([7z_path, "e", "-so", archivefn, fn_guess], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
result = subprocess.run([cmd7zip_path, "e", "-so", archivefn, fn_guess], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
result.check_returncode()
return (existing_files[fn_guess], hashlib.sha256(result.stdout).hexdigest())
base_dirs = []
Expand All @@ -167,7 +167,7 @@ def decompress_and_hash(archivefn, fn, insttype):
mfn = '/'.join(sfn)
for fn_guess in generate_fn_candidates(mfn, insttype):
if fn_guess in existing_files:
result = subprocess.run([7z_path, "e", "-so", archivefn, fn_guess], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
result = subprocess.run([cmd7zip_path, "e", "-so", archivefn, fn_guess], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
result.check_returncode()
return (existing_files[fn_guess], hashlib.sha256(result.stdout).hexdigest())
raise Exception('No file match found')
Expand Down Expand Up @@ -380,7 +380,7 @@ def compile_packages():
os.remove('avspackages.zip')
except:
pass
result = subprocess.run([7z_path, 'a', '-tzip', 'avspackages.zip', 'avspackages.json'])
result = subprocess.run([cmd7zip_path, 'a', '-tzip', 'avspackages.zip', 'avspackages.json'])
result.check_returncode()

if args.operation == 'compile':
Expand Down

0 comments on commit 3dced1c

Please sign in to comment.