Exemple #1
0
def _setup_convenience_funcs():
    if os.name == 'nt':
        _setup_windows_path()
    else:
        bash_profile = '.bashrc'
        machineInfo = buildinfo.BuildInfo()
        if machineInfo.os == 'OSX':
            bash_profile = '.bash_profile'
        bash_profile = join_path(HOMEDIR, bash_profile)
        txt = ''
        if os.path.isfile(bash_profile):
            txt = read_file(bash_profile)
            if txt.find(_SADM_BASH_CMDS_FILE) > -1:
                print('\nConvenience functions appear to be installed in %s.\n' % bash_profile)
                linked_path, updated = _update_bash_funcs()
                if updated:
                    eprintc('\nContent in %s has been updated. Restart bash to get updates.\n' % linked_path, WARNING_COLOR)
                return
        print('')
        if sadm_prompt.prompt_bool('Add convenience functions like "sb cr" and "sb build" to %s' % bash_profile, 'y'):
            print('')
            cmds_path, updated = _update_bash_funcs()
            txt = read_file(bash_profile).rstrip()
            txt += '\n\n# Convenience functions installed by sadm\ntest -r %s && source %s\n\n' % (cmds_path, cmds_path)
            save(bash_profile, txt)
            eprintc('Restart bash to get updates.\n', WARNING_COLOR)
Exemple #2
0
def _check_uac():
    if os.name == 'nt':
        if config.uac_disabled is None:
            if user_has_admin_privileges():
                config.uac_disabled = sadm_prompt.prompt_bool(
'''You're currently running in a command prompt with elevated privileges. Is
this because you disabled UAC permanently?''', 'y')
            else:
                config.uac_disabled = False
Exemple #3
0
def _check_continuous_activity_window():
    cmd = '%s --no-color next' % APP_INVOKE
    sched = DEFAULT_NEXT_SCHEDULE
    rng = ''
    defValue = config.default_continuous_range
    if not defValue:
        if config.is_canonical_machine:
            defValue = "0400 to 2200"
        else:
            defValue = '*'
    print('''
Continuous builds can be constrained to an activity window so that during off
hours, system resources can be used elsewhere. This is important if you plan to
run performance tests, among other things.
''')
    rng = sadm_prompt.prompt('Hours for running continuous sandboxes (e.g., 0100 to 2200; "*" = all)', defValue)
    if rng and (rng == '*' or rng == 'all'):
        rng = ''
    config.schedule_continuous_manually = sadm_prompt.prompt_bool('\nSchedule continuous sandboxes manually?', _get_prompt_bool_repr(config.schedule_continuous_manually))
    if not config.schedule_continuous_manually:
        # Remove any manually-scheduled, continuous sandboxes from the schedule.
        unschedule = [sb for sb in Sandbox.list() if (sb.get_sandboxtype().get_should_schedule() and sb.schedule)]
        for sb in unschedule:
            sb.schedule = None
            sb.applySchedule()
    # Only allow overriding standard interval on non-canonical machines.
    if not config.is_canonical_machine:
        if config.continuous_interval:
            # Make sure we only have the interval part, not the range.
            sched = str(Schedule(config.continuous_interval))
        sched = sadm_prompt.prompt('\nIf idle, start next continuous sandbox ("never" to disable)', sched)
    # Again, make sure we only have the interval part.
    if sched:
        sched = Schedule(sched)
        if sched.is_periodic():
            sched = 'every ' + sched.every
        else:
            sched = 'never'
    else:
        sched = DEFAULT_NEXT_SCHEDULE
    # Add the range part on, regardless of where the interval came from.
    if rng:
        if sched != 'never':
            sched += ", " + rng
        else:
            rng = ''
    sched = Schedule(sched)
    Schedule.apply_to_arbitrary_command(cmd, 'run next continuous sandbox', sched, removeOnly=(config.schedule_continuous_manually))
    if rng:
        rng = '%s to %s' % (sched.range[0], sched.range[1])
    if not rng:
        print('''
Performance tests are disallowed on this box, since unconstrained continuous
builds might invalidate results.
''')
    config.default_continuous_range = rng
