Пример #1
0
def main(args):
    ''' This main is for running tests and debugging only. Normally
    this module is imported.
    '''
    handle_arguments(args)
    set_up_logging(OPTIONS)

    if OPTIONS.branch:
        if OPTIONS.component:
            return branch_component(vcs.get_working_repository(),
                                    OPTIONS.component, OPTIONS.b, OPTIONS.to)
        else:
            branch, component = OPTIONS.to.split('/')
            return branch_sandbox(vcs.get_working_repository(), component,
                                  OPTIONS.b, branch)

    sb = sandbox.Sandbox(OPTIONS.sandbox_root)
    if OPTIONS.revno:
        if OPTIONS.component:
            show_component_revno(OPTIONS.component, sb, OPTIONS.tree)
        else:
            show_sandbox_revno(sb, OPTIONS.tree)
    if OPTIONS.tags:
        if OPTIONS.component:
            show_component_tags(OPTIONS.component, sb)
        else:
            show_sandbox_tags(sb)
    if OPTIONS.info:
        if OPTIONS.component:
            show_component_info(OPTIONS.component, sb)
        else:
            show_sandbox_info(sb)
    if OPTIONS.status:
        if OPTIONS.component:
            show_component_status(OPTIONS.component, sb)
        else:
            show_sandbox_status(sb)
    if OPTIONS.tag_info:
        show_sandbox_tag_info(OPTIONS.t, sb)
    if OPTIONS.update:
        if OPTIONS.component:
            update_component(OPTIONS.component, sb)
        else:
            update_sandbox(sb)
    if OPTIONS.tag:
        if OPTIONS.component:
            tag_component(OPTIONS.component, sb)
        else:
            tag_sandbox(sb)
    if OPTIONS.pull:
        if OPTIONS.component:
            pull_component(OPTIONS.component, sb)
        else:
            pull_sandbox(sb, OPTIONS.source)
    if OPTIONS.push:
        if OPTIONS.component:
            push_component(OPTIONS.component, sb)
        else:
            push_sandbox(sb, OPTIONS.source)
Пример #2
0
def main(args):
    ''' This main is for running tests and debugging only. Normally
    this module is imported.
    '''
    handle_arguments(args)
    set_up_logging(OPTIONS)

    if OPTIONS.branch:
        if OPTIONS.component:
            return branch_component(vcs.get_working_repository(), OPTIONS.component, OPTIONS.b, OPTIONS.to)
        else:
            branch, component = OPTIONS.to.split('/')
            return branch_sandbox(vcs.get_working_repository(), component, OPTIONS.b, branch)

    sb = sandbox.Sandbox(OPTIONS.sandbox_root)
    if OPTIONS.revno:
        if OPTIONS.component:
            show_component_revno(OPTIONS.component, sb, OPTIONS.tree)
        else:
            show_sandbox_revno(sb, OPTIONS.tree)
    if OPTIONS.tags:
        if OPTIONS.component:
            show_component_tags(OPTIONS.component, sb)
        else:
            show_sandbox_tags(sb)
    if OPTIONS.info:
        if OPTIONS.component:
            show_component_info(OPTIONS.component, sb)
        else:
            show_sandbox_info(sb)
    if OPTIONS.status:
        if OPTIONS.component:
            show_component_status(OPTIONS.component, sb)
        else:
            show_sandbox_status(sb)
    if OPTIONS.tag_info:
        show_sandbox_tag_info(OPTIONS.t, sb)
    if OPTIONS.update:
        if OPTIONS.component:
            update_component(OPTIONS.component, sb)
        else:
            update_sandbox(sb)
    if OPTIONS.tag:
        if OPTIONS.component:
            tag_component(OPTIONS.component, sb)
        else:
            tag_sandbox(sb)
    if OPTIONS.pull:
        if OPTIONS.component:
            pull_component(OPTIONS.component, sb)
        else:
            pull_sandbox(sb, OPTIONS.source)
    if OPTIONS.push:
        if OPTIONS.component:
            push_component(OPTIONS.component, sb)
        else:
            push_sandbox(sb, OPTIONS.source)
Пример #3
0
def update_component_aspect(comp, sb, aspect, new_branch):
    err = 0
    wr = vcs.get_working_repository()
    if aspect == 'built':
        aspects = ['built.' + sb.get_targeted_platform_variant()]
