implement digiham version check
This commit is contained in:
parent
adf62bc2ca
commit
efa0c060fe
@ -2,6 +2,8 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
from operator import and_
|
from operator import and_
|
||||||
|
import re
|
||||||
|
from distutils.version import LooseVersion
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -18,7 +20,7 @@ class FeatureDetector(object):
|
|||||||
"hackrf": [ "hackrf_transfer" ],
|
"hackrf": [ "hackrf_transfer" ],
|
||||||
"airspy": [ "airspy_rx" ],
|
"airspy": [ "airspy_rx" ],
|
||||||
"digital_voice_digiham": [ "digiham", "sox" ],
|
"digital_voice_digiham": [ "digiham", "sox" ],
|
||||||
"digital_voice_dsd": [ "dsd", "sox" ]
|
"digital_voice_dsd": [ "dsd", "sox", "digiham" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
def feature_availability(self):
|
def feature_availability(self):
|
||||||
@ -82,19 +84,31 @@ class FeatureDetector(object):
|
|||||||
def command_exists(self, command):
|
def command_exists(self, command):
|
||||||
return os.system("which {0}".format(command)) == 0
|
return os.system("which {0}".format(command)) == 0
|
||||||
|
|
||||||
|
"""
|
||||||
|
To use DMR and YSF, the digiham package is required. You can find the package and installation instructions here:
|
||||||
|
https://github.com/jketterl/digiham
|
||||||
|
|
||||||
|
Please note: there is close interaction between digiham and openwebrx, so older versions will probably not work.
|
||||||
|
If you have an older verison of digiham installed, please update it along with openwebrx.
|
||||||
|
As of now, we require version 0.2 of digiham.
|
||||||
|
"""
|
||||||
def has_digiham(self):
|
def has_digiham(self):
|
||||||
# the digiham tools expect to be fed via stdin, they will block until their stdin is closed.
|
required_version = LooseVersion("0.2")
|
||||||
def check_with_stdin(command):
|
|
||||||
|
digiham_version_regex = re.compile('^digiham version (.*)$')
|
||||||
|
def check_digiham_version(command):
|
||||||
try:
|
try:
|
||||||
process = subprocess.Popen(command, stdin=subprocess.PIPE)
|
process = subprocess.Popen([command, "--version"], stdout=subprocess.PIPE)
|
||||||
process.communicate("")
|
version = LooseVersion(digiham_version_regex.match(process.stdout.readline().decode())[1])
|
||||||
return process.wait() == 0
|
process.wait(1)
|
||||||
|
return version >= required_version
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
return False
|
return False
|
||||||
return reduce(and_,
|
return reduce(and_,
|
||||||
map(
|
map(
|
||||||
check_with_stdin,
|
check_digiham_version,
|
||||||
["rrc_filter", "ysf_decoder", "dmr_decoder", "mbe_synthesizer", "gfsk_demodulator"]
|
["rrc_filter", "ysf_decoder", "dmr_decoder", "mbe_synthesizer", "gfsk_demodulator",
|
||||||
|
"digitalvoice_filter"]
|
||||||
),
|
),
|
||||||
True)
|
True)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user