def _get_co_assets(): from kano_content.api import ContentManager cm = ContentManager.from_local() co_index = {} for co in cm.list_local_objects(spec='make-art-assets'): co_files = co.get_data('').get_content() if len(co_files) != 2: logger.warning( 'Count of files other than 2 in co[{}], skipping'.format( co.get_data('').get_dir() ) ) continue # Check whether the first file is the index index_no = _get_co_index_apply_order(co_files[0]) if index_no is not None: co_index[index_no] = co_files[1] else: # It wasn't the first one, go for the second one index_no = _get_co_index_apply_order(co_files[1]) if index_no is not None: co_index[index_no] = co_files[0] else: err_msg = 'None of the files contained in co have apply index' logger.error(err_msg) continue return co_index
def merge_conf_files(conf_base, conf_added): """ """ if not is_valid_configuration(conf_base) or \ not is_valid_configuration(conf_added): return None else: for cat in conf_added.iterkeys(): if cat in conf_base: if type(conf_base[cat]) != type(conf_added[cat]): logger.error( "base and auxiliary configuration types mismatch") return None else: if type(conf_base[cat]) == list: conf_base[cat] += conf_added[cat] elif type(conf_base[cat]) == dict: conf_base[cat].update(conf_added[cat]) else: logger.warning( "Can't handle type {}".format(conf_base[cat])) return None else: conf_base[cat] = conf_added[cat] return True
def get_partition_info(): device = '/dev/mmcblk0' try: cmd = 'lsblk -n -b {} -o SIZE'.format(device) stdout, dummy_stderr, returncode = run_cmd(cmd) if returncode != 0: from kano.logging import logger logger.warning("error running lsblk") return [] lines = stdout.strip().split('\n') sizes = map(int, lines) return sizes except Exception: return []