Example #1
0
def _main():
    log = logging.getLogger(name="dls_ade")

    parser = make_parser()
    args = parser.parse_args()

    log.info(json.dumps({'CLI': sys.argv, 'options_args': vars(args)}))

    check_area_archivable(args.area)
    env.check_epics_version(args.epics_version)
    env.check_rhel_version(args.rhel_version)
    check_technical_area(args.area, args.module_name)

    # Check for the existence of release of this module/IOC
    w_dir = os.path.join(env.prodArea(args.area), args.module_name)
    release_dir = os.path.join(w_dir, args.release)
    archive = release_dir + ".tar.gz"

    check_file_paths(release_dir, archive, args.untar)

    # Create build object for release
    build = dlsbuild.ArchiveBuild(args.rhel_version, args.epics_version,
                                  args.untar)

    if args.epics_version:
        build.set_epics(args.epics_version)

    build.set_area(args.area)

    git = vcs_git.Git(args.module_name, args.area)
    git.set_version(args.release)

    build.submit(args.module_name, args.release, git)
Example #2
0
    def test_given_area_ioc_module_split_less_than_two_then_no_error_raised(
            self):
        area = "ioc"
        module = "test_module"
        expected_error_msg = "Missing technical area under beamline"

        try:
            dls_utilities.check_technical_area(area, module)
        except ParsingError as error:
            self.assertEqual(str(error), expected_error_msg)
def _main():
    log = logging.getLogger(name="dls_ade")
    usermsg = logging.getLogger(name="usermessages")
    output = logging.getLogger(name="output")

    parser = make_parser()
    args = parser.parse_args()

    log.info(json.dumps({'CLI': sys.argv, 'options_args': vars(args)}))

    check_technical_area(args.area, args.module_name)

    server = Server()

    module = args.module_name
    source = server.dev_module_path(module, args.area)
    log.debug(source)

    if server.is_server_repo(source):
        vcs = server.temp_clone(source)
        releases = vcs_git.list_module_releases(vcs.repo)

        if releases:
            last_release_num = releases[-1]
        else:
            usermsg.info("No release has been done for {}".format(module))
            # return so last_release_num can't be referenced before assignment
            return 1
    else:
        raise IOError("{} does not exist on the repository.".format(source))

    # Get a single log between last release and HEAD
    # If there is one, then changes have been made
    logs = list(vcs.repo.iter_commits(last_release_num + "..HEAD",
                                      max_count=1))
    if logs:
        output.info("Changes have been made to {module}"
                    " since release {release}".format(
                        module=module, release=last_release_num))
    else:
        output.info("No changes have been made to {module}"
                    " since most recent release {release}".format(
                        module=module, release=last_release_num))

    shutil.rmtree(vcs.repo.working_tree_dir)
Example #4
0
def _main():
    log = logging.getLogger(name="dls_ade")
    usermsg = logging.getLogger(name="usermessages")
    output = logging.getLogger(name="output")

    parser = make_parser()
    args = parser.parse_args()

    log.info(json.dumps({'CLI': sys.argv, 'options_args': vars(args)}))

    check_technical_area(args.area, args.module_name)

    server = Server()

    source = server.dev_module_path(args.module_name, args.area)

    vcs = server.temp_clone(source)

    branches = vcs_git.list_remote_branches(vcs.repo)
    usermsg.info("Branches of {module}:".format(module=source))
    output.info("{branches}".format(branches=", ".join(branches)))

    shutil.rmtree(vcs.repo.working_tree_dir)
Example #5
0
    def test_given_area_ioc_module_split_two_then_no_error_raised(self):
        area = "ioc"
        module = "modules/test_module"

        dls_utilities.check_technical_area(area, module)
Example #6
0
    def test_given_area_not_ioc_then_no_error_raised(self):
        area = "support"
        module = "test_module"

        dls_utilities.check_technical_area(area, module)