Exemple #4
0
def _check_canonical():
    if config.could_be_canonical_machine():
        print('''
Canonical build machines are managed by CM. They have a specific set of tools
installed (nothing extra), meet a minimal hardware spec, use standard
credentials and network config, and do nothing besides evaluate sandboxes.
When a build fails on a canonical build machine, the owner of the box and the
owner of the svn project cooperate to fix it. Many sadm settings are hard-coded
for such machines.
''')
        config.is_canonical_machine = sadm_prompt.prompt_bool('Treat this box as a canonical build machine?', _get_prompt_bool_repr(config.is_canonical_machine))
        if config.is_canonical_machine:
            config.auto_add_sandboxes = sadm_prompt.prompt_bool('Automatically add sandboxes?', _get_prompt_bool_repr(config.auto_add_sandboxes))
            config.branches_to_auto_add = sadm_prompt.prompt('Which branches would you like to add sandboxes from.(Give a list seperated by commas e.i. trunk,push_feature,... or all for all branches.)', config.branches_to_auto_add)
        else:
            config.auto_add_sandboxes = False
    else:
        config.is_canonical_machine = False
        config.auto_add_sandboxes = False
Exemple #5
0
def _check_auto_update():
    originalValue = bool(config.auto_update)
    if config.is_canonical_machine:
        print('\nSadm will be scheduled to auto-update itself each night.')
        config.auto_update = True
    else:
        config.auto_update = sadm_prompt.prompt_bool('\nSchedule %s to auto-update itself each night?' % APP_CMD, _get_prompt_bool_repr(config.auto_update))
    if config.auto_update != originalValue:
        taskName = 'update %s' % APP_CMD
        cmd = '%s --no-color --auto-confirm update' % APP_INVOKE
        sched = Schedule(DEFAULT_UPDATE_TIME)
        Schedule.apply_to_arbitrary_command(cmd, taskName, sched, removeOnly=(not config.auto_update))
Exemple #6
0
def _check_autoget_dev():
    oldAutoUpdateDev = bool(config.auto_update_dev_sandboxes)
    if config.machine_role.startswith('dev'):
        print('''
If you have a lot of dev sandboxes, it can be useful to have them updated
automatically before you come in in the morning. This guarantees that you are
never working off of stale versions of the code, and it makes unexpected merge
conflicts less likely to occur when you check in. However, it can also be
problematic, because code that you mostly have working when you go home one
day can be merged into a different state when you come in the next day.
''')
        config.auto_update_dev_sandboxes = sadm_prompt.prompt_bool('Auto-get code in *dev before work each morning?', _get_prompt_bool_repr(config.auto_update_dev_sandboxes))
    newAutoUpdateDev = bool(config.auto_update_dev_sandboxes)
    if oldAutoUpdateDev != newAutoUpdateDev:
        taskName = "get dev sandboxes"
        cmd = '%s get *dev' % APP_INVOKE
        sched = Schedule(DEFAULT_AUTO_GET_TIME)
        Schedule.apply_to_arbitrary_command(cmd, taskName, sched)
Exemple #7
0
def _check_automated_builds():
    if not config.is_canonical_machine:
        config.build_queue_schedule = 'never'
    originalCfg = str(config.allow_official_builds) + config.build_queue_schedule
    if config.is_canonical_machine:
        print('''
On canonical build machines, official builds are allowed. However, some such
machines may not wish to do them, since they can complicate the scheduling of
continuous builds...
''')
        config.allow_official_builds = sadm_prompt.prompt_bool('Allow official builds?', _get_prompt_bool_repr(config.allow_official_builds))
    else:
        config.allow_official_builds = False
    email_list = ''
    if config.allow_official_builds:
        config.archiveRepo = sadm_prompt.prompt('\nArchive repo url', config.archiveRepo)
    if config.is_canonical_machine:
        config.build_queue_url = prompt('\nBase url for build queue', config.build_queue_url)
        queueSched = sadm_prompt.prompt('\nCheck build queue for new requests ("never" to disable)', config.build_queue_schedule)
        queueSched = Schedule(queueSched)
        email_list = sadm_prompt.prompt('\nEmails to notify of official build results (comma-separated)', config.email_list)
    else:
        queueSched = Schedule("never")
    if email_list:
        if type(email_list).__name__ == 'list':
            config.email_list = email_list
        else:
            config.email_list = [x for x in email_list.split(',').strip()]
            config.email_list.append(config.mailto)
    else:
        config.email_list = [config.mailto]
    newCfg = str(config.allow_official_builds) + str(queueSched)
    if newCfg != originalCfg:
        config.build_queue_schedule = str(queueSched)
        taskName = "check official build queue"
        cmd = '%s service' % APP_INVOKE
        Schedule.apply_to_arbitrary_command(cmd, taskName, queueSched, removeOnly=(not config.allow_official_builds))