def install_hwpack(url, replace_existing=False): """install hwpackrary from web or local files system. :param url: web address or file path :param replace_existing: bool :rtype: None """ d = tmpdir(tmpdir()) f = download(url) Archive(f).extractall(d) clean_dir(d) src_dhwpack = find_hwpack_dir(d) targ_dhwpack = hwpack_dir() / src_dhwpack.name doaction = 0 if targ_dhwpack.exists(): log.debug('hwpack already exists: %s', targ_dhwpack) if replace_existing: log.debug('remove %s', targ_dhwpack) targ_dhwpack.rmtree() doaction = 1 else: doaction = 1 if doaction: log.debug('move %s -> %s', src_dhwpack, targ_dhwpack) src_dhwpack.move(targ_dhwpack) hwpack_dir().copymode(targ_dhwpack) for x in targ_dhwpack.walk(): hwpack_dir().copymode(x)
def remove_hwpack(name): """remove hardware package. :param name: hardware package name (e.g. 'Sanguino') :rtype: None """ targ_dlib = hwpack_dir() / name log.debug('remove %s', targ_dlib) targ_dlib.rmtree()