示例#1
0
def install_lib(url, replace_existing=False, fix_wprogram=True):
    """install library 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)
    d, src_dlib = find_lib_dir(d)
    move_examples(d, src_dlib)
    fix_examples_dir(src_dlib)
    if fix_wprogram:
        fix_wprogram_in_files(src_dlib)

    targ_dlib = libraries_dir() / src_dlib.name
    if targ_dlib.exists():
        log.debug('library already exists: %s', targ_dlib)
        if replace_existing:
            log.debug('remove %s', targ_dlib)
            targ_dlib.rmtree()
        else:
            raise ConfduinoError('library already exists:' + targ_dlib)

    log.debug('move %s -> %s', src_dlib, targ_dlib)
    src_dlib.move(targ_dlib)

    libraries_dir().copymode(targ_dlib)
    for x in targ_dlib.walk():
        libraries_dir().copymode(x)
    return targ_dlib.name
示例#2
0
def install_lib(url, replace_existing=False, fix_wprogram=True):
    """install library 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)
    d, src_dlib = find_lib_dir(d)
    move_examples(d, src_dlib)
    fix_examples_dir(src_dlib)
    if fix_wprogram:
        fix_wprogram_in_files(src_dlib)

    targ_dlib = libraries_dir() / src_dlib.name
    if targ_dlib.exists():
        log.debug('library already exists: %s', targ_dlib)
        if replace_existing:
            log.debug('remove %s', targ_dlib)
            targ_dlib.rmtree()
        else:
            raise ConfduinoError('library already exists:' + targ_dlib)

    log.debug('move %s -> %s', src_dlib, targ_dlib)
    src_dlib.move(targ_dlib)

    libraries_dir().copymode(targ_dlib)
    for x in targ_dlib.walk():
        libraries_dir().copymode(x)
    return targ_dlib.name
示例#3
0
def remove_lib(lib_name):
    """remove library.

    :param lib_name: library name (e.g. 'PS2Keyboard')
    :rtype: None

    """
    targ_dlib = libraries_dir() / lib_name
    log.debug('remove %s', targ_dlib)
    targ_dlib.rmtree()
示例#4
0
def gui():
    """remove libraries by GUI."""

    sel = psidialogs.multi_choice(libraries(),
                                  'select libraries to remove from %s!' % libraries_dir(),
                                  title='remove boards')
    print('%s selected' % sel)

    if sel:
        if psidialogs.ask_yes_no('Do you really want to remove selected libraries?\n' + '\n'.join(sel)):
            for x in sel:
                remove_lib(x)
                print('%s was removed' % x)
示例#5
0
def gui():
    """remove libraries by GUI."""

    sel = psidialogs.multi_choice(libraries(),
                                  'select libraries to remove from %s!' %
                                  libraries_dir(),
                                  title='remove boards')
    print('%s selected' % sel)

    if sel:
        if psidialogs.ask_yes_no(
                'Do you really want to remove selected libraries?\n' +
                '\n'.join(sel)):
            for x in sel:
                remove_lib(x)
                print('%s was removed' % x)