Update apt index if not update in last N days
558772
def update_apt(days=3, upgrade=False):
    """"""
    # Check the apt-get update timestamp (works on Ubuntu only)
    with settings(warn_only=True):
        last_update = run(
            "stat -c %Y /var/lib/apt/periodic/update-success-stamp")
    if ('cannot stat' in last_update
            or (time.time() - float(last_update)) > days * 86400):
        sudo("apt-get --yes update")
        if upgrade:
            sudo("apt-get --yes upgrade")
505063
def update(ctx, no_restart, no_rebuild):
    """"""

    # 0. (NOT YET! MAKE A BACKUP OF EVERYTHING)
    # 1. update repository
    # 2. update frontend repository
    # 3. (Not yet: update venv)
    # 4. rebuild frontend
    # 5. restart service

    instance = ctx.obj['instance']

    log('Pulling github updates')
    run_process('.', ['git', 'pull', 'origin', 'master'])
    run_process('./frontend', ['git', 'pull', 'origin', 'master'])

    if not no_rebuild:
        log('Rebuilding frontend')
        install_frontend(instance, forcerebuild=True, install=False, development=True)

    if not no_restart:
        log('Restaring service')
        if instance != 'hfos':
            instance = 'hfos-' + instance

        run_process('.', ['sudo', 'systemctl', 'restart', instance])

    log('Done')
1068845
def update_stale(self):
        """"""
        # Some events don't post an inactive XML, only active.
        # If we don't get an active update for 5 seconds we can
        # assume the event is no longer active and update accordingly.
        for etype, echannels in self.event_states.items():
            for eprop in echannels:
                if eprop[3] is not None:
                    sec_elap = ((datetime.datetime.now()-eprop[3])
                                .total_seconds())
                    # print('Seconds since last update: {}'.format(sec_elap))
                    if sec_elap > 5 and eprop[0] is True:
                        _LOGGING.debug('Updating stale event %s on CH(%s)',
                                       etype, eprop[1])
                        attr = [False, eprop[1], eprop[2],
                                datetime.datetime.now()]
                        self.update_attributes(etype, eprop[1], attr)
                        self.publish_changes(etype, eprop[1])
636620
def check_rollout(edits_service, package_name, days):
    """"""
    edit = edits_service.insert(body={}, packageName=package_name).execute()
    response = edits_service.tracks().get(editId=edit['id'], track='production', packageName=package_name).execute()
    releases = response['releases']
    for release in releases:
        if release['status'] == 'inProgress':
            url = 'https://archive.mozilla.org/pub/mobile/releases/{}/SHA512SUMS'.format(release['name'])
            resp = requests.head(url)
            if resp.status_code != 200:
                if resp.status_code != 404:  # 404 is expected for release candidates
                    logger.warning("Could not check %s: %s", url, resp.status_code)
                continue
            age = time.time() - calendar.timegm(eu.parsedate(resp.headers['Last-Modified']))
            if age >= days * DAY:
                yield release, age
832243
def update(self, quiet=False, prefix='[polyglot_data] '):
    
    self.clear_status_cache()
    for pkg in self.packages():
      if self.status(pkg) == self.STALE:
        self.download(pkg, quiet=quiet, prefix=prefix)
247844
def wait_for_package_sync(
    ctx, opts, owner, repo, slug, wait_interval, skip_errors, attempts=3
):
    """"""
    # pylint: disable=too-many-locals
    attempts -= 1
    click.echo()
    label = "Synchronising %(package)s:" % {"package": click.style(slug, fg="green")}

    status_str = "Waiting"
    stage_str = None

    def display_status(current):
        """Display current sync status."""
        # pylint: disable=unused-argument
        if not stage_str:
            return status_str
        return click.style(
            "%(status)s / %(stage)s" % {"status": status_str, "stage": stage_str},
            fg="cyan",
        )

    context_msg = "Failed to synchronise file!"
    with handle_api_exceptions(
        ctx, opts=opts, context_msg=context_msg, reraise_on_error=skip_errors
    ):
        last_progress = 0
        with click.progressbar(
            length=100,
            label=label,
            fill_char=click.style("#", fg="green"),
            empty_char=click.style("-", fg="red"),
            item_show_func=display_status,
        ) as pb:
            while True:
                res = get_package_status(owner, repo, slug)
                ok, failed, progress, status_str, stage_str, reason = res
                delta = progress - last_progress
                if delta > 0:
                    last_progress = progress
                    pb.update(delta)
                if ok or failed:
                    break
                time.sleep(wait_interval)

    if ok:
        click.secho("Package synchronised successfully!", fg="green")
        return

    click.secho(
        "Package failed to synchronise during stage: %(stage)s"
        % {"stage": click.style(stage_str or "Unknown", fg="yellow")},
        fg="red",
    )

    if reason:
        click.secho(
            "Reason given: %(reason)s" % {"reason": click.style(reason, fg="yellow")},
            fg="red",
        )

        # pylint: disable=fixme
        # FIXME: The API should communicate "no retry" fails
        if "package should be deleted" in reason and attempts > 1:
            click.secho(
                "This is not recoverable, so stopping further attempts!", fg="red"
            )
            click.echo()
            attempts = 0

    if attempts + 1 > 0:
        # Show attempts upto and including zero attempts left
        click.secho(
            "Attempts left: %(left)s (%(action)s)"
            % {
                "left": click.style(six.text_type(attempts), bold=True),
                "action": "trying again" if attempts > 0 else "giving up",
            }
        )
        click.echo()

    if attempts > 0:
        from .resync import resync_package

        resync_package(
            ctx=ctx,
            opts=opts,
            owner=owner,
            repo=repo,
            slug=slug,
            skip_errors=skip_errors,
        )

        wait_for_package_sync(
            ctx=ctx,
            opts=opts,
            owner=owner,
            repo=repo,
            slug=slug,
            wait_interval=wait_interval,
            skip_errors=skip_errors,
            attempts=attempts,
        )
    else:
        ctx.exit(1)
