mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-14 11:00:10 +01:00
set_command_in_config() for finding CLI tools to run
This commit is contained in:
parent
70915a7445
commit
ffd490d8da
@ -2076,12 +2076,7 @@ def compare_apks(apk1, apk2, tmp_dir):
|
|||||||
absapk1 = os.path.abspath(apk1)
|
absapk1 = os.path.abspath(apk1)
|
||||||
absapk2 = os.path.abspath(apk2)
|
absapk2 = os.path.abspath(apk2)
|
||||||
|
|
||||||
# try to find diffoscope in the path, if it hasn't been manually configed
|
if set_command_in_config('diffoscope'):
|
||||||
if 'diffoscope' not in config:
|
|
||||||
tmp = find_command('diffoscope')
|
|
||||||
if tmp is not None:
|
|
||||||
config['diffoscope'] = tmp
|
|
||||||
if 'diffoscope' in config:
|
|
||||||
htmlfile = absapk1 + '.diffoscope.html'
|
htmlfile = absapk1 + '.diffoscope.html'
|
||||||
textfile = absapk1 + '.diffoscope.txt'
|
textfile = absapk1 + '.diffoscope.txt'
|
||||||
if subprocess.call([config['diffoscope'],
|
if subprocess.call([config['diffoscope'],
|
||||||
@ -2107,12 +2102,7 @@ def compare_apks(apk1, apk2, tmp_dir):
|
|||||||
cwd=os.path.join(apk2dir, 'jar-xf')) != 0:
|
cwd=os.path.join(apk2dir, 'jar-xf')) != 0:
|
||||||
return("Failed to unpack " + apk2)
|
return("Failed to unpack " + apk2)
|
||||||
|
|
||||||
# try to find apktool in the path, if it hasn't been manually configed
|
if set_command_in_config('apktool'):
|
||||||
if 'apktool' not in config:
|
|
||||||
tmp = find_command('apktool')
|
|
||||||
if tmp is not None:
|
|
||||||
config['apktool'] = tmp
|
|
||||||
if 'apktool' in config:
|
|
||||||
if subprocess.call([config['apktool'], 'd', os.path.abspath(apk1), '--output', 'apktool'],
|
if subprocess.call([config['apktool'], 'd', os.path.abspath(apk1), '--output', 'apktool'],
|
||||||
cwd=apk1dir) != 0:
|
cwd=apk1dir) != 0:
|
||||||
return("Failed to unpack " + apk1)
|
return("Failed to unpack " + apk1)
|
||||||
@ -2136,6 +2126,22 @@ def compare_apks(apk1, apk2, tmp_dir):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def set_command_in_config(command):
|
||||||
|
'''Try to find specified command in the path, if it hasn't been
|
||||||
|
manually set in config.py. If found, it is added to the config
|
||||||
|
dict. The return value says whether the command is available.
|
||||||
|
|
||||||
|
'''
|
||||||
|
if command in config:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
tmp = find_command(command)
|
||||||
|
if tmp is not None:
|
||||||
|
config[command] = tmp
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def find_command(command):
|
def find_command(command):
|
||||||
'''find the full path of a command, or None if it can't be found in the PATH'''
|
'''find the full path of a command, or None if it can't be found in the PATH'''
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user