Exemplo n.º 1
0
def make_parser():
    """
    Takes ArgParse instance with default arguments and adds

    Positional Arguments:
        * module_name
        * release

    Flags:
        * -u: `untar`
        * -e: `epics_version`

    Returns:
        :class:`argparse.ArgumentParser`: ArgParse instance

    """

    parser = ArgParser(usage)
    parser.add_module_name_arg()
    parser.add_release_arg()
    parser.add_epics_version_flag()

    parser.add_argument(
        "-u", "--untar", action="store_true", dest="untar",
        help="Untar archive created with dls-archive-module.py")

    return parser
Exemplo n.º 2
0
def make_parser():
    """
    Takes ArgParse instance with default arguments and adds

    Positional Arguments:
        * module_name

    Flags:
        * -n (no-import)
        * -f (fullname)

    Returns:
        :class:`argparse.ArgumentParser`:  ArgParse instance
    """
    supported_areas = ["support", "ioc", "python", "tools"]

    parser = ArgParser(usage, supported_areas)
    parser.add_module_name_arg()

    parser.add_argument(
        "-n",
        "--no-import",
        action="store_true",
        dest="no_import",
        help="Creates the module but doesn't store it on the server",
    )
    parser.add_argument(
        "-f",
        "--fullname",
        action="store_true",
        dest="fullname",
        help="create new-style ioc, with full ioc name in path",
    )

    return parser
Exemplo n.º 3
0
def make_parser():
    """
    Takes ArgParse instance with default arguments and adds

    Positional Arguments:
        * module_name

    Flags:
        * -b (branch)
        * -l (latest)
        * -g (git)
        * -e (epics_version)
        * -r (rhel_version)

    Returns:
        :class:`argparse.ArgumentParser`:  ArgParse instance

    """
    parser = ArgParser(usage)
    parser.add_module_name_arg()
    parser.add_epics_version_flag()
    parser.add_git_flag(
        help_msg="Print releases available in git")

    parser.add_argument(
        "-l", "--latest", action="store_true", dest="latest",
        help="Only print the latest release")
    parser.add_argument(
        "-r", "--rhel_version", action="store", type=int, dest="rhel_version",
        default=get_rhel_version(),
        help="Change the rhel version of the environment, default is " +
             get_rhel_version() + " (from your system)")

    return parser
Exemplo n.º 4
0
def make_parser():
    """
    Takes ArgParse instance with default arguments and adds

    Positional Arguments:
        * module_name
        * release

    Flags:
        * -u: `untar`
        * -e: `epics_version`

    Returns:
        :class:`argparse.ArgumentParser`: ArgParse instance

    """

    parser = ArgParser(USAGE, SUPPORTED_AREAS)
    parser.add_module_name_arg()
    parser.add_release_arg()
    parser.add_epics_version_flag()
    parser.add_rhel_version_flag()

    parser.add_argument("-u",
                        "--untar",
                        action="store_true",
                        dest="untar",
                        help="Untar archive created with dls-tar-module.py")

    return parser
Exemplo n.º 5
0
class AddModuleNameTest(unittest.TestCase):

    def setUp(self):
        self.parser = ArgParser("")
        self.parser.add_module_name_arg()

    def test_module_name_has_correct_attributes(self):
        arguments = self.parser._positionals._actions[4]
        self.assertEqual(arguments.type, str)
        self.assertEqual(arguments.dest, 'module_name')
def make_parser():
    """
    Takes default parser arguments and adds module_name

    Returns:
        :class:`argparse.ArgumentParser`:  ArgParse instance
    """
    parser = ArgParser(usage)
    parser.add_module_name_arg()

    return parser
Exemplo n.º 7
0
def make_parser():
    """
    Takes default parser arguments and adds module_name

    Returns:
        :class:`argparse.ArgumentParser`:  ArgParse instance
    """
    parser = ArgParser(usage)
    parser.add_module_name_arg()

    return parser