##
##        aspects = []
##        pattern = '%s/%s/%s(\.[^/]+)' % (comp.branch, comp.name, aspect) #fix_julie repo structure
##        # Find all the built variants that have the specified branch.
##        aspect_suffixes = []
##        for branchpath in wr.branches:
##            m = re.match(pattern, '/'.join(branchpath))
##            if m:
##                if m.group(1) not in aspect_suffixes:
##                    aspect_suffixes.append(m.group(1))
##        aspects = [aspect + x for x in aspect_suffixes]
    else:
        aspects = [aspect]
    for a in aspects:
        sys.stdout.write('.')
        sys.stdout.flush()
        target_dir = sb.get_component_path(comp.name, a)
        if target_dir:
            print('  ' + _get_relative_path(sb, comp.name, a))
            aspect_folder = target_dir[0:target_dir.rfind(comp.name)]
            if not os.path.exists(aspect_folder):
                os.makedirs(aspect_folder)
            try:
                err = wr.create_or_update_checkout(target_dir, comp.name, a, comp.branch, comp.revision, use_master=new_branch)
            except:
                print(sys.exc_info()[1])
                err = 1
    return err
Пример #4
0
def convert_to_working_copy(sb, folder_to_publish, options):
    vprint('Converting %s to working copy.' % folder_to_publish, verbosity=1)
    use_master = False
    branch = '%s%s/%s/built.%s' % (options.repo, sb.get_branch(), sb.get_top_component(), #fix_julie repo structure knowledge
                                   sb.get_targeted_platform_variant())
    if bzr_node_needs_creating(branch, 'version-info', 'branch-nick:'):
        err = vcs.init(branch)
        if err:
            return err
        use_master = True
    tmpfldr = sb.get_built_root() + '.' + sb.get_top_component() + '~tmp~'
    wr = vcs.get_working_repository()
    err = wr.create_or_update_checkout(tmpfldr, sb.get_top_component(),
                                 'built.%s' % sb.get_targeted_platform_variant(),
                                 sb.get_branch(), revision=None,
                                 use_master=use_master)
    if err:
        return err
    try:
        for x in [x for x in os.listdir(tmpfldr) if x.startswith('.bzr')]:
            dest = os.path.join(folder_to_publish, x)
            if os.path.exists(dest):
                if os.path.isfile(dest):
                    os.remove(dest)
                else:
                    vprint('Error: %s already exists.' % dest)
                    return 1
            src = os.path.join(tmpfldr, x)
            os.rename(src, dest)
    finally:
        shutil.rmtree(tmpfldr)
    return 0
Пример #5
0
def pull_component(comp, sb, source):
    aspects = get_vcs_component_aspects(comp, sb)
    wr = vcs.get_working_repository()
    for a in aspects:
        pattern = '%s/%s/%s(\.[^/]+)' % (sb.get_branch(), comp, a)  #fix_julie repo structure
        aspect_suffixes = []
        for branchinfo in wr.branches:
            m = re.match(pattern, '/'.join(branchinfo))
            if m:
                aspect_suffixes.append(m.group(1))
        if aspect_suffixes:
            aspects = [a + x for x in aspect_suffixes]
        else:
            aspects = [a]
        for aspect in aspects:
            path = sb.get_component_path(comp, aspect)
            if source:
                if a.startswith(component.BUILT_ASPECT_NAME) or a == component.REPORT_ASPECT_NAME:
                    continue
                from_location = BranchInfo(branchname=source, componentname=comp, aspectname=aspect).get_branchdir(wr.source_reporoot)
            else:
                from_location = BranchInfo(branchname=sb.get_branch(), componentname=comp, aspectname=aspect).get_branchdir(wr.source_reporoot)
                print('  ' + _get_relative_path(sb, comp, aspect))
            try:
                vcs.pull(path, from_location=from_location)
            except:
                print(sys.exc_info()[1])