685259
def check_for_update(self):
        
        try:
            version = pkg_resources.require("zappa")[0].version
            updateable = check_new_version_available(version)
            if updateable:
                click.echo(click.style("Important!", fg="yellow", bold=True) +
                           " A new version of " + click.style("Zappa", bold=True) + " is available!")
                click.echo("Upgrade with: " + click.style("pip install zappa --upgrade", bold=True))
                click.echo("Visit the project page on GitHub to see the latest changes: " +
                           click.style("https://github.com/Miserlou/Zappa", bold=True))
        except Exception as e: # pragma: no cover
            print(e)
            return
1119100
def cli(obj):
    """"""
    client = obj['client']
    status = client.mgmt_status()

    now = datetime.fromtimestamp(int(status['time']) / 1000.0)
    uptime = datetime(1, 1, 1) + timedelta(seconds=int(status['uptime']) / 1000.0)

    click.echo('{} up {} days {:02d}:{:02d}'.format(
        now.strftime('%H:%M'),
        uptime.day - 1, uptime.hour, uptime.minute
    ))
30478
def track_update(self):
        """"""
        metadata = self.info()
        metadata.updated_at = dt.datetime.now()
        self.commit()
598565
def update kwargs={}
      ignore_cksum = kwargs.arg :ignore_cksum, false
      ignore_sigs = kwargs.arg :ignore_sigs, false

      cmd = 'aptly mirror update'
      cmd += ' -ignore-checksums' if ignore_cksum
      cmd += ' -ignore-signatures' if ignore_sigs
      cmd += " #{@name.quote}"

      Aptly::runcmd cmd
    end
627902
@GuardedBy("lock")
  private void updateStats() {
    mInternalStatFs = updateStatsHelper(mInternalStatFs, mInternalPath);
    mExternalStatFs = updateStatsHelper(mExternalStatFs, mExternalPath);
    mLastRestatTime = SystemClock.uptimeMillis();
  }
1069191
function updateDepsTo (arg, cb) {
  asyncMap(arg._others, function (o, cb) {
    updateOtherVersionDeps(o, arg, cb)
  }, cb)
}
1050942
def update(self):
        """"""
        for linenum in reversed(sorted(self.updates)):
            self.replace_baseline_repr(linenum, self.updates[linenum])

        if not self.TEST_MODE:
            path = '{}.update{}'.format(*os.path.splitext(self.path))
            with io.open(path, 'w', encoding='utf-8') as fh:
                fh.write('\n'.join(self.lines))
            print('UPDATE: {}'.format(self.showpath(path)))
982312
private boolean setUpdated(Date lastUpdateTime) {
        // Because there is no gaurantee of order of delivery,
        // we want to ensure that we do not set the updated time if it was
        // earlier than the current updated time
        if (updated == null || updated.compareTo(lastUpdateTime) < 0) {
            updated = lastUpdateTime;
            return true;
        }
        return false;
    }
783510
def update_lambda(self, *args, **kwargs):
        

        """

        if self.restart_strategy == 'greedy':
            return 2

        # Steps 3 and 4 from alg.10.7.
        self._t_prev = self._t_now

        if self.mode == 'regular':
            self._t_now = (self.p_lazy + np.sqrt(self.r_lazy *
                           self._t_prev ** 2 + self.q_lazy)) * 0.5

        elif self.mode == 'CD':
            self._t_now = (self._n + self.a_cd - 1) / self.a_cd
            self._n += 1

        return 1 + (self._t_prev - 1) / self._t_now
370957
def run_outdated(cls, options):
        """"""
        latest_versions = sorted(
            cls.find_packages_latest_versions(cls.options),
            key=lambda p: p[0].project_name.lower())

        for dist, latest_version, typ in latest_versions:
            if latest_version > dist.parsed_version:
                if options.all:
                    pass
                elif options.pinned:
                    if cls.can_be_updated(dist, latest_version):
                        continue
                elif not options.pinned:
                    if not cls.can_be_updated(dist, latest_version):
                        continue
                    elif options.update:
                        print(dist.project_name if options.brief else
                              'Updating %s to Latest: %s [%s]' %
                              (cls.output_package(dist), latest_version, typ))
                        main(['install', '--upgrade'] + ([
                            '--user'
                        ] if ENABLE_USER_SITE else []) + [dist.key])
                        continue

                print(dist.project_name if options.brief else
                      '%s - Latest: %s [%s]' %
                      (cls.output_package(dist), latest_version, typ))
283478
def last_modified_date(filename):
    """"""
    mtime = os.path.getmtime(filename)
    dt = datetime.datetime.utcfromtimestamp(mtime)
    return dt.replace(tzinfo=pytz.utc)