def _main():
    log = logging.getLogger(name="dls_ade")
    usermsg = logging.getLogger(name="usermessages")
    output = logging.getLogger(name="output")

    parser = make_parser()
    args = parser.parse_args()

    log.info(json.dumps({'CLI': sys.argv, 'options_args': vars(args)}))

    raw = set_raw_argument(args.raw)
    check_technical_area(args.area, args.module_name)
    check_parsed_args_compatible(args.releases, args.earlier_release,
                                 args.later_release, parser)
    check_releases_valid(args.releases, parser)

    server = Server()

    source = server.dev_module_path(args.module_name, args.area)

    if server.is_server_repo(source):
        vcs = server.temp_clone(source)
        releases = vcs_git.list_module_releases(vcs.repo)
        log.debug(releases)
    else:
        raise Exception("Module " + args.module_name + " doesn't exist in " +
                        source)

    # Set start and end releases and check they exist, set to defaults
    # if not given
    start, end = set_log_range(args.module_name, args.releases,
                               args.earlier_release, args.later_release,
                               releases)

    # Create log info from log messages
    # log_info is a dictionary in the form {logs(list), commit_objects(dict),
    # max_author_length(int)}
    log_info = get_log_messages(vcs.repo)

    if len(releases) > 0:

        if start == "":
            tag_start = releases[0]
        else:
            tag_start = start

        # Append tag info to log info from tag messages
        tags = get_tags_list(vcs.repo, tag_start, end, releases[-1])
        log_info = get_tag_messages(tags, log_info)

    # Check if there are any logs, exit if not
    if not log_info['logs']:
        usermsg.info("No logs for " + args.module_name + " between releases " +
                     args.earlier_release + " and " + args.later_release)
        return 0

    # Sort tags and commits chronologically by the UNIX time stamp in index 0
    log_info['logs'] = sorted(log_info['logs'], key=itemgetter(0))

    # Make list of printable log entries
    formatted_logs = format_log_messages(log_info, raw, args.verbose)

    if end == 'HEAD':
        print_bool = True
    else:
        print_bool = False

    release_marker = "(RELEASE: {})"
    messages = []
    for log in formatted_logs:
        if log.endswith(release_marker.format(end)):
            print_bool = True
        if print_bool:
            messages.append(log)
        if log.endswith(release_marker.format(start)):
            break
    output.info("\n".join(messages))

    shutil.rmtree(vcs.repo.working_tree_dir)
Example #8
0
def _main():
    log = logging.getLogger(name="dls_ade")
    usermsg = logging.getLogger(name="usermessages")
    output = logging.getLogger(name="output")

    parser = make_parser()
    args = parser.parse_args()

    env = environment()

    log.info(json.dumps({'CLI': sys.argv, 'options_args': vars(args)}))

    env.check_epics_version(args.epics_version)
    env.check_rhel_version(str(args.rhel_version))
    check_technical_area(args.area, args.module_name)

    # Force check of repo, not file system, for etc and epics
    # (previous releases are only stored on repo)
    if args.area in ["etc", "epics"]:
        args.git = True

    # Check for the existence of releases of this module/IOC
    releases = []
    if args.git:

        server = Server()

        # List branches of repository
        target = "the repository"
        source = server.dev_module_path(args.module_name, args.area)
        log.debug(source)

        vcs = server.temp_clone(source)
        releases = vcs_git.list_module_releases(vcs.repo)
        shutil.rmtree(vcs.repo.working_tree_dir)

    else:
        # List branches from prod
        target = "prod for {os}".format(os=env.rhelVerDir())
        source = env.prodArea(args.area)
        release_dir = os.path.join(source, args.module_name)

        if os.path.isdir(release_dir):
            for p in os.listdir(release_dir):
                if os.path.isdir(os.path.join(release_dir, p)):
                    releases.append(p)

    # Check some releases have been made
    if len(releases) == 0:
        if args.git:
            usermsg.info("{}: No releases made in git".format(
                args.module_name))
        else:
            usermsg.info("{module}: No releases made for {version}".format(
                module=args.module_name, version=args.epics_version))
        return 1

    releases = env.sortReleases(releases)

    if args.latest:
        usermsg.info("The latest release for {module} in {target} is: ".format(
            module=args.module_name, target=target))
        output.info("{release}".format(release=releases[-1]))
    else:
        usermsg.info("Previous releases for {module} in {target}:".format(
            module=args.module_name, target=target))
        output.info("{releases}".format(releases=str(releases)))