Пример #6
0
def pull_component(comp, sb, source):
    aspects = get_vcs_component_aspects(comp, sb)
    wr = vcs.get_working_repository()
    for a in aspects:
        pattern = '%s/%s/%s(\.[^/]+)' % (sb.get_branch(), comp, a
                                         )  #fix_julie repo structure
        aspect_suffixes = []
        for branchinfo in wr.branches:
            m = re.match(pattern, '/'.join(branchinfo))
            if m:
                aspect_suffixes.append(m.group(1))
        if aspect_suffixes:
            aspects = [a + x for x in aspect_suffixes]
        else:
            aspects = [a]
        for aspect in aspects:
            path = sb.get_component_path(comp, aspect)
            if source:
                if a.startswith(component.BUILT_ASPECT_NAME
                                ) or a == component.REPORT_ASPECT_NAME:
                    continue
                from_location = BranchInfo(branchname=source,
                                           componentname=comp,
                                           aspectname=aspect).get_branchdir(
                                               wr.source_reporoot)
            else:
                from_location = BranchInfo(branchname=sb.get_branch(),
                                           componentname=comp,
                                           aspectname=aspect).get_branchdir(
                                               wr.source_reporoot)
                print('  ' + _get_relative_path(sb, comp, aspect))
            try:
                vcs.pull(path, from_location=from_location)
            except:
                print(sys.exc_info()[1])
Пример #7
0
def apply_tag(sb, dry_run):
    tag = str(sb.get_build_id())
    vprint('Applying tag "%s" to entire sandbox.' % tag, verbosity=1)
    if dry_run:
        return
    err = 0
    for c in sb.get_cached_components():
        for a in sb.get_component_aspects(c.name):
            folder = sb.get_component_path(c.name, a)
            if vcs.folder_is_tied_to_vcs(folder):
                revid = None
                try:
                    vprint('Applying tag %s %s' % (c.get_name(), a), verbosity=1)
                    wr = vcs.get_working_repository()
                    if a == 'built':
                        a = "built.%s" % sb.get_targeted_platform_variant()
                    try:
                        revid = wr.get_local_revid(sb.get_branch(), c.get_name(), a)
                    except:
                        revid = None
                    wr.tag(tag, c.get_name(), a, sb.get_branch(), revisionid=revid)
                except:
                    txt = traceback.format_exc()
                    relative_path = folder[len(sb.get_root()):]
                    if 'TagAlreadyExists' in txt:
                        vprint('%s already tagged.' % relative_path, verbosity=2)
                    else:
                        vprint('Unable to tag %s.' % relative_path, verbosity=1)
                        if revid:
                            vprint('Untable to tag revid %s.' % revid, verbosity=1)
                        vprint('%s' % txt, verbosity=2)
    return err
Пример #8
0
def branch_component(comp, directory, branch):
    if not branch:
        print('Please enter a name for the new branch using the -b option.')
        return
    err = component.get_branch_name_validation_error(branch)
    if err:
        print err
        return
    wr = vcs.get_working_repository()
    aggregate_vcs.branch_component(wr.master_reporoot, comp, branch, _find_sb(directory))
Пример #9
0
def branch_component(comp, directory, branch):
    if not branch:
        print('Please enter a name for the new branch using the -b option.')
        return
    err = component.get_branch_name_validation_error(branch)
    if err:
        print err
        return
    wr = vcs.get_working_repository()
    aggregate_vcs.branch_component(wr.master_reporoot, comp, branch,
                                   _find_sb(directory))
Пример #10
0
    def add_dependencies(self, working_repo, componentname):
##        print('calculating dependencies for %s' % componentname)
        deps = self.lookup_dependencies(working_repo, componentname, returnList=True)
        wr = vcs.get_working_repository()
        deps = [wr.normalize(comp, 'code', self.branch)[0] for comp in deps]
##        print '\t', deps
        for comp in deps:
            self.infos[componentname].dependencies.append(comp)
            if not comp in self.infos:
                self.componentorder.append(comp)
                if not comp in self.omit_tree:
                    self.infos[comp] = ComponentInfo(comp, 'code',[])
                    self.add_dependencies(working_repo, comp)