Exemplo n.º 8
0
def make_parser():
    """
    Takes ArgParse instance with default arguments and adds

    Positional Arguments:
        * module_name
        * releases

    Flags:
        * -e (earlier_release)
        * -l (later_release)
        * -v (verbose)
        * -r (raw)

    Returns:
        :class:`argparse.ArgumentParser`: ArgParse instance
    """

    parser = ArgParser(usage)
    parser.add_module_name_arg()

    parser.add_argument("releases",
                        nargs='*',
                        type=str,
                        default=None,
                        help="Releases range to print logs for")
    parser.add_argument("-e",
                        "--earlier_release",
                        action="store",
                        dest="earlier_release",
                        type=str,
                        help="Start point of log messages")
    parser.add_argument("-l",
                        "--later_release",
                        action="store",
                        dest="later_release",
                        type=str,
                        help="End point of log messages")
    parser.add_argument(
        "-v",
        "--verbose",
        action="store_true",
        dest="verbose",
        help="Adds date, time, message body and file diff information to logs")
    parser.add_argument("-r",
                        "--raw",
                        action="store_true",
                        dest="raw",
                        help="Print raw text (not in colour)")

    return parser
Exemplo n.º 9
0
def make_parser():
    """
    Takes ArgParse instance with default arguments and adds

    Positional Arguments:
        * module_name

    Returns:
        :class:`argparse.ArgumentParser`:  ArgParse instance
    """

    parser = ArgParser(usage)
    parser.add_module_name_arg()
    return parser
Exemplo n.º 10
0
def make_parser():
    """
    Takes ArgParse instance with default arguments and adds

    Positional Arguments:
        * module_name

    Returns:
        :class:`argparse.ArgumentParser`:  ArgParse instance
    """

    parser = ArgParser(usage)
    parser.add_module_name_arg()
    return parser
Exemplo n.º 11
0
class AddModuleNameTest(unittest.TestCase):
    def setUp(self):
        self.parser = ArgParser("")

    def test_arg_parser_quits_if_module_name_not_added_and_module_name_provided(
            self):
        try:
            self.parser.parse_args("-p module1".split())
            self.fail("Parser should have quit.")
        except SystemExit:
            pass

    def test_arg_parser_parses_module_name_correctly(self):
        self.parser.add_module_name_arg()
        args = self.parser.parse_args("-p module1".split())
        self.assertEqual(args.module_name, "module1")
Exemplo n.º 12
0
def make_parser():
    """
    Takes ArgParse instance with default arguments and adds

    Positional Arguments:
        * module_name

    Flags:
        * -n (no-import)
        * -f (fullname)

    Returns:
        :class:`argparse.ArgumentParser`:  ArgParse instance
    """
    supported_areas = ["support", "ioc", "python", "python3", "tools"]

    parser = ArgParser(usage, supported_areas)
    parser.add_module_name_arg()
    parser.formatter_class = argparse.RawDescriptionHelpFormatter

    # The following arguments cannot be used together
    group = parser.add_mutually_exclusive_group()
    group.add_argument(
        "-n",
        "--no-import",
        action="store_true",
        dest="no_import",
        help="Creates the module but doesn't store it on the server")

    group.add_argument(
        "-e",
        "--empty",
        action="store_true",
        dest="empty",
        help="Initialize an empty remote repository on the server. Does not "
        "create a local repo nor commit any files.")

    parser.add_argument(
        "-q",
        "--ignore_existing",
        action="store_true",
        dest="ignore_existing",
        help="When used together with -e/--empty, this script will exit "
        "silently with success if a repository with the given name "
        "already exists on the server.")

    return parser
Exemplo n.º 13
0
def make_parser():
    """
    Takes ArgParse instance with default arguments and adds

    Positional Arguments:
        * module_name

    Flags:
        * -b (branch)
        * -l (latest)
        * -g (git)
        * -e (epics_version)
        * -r (rhel_version)

    Returns:
        :class:`argparse.ArgumentParser`:  ArgParse instance
    """

    parser = ArgParser(usage)
    parser.add_module_name_arg()
    parser.add_epics_version_flag()
    parser.add_git_flag(help_msg="Print releases available in git")

    parser.add_argument("-l",
                        "--latest",
                        action="store_true",
                        dest="latest",
                        help="Only print the latest release")
    parser.add_argument(
        "-r",
        "--rhel_version",
        action="store",
        type=int,
        dest="rhel_version",
        default=get_rhel_version(),
        help="Change the rhel version of the environment, default is " +
        get_rhel_version() + " (from your system)")

    return parser
