コード例 #1
0
def create_link(opts, src, dst):
    if not os.path.lexists(dst):
        return _create_link(opts, src, dst)

    if not os.path.islink(dst):
        return "[%s] is not a symbolic link as we expected, please adjust if this is not what you intended." % (
            dst)

    if not os.path.exists(os.readlink(dst)):
        environment.warning(
            'BROKEN LINK: [%s] attempting to delete and fix it to point to %s.'
            % (dst, src))
        try:
            os.unlink(dst)
            return _create_link(opts, src, dst)
        except:
            msg = "[%s] was a broken symlink, failed to delete and relink to [%s], please fix this manually" % (
                dst, src)
            return msg

    environment.debug(opts, 'verifying link: %s points to %s' % (dst, src))
    dst_stat = os.stat(dst)
    src_stat = os.stat(src)
    if dst_stat.st_ino != src_stat.st_ino:
        msg = "[%s] is pointing to [%s] which is different than the intended target [%s]" % (
            dst, os.readlink(dst), src)
        return msg
コード例 #2
0
ファイル: pulp-dev.py プロジェクト: FlorianHeigl/pulp_rpm
def create_link(opts, src, dst):
    if not os.path.lexists(dst):
        return _create_link(opts, src, dst)

    if not os.path.islink(dst):
        return ("[%s] is not a symbolic link as we expected, please adjust if this is not what "
                "you intended." % (dst))

    if not os.path.exists(os.readlink(dst)):
        environment.warning(
            'BROKEN LINK: [%s] attempting to delete and fix it to point to %s.' % (dst, src))
        try:
            os.unlink(dst)
            return _create_link(opts, src, dst)
        except:
            msg = ("[%s] was a broken symlink, failed to delete and relink to [%s], please fix "
                   "this manually" % (dst, src))
            return msg

    environment.debug(opts, 'verifying link: %s points to %s' % (dst, src))
    dst_stat = os.stat(dst)
    src_stat = os.stat(src)
    if dst_stat.st_ino != src_stat.st_ino:
        msg = ("[%s] is pointing to [%s] which is different than the intended target "
               "[%s]" % (dst, os.readlink(dst), src))
        return msg
コード例 #3
0
def install(opts):
    # Install the packages in developer mode
    environment.manage_setup_pys('install', ROOT_DIR)

    warnings = []
    create_dirs(opts)
    currdir = os.path.abspath(os.path.dirname(__file__))
    for src, dst in getlinks():
        warning_msg = create_link(opts, os.path.join(currdir, src), dst)
        if warning_msg:
            warnings.append(warning_msg)

    if warnings:
        print "\n***\nPossible problems:  Please read below\n***"
        for w in warnings:
            environment.warning(w)
    return os.EX_OK
コード例 #4
0
ファイル: pulp-dev.py プロジェクト: FlorianHeigl/pulp_rpm
def install(opts):
    # Install the packages in developer mode
    environment.manage_setup_pys('install', ROOT_DIR)

    warnings = []
    create_dirs(opts)
    currdir = os.path.abspath(os.path.dirname(__file__))
    for src, dst in getlinks():
        warning_msg = create_link(opts, os.path.join(currdir, src), dst)
        if warning_msg:
            warnings.append(warning_msg)

    if warnings:
        print "\n***\nPossible problems:  Please read below\n***"
        for w in warnings:
            environment.warning(w)
    return os.EX_OK