Пример #11
0
def update_sandbox(sb, branch=None, aspect=None, new_branch=False):
    sys.stdout.write('Getting %s \n' % sb.get_name())
    sys.stdout.flush()
    err = 0
    try:
        top = sb.get_top_component()
        wr = vcs.get_working_repository()
        old_srr = None
        if not branch:
            branch = sb.get_branch()
        try:
            location = sb.get_code_root()
            if not aspect:
                aspect = sb.get_component_reused_aspect(sb.get_top_component())
            deps = metadata.get_components_inv_dep_order(wr, sb.get_targeted_platform_variant(), top, location, branch, aspect=aspect, use_master=new_branch)
            for comp in deps:
                aspects = [comp.reused_aspect, component.TEST_ASPECT_NAME]
                if comp.name == sb.get_top_component():
                    for br, c, asp, revid in wr.localbranches:
                        if br == branch and c == comp.name and asp == component.REPORT_ASPECT_NAME:
                            aspects.append(component.REPORT_ASPECT_NAME)
                            break
                    if component.REPORT_ASPECT_NAME not in aspects:
                        rbranches = vcs.get_branches(wr.master_reporoot, aspect=component.REPORT_ASPECT_NAME)
                        rbranches = [x[1] for x in rbranches if x[0] == branch]
                        if comp.name in rbranches:
                            aspects.append(component.REPORT_ASPECT_NAME)
                for a in aspects:
                    # TODO: warn if component reused aspect has changed
                    if update_component_aspect(comp, sb, a, new_branch):
                        err = 1
        except KeyboardInterrupt:
            sys.exit(1)
        except:
            print(sys.exc_info()[1])
        finally:
            if old_srr:
                wr.source_reporoot = old_srr
        if not err:
            bad_status = get_sandbox_status(sb, status_filter=lambda lbl: lbl.startswith('conflict'))
            if bad_status:
                print(format_sandbox_status(sb, bad_status))
                print('Manual intervention needed to resolve conflicts.')
                err = 1
        # Record our dependencies for later use.
        with open(sb.get_dependencies_file_path(), 'w') as f:
            for comp in deps:
                f.write(str(comp) + '\r\n')
    finally:
        print('')
        return err
Пример #12
0
def push_component(comp, sb, to, validate_status=True):
    if validate_status and _complain_component_not_clean(comp, sb, 'push'):
        return
    aspects = get_vcs_component_aspects(comp, sb)
    wr = vcs.get_working_repository()
    for a in aspects:
        if a.startswith(component.BUILT_ASPECT_NAME) or a == component.REPORT_ASPECT_NAME:
            continue
        path = sb.get_component_path(comp, a)
        if to:
            location=BranchInfo(branchname=to, componentname=comp, aspectname=a).get_branchdir(wr.master_reporoot)
        else:
            location=BranchInfo(branchname=sb.get_branch(), componentname=comp, aspectname=a).get_branchdir(wr.master_reporoot)
        print('  ' + _get_relative_path(sb, comp, a))
        vcs.push(path, location=location)
Пример #13
0
 def add_dependencies(self, working_repo, componentname):
     ##        print('calculating dependencies for %s' % componentname)
     deps = self.lookup_dependencies(working_repo,
                                     componentname,
                                     returnList=True)
     wr = vcs.get_working_repository()
     deps = [wr.normalize(comp, 'code', self.branch)[0] for comp in deps]
     ##        print '\t', deps
     for comp in deps:
         self.infos[componentname].dependencies.append(comp)
         if not comp in self.infos:
             self.componentorder.append(comp)
             if not comp in self.omit_tree:
                 self.infos[comp] = ComponentInfo(comp, 'code', [])
                 self.add_dependencies(working_repo, comp)
Пример #14
0
def branch_sandbox(to, source):
    if to is None:
        print('Please enter a name for the new branch using the --to option.')
        return
    if source is None:
        print('Please enter a name for the old branch/component using the --from option.')
        return
    if not '/' in source:
        print('From needs to be in format branch/component.')
        return
    err = component.get_branch_name_validation_error(to)
    if err is not None:
        print 'Branch %s' % err.lower()
        return
    wr = vcs.get_working_repository()
    wr.source_reporoot = wr.master_reporoot
    branch, comp = source.split('/')
    aggregate_vcs.branch_sandbox(wr, comp, branch, to)
Пример #15
0
def merge_component(comp, sb, source):
    aspects = get_vcs_component_aspects(comp, sb)
    wr = vcs.get_working_repository()
    for a in aspects:
        if a.startswith(component.BUILT_ASPECT_NAME):
            continue
        path = sb.get_component_path(comp, a)
        if source:
            if a == component.REPORT_ASPECT_NAME:
                continue
            from_location=BranchInfo(branchname=source, componentname=comp, aspectname=a).get_branchdir(wr.master_reporoot)
        else:
            from_location=BranchInfo(branchname=sb.get_branch(), componentname=comp, aspectname=a).get_branchdir(wr.master_reporoot)
        print('  ' + _get_relative_path(sb, comp, a))
        try:
            vcs.merge(path, from_location=from_location)
        except:
            print(sys.exc_info()[1])