Exemplo n.º 14
0
def make_parser():
    """
    Takes ArgParse instance with default arguments and adds

    Positional Arguments:
        * module_name
        * releases

    Flags:
        * -e (earlier_release)
        * -l (later_release)
        * -v (verbose)
        * -r (raw)

    Returns:
        :class:`argparse.ArgumentParser`: ArgParse instance

    """
    parser = ArgParser(usage)
    parser.add_module_name_arg()

    parser.add_argument(
        "releases", nargs='*', type=str, default=None,
        help="Releases range to print logs for")
    parser.add_argument(
        "-e", "--earlier_release", action="store", dest="earlier_release", type=str,
        help="Start point of log messages")
    parser.add_argument(
        "-l", "--later_release", action="store", dest="later_release", type=str,
        help="End point of log messages")
    parser.add_argument(
        "-v", "--verbose", action="store_true", dest="verbose",
        help="Adds date, time, message body and file diff information to logs")
    parser.add_argument(
        "-r", "--raw", action="store_true", dest="raw",
        help="Print raw text (not in colour)")

    return parser
Exemplo n.º 15
0
def make_parser():
    """
    Takes ArgParse instance with default arguments and adds

    Positional Arguments:
        * module_name
        * release

    Flags:
        * -b (branch)
        * -f (force)
        * -t (no-test-build)
        * -l (local-build-only)
        * -e (epics_version)
        * -T (test_build_only
        * -m (message)
        * -n (next_version)
        * -r (rhel_version) or --w (windows arguments)

    Returns:
        :class:`argparse.ArgumentParser`: ArgParse instance

    """
    parser = ArgParser(usage)

    parser.add_module_name_arg()
    parser.add_release_arg()
    parser.add_branch_flag(help_msg="Release from a branch")
    parser.add_epics_version_flag(
        help_msg="Change the epics version. This will determine which build "
        "server your job is built on for epics modules. Default is "
        "from your environment"
    )

    parser.add_argument(
        "-f",
        "--force",
        action="store_true",
        dest="force",
        default=None,
        help="force a release. If the release exists in prod it is removed. "
        "If the release exists in git it is exported to prod, otherwise "
        "the release is created in git and exported to prod",
    )
    parser.add_argument(
        "-t",
        "--no-test-build",
        action="store_true",
        dest="skip_test",
        help="If set, this will skip the local test build " "and just do a release",
    )
    parser.add_argument(
        "-l",
        "--local-build-only",
        action="store_true",
        dest="local_build",
        help="If set, this will only do the local test build and no more.",
    )
    parser.add_argument(
        "-T",
        "--test_build-only",
        action="store_true",
        dest="test_only",
        help="If set, this will only do a test build on the build server",
    )
    parser.add_argument(
        "-m",
        "--message",
        action="store",
        type=str,
        dest="message",
        default="",
        help="Add user message to the end of the default commit message. "
        "The message will be <module_name>: Released version <release>. <message>",
    )
    parser.add_argument(
        "-n",
        "--next_version",
        action="store_true",
        dest="next_version",
        help="Use the next version number as the release version",
    )

    title = "Build operating system arguments"
    desc = "Note: The following arguments are mutually exclusive - only use one"

    desc_group = parser.add_argument_group(title=title, description=desc)  # Can only add description to group, so have
    group = desc_group.add_mutually_exclusive_group()  # to nest inside ordinary group

    group.add_argument(
        "-r",
        "--rhel_version",
        action="store",
        type=str,
        dest="rhel_version",
        help="change the rhel version of the build. This will determine which "
        "build server your job is build on for non-epics modules. Default "
        "is from /etc/redhat-release. Can be 6",
    )
    group.add_argument(
        "-w",
        "--windows",
        action="store",
        dest="windows",
        type=str,
        help="Release the module or IOC only for the Windows version. "
        "Note that the windows build server can not create a test build. "
        "A configure/RELEASE.win32-x86 or configure/RELEASE.windows64 file"
        " must exist in the module in order for the build to start. "
        "If the module has already been released with the same version "
        "the build server will rebuild that release for windows. "
        "Existing unix builds of the same module version will not be "
        "affected. Must specify 32 or 64 after the flag to choose 32/64-bit. "
        "Both 32 and 64 bit builds are built on the same 64-bit build server",
    )

    return parser
