Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_package_version(self, name, release_name=''):
version = '0.0.0'
if name in self.packages:
version = self.packages.get(name).get('version')
elif release_name:
dir_name = util.get_package_dir(release_name)
if isdir(dir_name):
filepath = util.safe_join(dir_name, 'package.json')
try:
with open(filepath, 'r') as json_file:
tmp_data = json.load(json_file)
if 'version' in tmp_data.keys():
version = tmp_data.get('version')
except Exception:
pass
return version
def _ftdi_enable_windows(self):
drivers_base_dir = util.get_package_dir('tools-drivers')
drivers_bin_dir = util.safe_join(drivers_base_dir, 'bin')
drivers_share_dir = util.safe_join(drivers_base_dir, 'share')
zadig_ini_path = util.safe_join(drivers_share_dir, 'zadig.ini')
zadig_ini = 'zadig.ini'
try:
if util.check_package(
self.name,
self.version,
self.spec_version,
drivers_bin_dir
):
click.secho('Launch drivers configuration tool')
click.secho(FTDI_INSTALL_DRIVER_INSTRUCTIONS, fg='yellow')
# Copy zadig.ini
with open(zadig_ini, 'w') as ini_file:
def _run_command(self, command, silent=False):
result = {}
system_base_dir = util.get_package_dir('tools-system')
system_bin_dir = util.safe_join(system_base_dir, 'bin')
on_stdout = None if silent else self._on_stdout
on_stderr = self._on_stderr
if util.check_package(
self.name,
self.version,
self.spec_version,
system_bin_dir
):
result = util.exec_command(
util.safe_join(system_bin_dir, command + self.ext),
stdout=util.AsyncPipe(on_stdout),
stderr=util.AsyncPipe(on_stderr))
def __init__(self):
profile = Profile()
resources = Resources()
self.name = 'examples'
self.examples_dir = util.get_package_dir(self.name)
self.version = util.get_package_version(self.name, profile)
self.spec_version = util.get_package_spec_version(self.name, resources)