Пример #16
0
def _check_remoting_info():
    if sadm_prompt.prompter.get_mode() == sadm_prompt.AUTOCONFIRM_MODE:
        return
    if not config.needs_remoting_info():
        return
    descr = buildinfo.BuildInfo()
    remoteInfo = ''
    print('''
Machines that automate sandbox operations should be remotely accessible for
configuration and troubleshooting purposes. Please provide the following
information to facilitate this.
''')
    config.username_for_remote_access = sadm_prompt.prompt('Username for remote login', config.username_for_remote_access)
    config.ipaddr = sadm_prompt.prompt('IP address', config.ipaddr)
    config.ssh_port = sadm_prompt.prompt('Port for ssh', config.ssh_port)
    config.remote_desktop_port = sadm_prompt.prompt('Port for remote desktop', config.remote_desktop_port)
    config.remoting_instructions = sadm_prompt.prompt('''
Other instructions for accessing this machine remotely (such as where to get the password etc.)''', config.remoting_instructions)
    if config.ssh_port:
        remoteInfo += 'ssh to %s:%s as %s\n' % (config.ipaddr, config.ssh_port, config.username_for_remote_access)
    if config.remote_desktop_port:
        remoteInfo += 'remote desktop to %s:%s\n' % (config.ipaddr, config.remote_desktop_port)
    if config.remoting_instructions:
        remoteInfo += '%s' % config.remoting_instructions
    build_machines = tempfile.mkdtemp()
    wr = vcs.get_working_repository()
    vcs.checkout(os.path.join(wr.master_reporoot, 'BuildMachines').replace('\\','/'), build_machines)
    if os.name == 'nt':
        site = os.environ['COMPUTERNAME'].lower()
    else:
        site = os.environ['HOSTNAME'].lower()
    fldr = os.path.join(build_machines, site)
    if not os.path.isdir(fldr):
        os.makedirs(fldr)
    fp = open(os.path.join(fldr, REMOTE_INFO_FILE), 'w')
    fp.write(remoteInfo)
    fp.close()
    vcs.add(build_machines)
    try:
        vcs.checkin(build_machines, 'Update remote info for %s' % site, quiet=True)
    except:
        pass
Пример #17
0
def branch_sandbox(to, source):
    if to is None:
        print('Please enter a name for the new branch using the --to option.')
        return
    if source is None:
        print(
            'Please enter a name for the old branch/component using the --from option.'
        )
        return
    if not '/' in source:
        print('From needs to be in format branch/component.')
        return
    err = component.get_branch_name_validation_error(to)
    if err is not None:
        print 'Branch %s' % err.lower()
        return
    wr = vcs.get_working_repository()
    wr.source_reporoot = wr.master_reporoot
    branch, comp = source.split('/')
    aggregate_vcs.branch_sandbox(wr, comp, branch, to)
Пример #18
0
def update_component_aspect(comp, sb, aspect, new_branch):
    err = 0
    wr = vcs.get_working_repository()
    if aspect == 'built':
        aspects = ['built.' + sb.get_targeted_platform_variant()]


##
##        aspects = []
##        pattern = '%s/%s/%s(\.[^/]+)' % (comp.branch, comp.name, aspect) #fix_julie repo structure
##        # Find all the built variants that have the specified branch.
##        aspect_suffixes = []
##        for branchpath in wr.branches:
##            m = re.match(pattern, '/'.join(branchpath))
##            if m:
##                if m.group(1) not in aspect_suffixes:
##                    aspect_suffixes.append(m.group(1))
##        aspects = [aspect + x for x in aspect_suffixes]
    else:
        aspects = [aspect]
    for a in aspects:
        sys.stdout.write('.')
        sys.stdout.flush()
        target_dir = sb.get_component_path(comp.name, a)
        if target_dir:
            print('  ' + _get_relative_path(sb, comp.name, a))
            aspect_folder = target_dir[0:target_dir.rfind(comp.name)]
            if not os.path.exists(aspect_folder):
                os.makedirs(aspect_folder)
            try:
                err = wr.create_or_update_checkout(target_dir,
                                                   comp.name,
                                                   a,
                                                   comp.branch,
                                                   comp.revision,
                                                   use_master=new_branch)
            except:
                print(sys.exc_info()[1])
                err = 1
    return err