Exemplo n.º 16
0
def make_parser():
    """
    Takes ArgParse instance with default arguments and adds

    Positional Arguments:
        * module_name
        * release

    Flags:
        * -b (branch)
        * -f (force)
        * -t (no-test-build)
        * -l (local-build-only)
        * -e (epics_version)
        * -T (test_build_only
        * -m (message)
        * -n (next_version)
        * -r (rhel_version) or --w (windows arguments)
        * -g (redundant_argument)
        * -c (commit)

    Returns:
        :class:`argparse.ArgumentParser`: ArgParse instance

    """
    parser = ArgParser(usage)

    parser.add_module_name_arg()
    parser.add_release_arg(optional=True)
    parser.add_branch_flag(help_msg="Release from a branch")
    parser.add_epics_version_flag(
        help_msg="Change the EPICS version. This will determine which build "
        "server your job is built on for EPICS modules. Default is "
        "from your environment")

    parser.add_argument(
        "-f",
        "--force",
        action="store_true",
        dest="force",
        default=None,
        help="Force a release. If the release exists in prod it is removed "
        "(otherwise in this case the default behaviour is to rebuild "
        "the existing release). Overrides some sanity checks and is "
        "therefore to be used with caution.")
    parser.add_argument("-t",
                        "--no-test-build",
                        action="store_true",
                        dest="skip_test",
                        help="If set, this will skip the local test build "
                        "and just do a release")
    parser.add_argument(
        "-l",
        "--local-build-only",
        action="store_true",
        dest="local_build",
        help="If set, this will only do the local test build and no more.")
    parser.add_argument(
        "-T",
        "--test_build-only",
        action="store_true",
        dest="test_only",
        help="If set, this will only do a test build on the build server.")
    parser.add_argument(
        "-m",
        "--message",
        action="store",
        type=str,
        dest="message",
        default="",
        help="Add user message to the end of the default commit message. "
        "The message will be <module_name>: Released version <release>."
        "<message>")
    parser.add_argument(
        "-n",
        "--next_version",
        action="store_true",
        dest="next_version",
        help="Use the next version number as the release version")
    parser.add_argument(
        "-g",
        "--redundant_argument",
        action="store_true",
        dest="redundant_argument",
        help="Redundant argument to preserve backward compatibility")
    parser.add_argument(
        "-c",
        "--commit",
        action="store",
        type=str,
        dest="commit",
        help="If <release> is given, "
        "this option causes the tag to be created "
        "on the server, at the given COMMIT. The <release> is "
        "checked against the DLS naming convention. "
        "This option can also be used to execute only test builds "
        "at the given commit by omitting <release> and using "
        "either -T or -l. This avoids having to tag to do a test build.")

    title = "Build operating system arguments"
    desc = "Note: The following arguments are mutually exclusive - only use " \
           "one"

    # Can only add description to group, so have to nest inside ordinary group
    desc_group = parser.add_argument_group(title=title, description=desc)
    group = desc_group.add_mutually_exclusive_group()

    group.add_argument(
        "-r",
        "--rhel_version",
        action="store",
        type=str,
        dest="rhel_version",
        help="change the rhel version of the build. This will determine which "
        "build server your job is build on for non-epics modules. Default "
        "is from /etc/redhat-release. Can be 6 or 7")
    group.add_argument(
        "-w",
        "--windows",
        action="store",
        dest="windows",
        type=str,
        help="Release the module or IOC only for the Windows version. "
        "If the module has already been released with the same version "
        "the build server will rebuild that release for Windows. "
        "Existing unix builds of the same module version will not be "
        "affected. If the EPICS version is different to the default "
        "it must be specified explicitly. Possible options are: "
        "32 (win32-x86, R3.14.12.3, Server 2008),"
        "64 (windows-x64, R3.14.12.3, Server 2008), "
        "64_2012 (windows-x64, R3.14.12.7, Server 2012)")

    return parser