Exemple #1
0
def get_tabsint_plugin_docs(name, src, version=None):
    """ include tabsint plugin documentation """

    def copy_userguide(path, ext="rst"):
        installPath = "../docs/userguide/src/docs/plugins"
        try:
            os.mkdir(installPath)
        except:
            pass

        try:
            shutil.copy("{0}/index.{1}".format(path, ext), "{0}/plugin-{1}.{2}".format(installPath, name, ext))

            # copy any other ancillary files - must be named the same as the plugin!
            if name in os.listdir(path):
                shutil.copytree("{0}/{1}".format(path, name), "{0}/{1}/".format(installPath, name))
        except Exception as e:
            sys.exit('[ERROR]: Failed to copy docs for plugin "{0}" to userguide. Error: {1} '.format(name, str(e)))

    # git files
    if any(s in src for s in ["https://", ".git"]):
        [repo, subdir] = ut.checkout(src, tag=version)
        docPath = ".tmp/{0}/{1}".format(repo, subdir)

    # local files
    else:
        src = "../" + src
        ut.check_tag(src, version)

        if src.endswith("/"):
            docPath = src[:-1]
        else:
            docPath = src

    # user guide
    if "index.rst" in os.listdir(docPath):
        copy_userguide(docPath)
    elif "index.md" in os.listdir(docPath):
        copy_userguide(docPath, ext="md")

    ut.cmd("rm -rf .tmp", force=True)  # remove temp git directory, if its there

    ut.log.info('[BUILD]: Successfully retrieved docs for tabsint plugin "{0}"'.format(name))
Exemple #2
0
def get_tabsint_plugin(name, src, version=None):
    """ get tabsint plugin from git repository or local folder"""

    def copy_to_plugins(path):
        shutil.rmtree("../www/tabsint_plugins/{0}".format(name), True)
        shutil.copytree(path, "../www/tabsint_plugins/{0}".format(name))

    # git repos
    if any(s in src for s in ["https://", ".git"]):
        [repo, subdir] = ut.checkout(src, tag=version)
        copy_to_plugins(".tmp/{0}/{1}".format(repo, subdir))
        ut.cmd("rm -rf .tmp")  # remove temp git directory

    # local files
    else:
        src = "../" + src  # make path relative to top level directory
        ut.check_tag(src, version)
        copy_to_plugins(src)

    ut.log.info('[BUILD]: Successfully retrieved the source for tabsint plugin "{0}"'.format(name))