Пример #19
0
def push_component(comp, sb, to, validate_status=True):
    if validate_status and _complain_component_not_clean(comp, sb, 'push'):
        return
    aspects = get_vcs_component_aspects(comp, sb)
    wr = vcs.get_working_repository()
    for a in aspects:
        if a.startswith(component.BUILT_ASPECT_NAME
                        ) or a == component.REPORT_ASPECT_NAME:
            continue
        path = sb.get_component_path(comp, a)
        if to:
            location = BranchInfo(branchname=to,
                                  componentname=comp,
                                  aspectname=a).get_branchdir(
                                      wr.master_reporoot)
        else:
            location = BranchInfo(branchname=sb.get_branch(),
                                  componentname=comp,
                                  aspectname=a).get_branchdir(
                                      wr.master_reporoot)
        print('  ' + _get_relative_path(sb, comp, a))
        vcs.push(path, location=location)
Пример #20
0
def merge_component(comp, sb, source):
    aspects = get_vcs_component_aspects(comp, sb)
    wr = vcs.get_working_repository()
    for a in aspects:
        if a.startswith(component.BUILT_ASPECT_NAME):
            continue
        path = sb.get_component_path(comp, a)
        if source:
            if a == component.REPORT_ASPECT_NAME:
                continue
            from_location = BranchInfo(branchname=source,
                                       componentname=comp,
                                       aspectname=a).get_branchdir(
                                           wr.master_reporoot)
        else:
            from_location = BranchInfo(branchname=sb.get_branch(),
                                       componentname=comp,
                                       aspectname=a).get_branchdir(
                                           wr.master_reporoot)
        print('  ' + _get_relative_path(sb, comp, a))
        try:
            vcs.merge(path, from_location=from_location)
        except:
            print(sys.exc_info()[1])
Пример #21
0
def update_sandbox(sb, branch=None, aspect=None, new_branch=False):
    sys.stdout.write('Getting %s \n' % sb.get_name())
    sys.stdout.flush()
    err = 0
    try:
        top = sb.get_top_component()
        wr = vcs.get_working_repository()
        old_srr = None
        if not branch:
            branch = sb.get_branch()
        try:
            location = sb.get_code_root()
            if not aspect:
                aspect = sb.get_component_reused_aspect(sb.get_top_component())
            deps = metadata.get_components_inv_dep_order(
                wr,
                sb.get_targeted_platform_variant(),
                top,
                location,
                branch,
                aspect=aspect,
                use_master=new_branch)
            for comp in deps:
                aspects = [comp.reused_aspect, component.TEST_ASPECT_NAME]
                if comp.name == sb.get_top_component():
                    for br, c, asp, revid in wr.localbranches:
                        if br == branch and c == comp.name and asp == component.REPORT_ASPECT_NAME:
                            aspects.append(component.REPORT_ASPECT_NAME)
                            break
                    if component.REPORT_ASPECT_NAME not in aspects:
                        rbranches = vcs.get_branches(
                            wr.master_reporoot,
                            aspect=component.REPORT_ASPECT_NAME)
                        rbranches = [x[1] for x in rbranches if x[0] == branch]
                        if comp.name in rbranches:
                            aspects.append(component.REPORT_ASPECT_NAME)
                for a in aspects:
                    # TODO: warn if component reused aspect has changed
                    if update_component_aspect(comp, sb, a, new_branch):
                        err = 1
        except KeyboardInterrupt:
            sys.exit(1)
        except:
            print(sys.exc_info()[1])
        finally:
            if old_srr:
                wr.source_reporoot = old_srr
        if not err:
            bad_status = get_sandbox_status(
                sb, status_filter=lambda lbl: lbl.startswith('conflict'))
            if bad_status:
                print(format_sandbox_status(sb, bad_status))
                print('Manual intervention needed to resolve conflicts.')
                err = 1
        # Record our dependencies for later use.
        with open(sb.get_dependencies_file_path(), 'w') as f:
            for comp in deps:
                f.write(str(comp) + '\r\n')
    finally:
        print('')
        return err
Пример #22
0
def report(sb, state):
    rr = sb.get_report_root()
    root = sb.get_root()
    need_checkin = vcs.folder_is_tied_to_vcs(rr)
    try:
        # Get latest version of reports so we are less likely to cause merge
        # conflicts.
        wr = vcs.get_working_repository()
        use_master = False
        if not need_checkin:
            url = os.path.join(
                wr.master_reporoot,
                sb.get_branch(),
                sb.get_top_component(),
                'report',
            ).replace('\\', '/')
            publish.create_branch(url, False)
            use_master = True
        wr.create_or_update_checkout(rr,
                                     sb.get_top_component(),
                                     'report',
                                     sb.get_branch(),
                                     None,
                                     use_master=use_master)
        need_checkin = vcs.folder_is_tied_to_vcs(rr)
        # Report our results.
        bi = buildinfo.BuildInfo()
        machineFolder = os.path.join(rr, bi.host).replace('\\', '/')
        summary = EvalSummary(sb.get_build_id(),
                              sb.get_sandboxtype().get_style(), bi.host,
                              state.phase, state.reason, state.start_time,
                              state.timestamps,
                              sb.get_targeted_platform_variant(), bi.os,
                              bi.bitness, bi.version)
        db = Dashboard(rr)
        db.add_summary(summary)
        if os.path.exists(os.path.join(root, 'eval-log.txt')):
            shutil.copy2(os.path.join(root, 'eval-log.txt'), machineFolder)
        # Check in our changes.
        if need_checkin:
            status = vcs.get_status(rr)
            if 'unknown' in status:
                vcs.add(rr)
            vcs.checkin(rr, msg="update dashboard", quiet_stderr=True)
            try:
                vcs.push(rr)
            except BzrCommandError, e:
                if 'diverged' in ("%s" % e):
                    print "\nAttemping to resolve diverged report aspect"
                    print "\nNuking report dir %s" % rr
                    if not ioutil.nuke(rr):
                        print "\nAuto resolving diverged report aspect failed!"

                    bi = BranchInfo(branchname=sb.get_branch(),
                                    componentname=sb.get_top_component(),
                                    aspectname='report')
                    aspectdir = bi.get_branchdir(wr.local_reporoot)
                    print "\nNuking report repo %s" % aspectdir
                    if not ioutil.nuke(aspectdir):
                        print "\nAuto resolving diverged report aspect failed!"

                    # Use the master because we have a problem here.
                    wr.create_local_branch(sb.get_top_component(),
                                           'report',
                                           sb.get_branch(),
                                           use_master=True)
                    wr.create_or_update_checkout(rr,
                                                 sb.get_top_component(),
                                                 'report',
                                                 sb.get_branch(),
                                                 None,
                                                 use_master=True)

                    db = Dashboard(rr)
                    db.add_summary(summary)
                    if os.path.exists(os.path.join(root, 'eval-log.txt')):
                        shutil.copy2(os.path.join(root, 'eval-log.txt'),
                                     machineFolder)

                    status = vcs.get_status(rr)
                    if 'unknown' in status:
                        vcs.add(rr)
                    vcs.checkin(rr, msg="update dashboard", quiet_stderr=True)
                    vcs.push(rr)
                    print "\nAuto resolve diverged report aspect success!"
                else:
                    raise e
    except:
        traceback.print_exc()
Пример #23
0
def report(sb, state):
    rr = sb.get_report_root()
    root = sb.get_root()
    need_checkin = vcs.folder_is_tied_to_vcs(rr)
    try:
        # Get latest version of reports so we are less likely to cause merge
        # conflicts.
        wr = vcs.get_working_repository()
        use_master = False
        if not need_checkin:
            url = os.path.join(wr.master_reporoot, sb.get_branch(), sb.get_top_component(), 'report', ). replace('\\', '/')
            publish.create_branch(url, False)
            use_master = True
        wr.create_or_update_checkout(rr, sb.get_top_component(), 'report', sb.get_branch(), None, use_master=use_master)
        need_checkin = vcs.folder_is_tied_to_vcs(rr)
        # Report our results.
        bi = buildinfo.BuildInfo()
        machineFolder = os.path.join(rr, bi.host).replace('\\', '/')
        summary = EvalSummary(sb.get_build_id(), sb.get_sandboxtype().get_style(), bi.host,
                              state.phase, state.reason, state.start_time,
                              state.timestamps, sb.get_targeted_platform_variant(),
                              bi.os, bi.bitness, bi.version)
        db = Dashboard(rr)
        db.add_summary(summary)
        if os.path.exists(os.path.join(root, 'eval-log.txt')):
            shutil.copy2(os.path.join(root, 'eval-log.txt'), machineFolder)
        # Check in our changes.
        if need_checkin:
            status = vcs.get_status(rr)
            if 'unknown' in status:
                vcs.add(rr)
            vcs.checkin(rr, msg="update dashboard", quiet_stderr=True)
            try:
                vcs.push(rr)
            except BzrCommandError, e:
                if 'diverged' in ("%s" % e):
                    print "\nAttemping to resolve diverged report aspect"
                    print "\nNuking report dir %s" % rr
                    if not ioutil.nuke(rr):
                        print "\nAuto resolving diverged report aspect failed!"

                    bi = BranchInfo(branchname=sb.get_branch(), componentname=sb.get_top_component(), aspectname='report')
                    aspectdir = bi.get_branchdir(wr.local_reporoot)
                    print "\nNuking report repo %s" % aspectdir
                    if not ioutil.nuke(aspectdir):
                        print "\nAuto resolving diverged report aspect failed!"

                    # Use the master because we have a problem here.
                    wr.create_local_branch(sb.get_top_component(), 'report', sb.get_branch(), use_master=True)
                    wr.create_or_update_checkout(rr, sb.get_top_component(), 'report', sb.get_branch(), None, use_master=True)

                    db = Dashboard(rr)
                    db.add_summary(summary)
                    if os.path.exists(os.path.join(root, 'eval-log.txt')):
                        shutil.copy2(os.path.join(root, 'eval-log.txt'), machineFolder)

                    status = vcs.get_status(rr)
                    if 'unknown' in status:
                        vcs.add(rr)
                    vcs.checkin(rr, msg="update dashboard", quiet_stderr=True)
                    vcs.push(rr)
                    print "\nAuto resolve diverged report aspect success!"
                else:
                    raise e
    except:
        traceback.print_exc()
Пример #24
0
    parser.add_option('--dry-run', dest="dry_run", action='store_true', help="simulate and return success", default=False)

    return parser

if __name__ == '__main__':
    parser = _define_options()
    options, args = parser.parse_args(sys.argv)
    try:
        sb = sandbox.create_from_within(options.sandbox)
        if not sb:
            print('%s does not appear to be inside a sandbox.' % os.path.abspath(options.sandbox))
            err = 1
        else:
            if 1:
                import pprint
                pprint.pprint(get_components_in_product(branch=sb.get_branch(), topcomponent=sb.get_top_component()))
            else:
                deps, tree = get_components_inv_dep_order(vcs.get_working_repository(), sb.get_top_component(), code_root=sb.get_code_root(),
                                                         branch=sb.get_branch(), aspect=sb.get_component_reused_aspect(sb.get_top_component()), debug=True)
                print('Dependencies:')
                for comp in deps:
                    print comp
                print('-----------------------------------')
                print('Full dependance tree')
                print_tree(tree)
            err = 0
    except:
        traceback.print_exc()
        err = 1
    sys.exit(err)
Пример #25
0
 try:
     sb = sandbox.create_from_within(options.sandbox)
     if not sb:
         print('%s does not appear to be inside a sandbox.' %
               os.path.abspath(options.sandbox))
         err = 1
     else:
         if 1:
             import pprint
             pprint.pprint(
                 get_components_in_product(
                     branch=sb.get_branch(),
                     topcomponent=sb.get_top_component()))
         else:
             deps, tree = get_components_inv_dep_order(
                 vcs.get_working_repository(),
                 sb.get_top_component(),
                 code_root=sb.get_code_root(),
                 branch=sb.get_branch(),
                 aspect=sb.get_component_reused_aspect(
                     sb.get_top_component()),
                 debug=True)
             print('Dependencies:')
             for comp in deps:
                 print comp
             print('-----------------------------------')
             print('Full dependance tree')
             print_tree(tree)
         err = 0
 except:
     traceback.print_exc()