def uptodate_index(quiet=True, max_age=86400): """ Require an up-to-date package index. This will update the package index (using ``apt-get update``) if the last update occured more than *max_age* ago. *max_age* can be specified either as an integer (a value in seconds), or as a dictionary whose keys are units (``seconds``, ``minutes``, ``hours``, ``days``, ``weeks``, ``months``) and values are integers. The default value is 1 hour. Examples: :: from fabtools import require # Update index if last time was more than 1 day ago require.deb.uptodate_index(max_age={'day': 1}) # Update index if last time was more than 1 hour and 30 minutes ago require.deb.uptodate_index(max_age={'hour': 1, 'minutes': 30}) """ from fabtools.require import file as require_file require_file('/etc/apt/apt.conf.d/15fabtools-update-stamp', contents='''\ APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/fabtools-update-success-stamp 2>/dev/null || true";}; ''', use_sudo=True) if system.time() - last_update_time() > _to_seconds(max_age): update_index(quiet=quiet)
def uptodate_index(quiet=True, max_age=86400): """ Require an up-to-date package index. This will update the package index (using ``apt-get update``) if the last update occured more than *max_age* ago. *max_age* can be specified either as an integer (a value in seconds), or as a dictionary whose keys are units (``seconds``, ``minutes``, ``hours``, ``days``, ``weeks``, ``months``) and values are integers. The default value is 1 hour. Examples: :: from fabtools import require # Update index if last time was more than 1 day ago require.deb.uptodate_index(max_age={'day': 1}) # Update index if last time was more than 1 hour and 30 minutes ago require.deb.uptodate_index(max_age={'hour': 1, 'minutes': 30}) """ if system.time() - last_update_time() > _to_seconds(max_age): update_index(quiet=quiet)
def uptodate_index(quiet=True, max_age=86400): """ Update APT package definitions (``apt-get update``) only if specified time since last update already elapsed. Example:: from fabtools import require # do not update in 1 day require.deb.uptodate_index(max_age={'day' : 1}) """ if system.time() - last_update_time() > _simple_time_interval(max_age): update_index(quiet=quiet)
def uptodate_index(quiet=True, max_age=86400): """ Update APT package definitions (``apt-get update``) only if specified time since last update already elapsed. Example:: from fabtools import require # do not update in 1 day require.deb.uptodate_index(max_age={'day': 1}) # do not update in 1 hour and 30 minutes require.deb.uptodate_index(max_age={'hour': 1, 'minutes': 30}) """ if system.time() - last_update_time() > _to_seconds(max_age): update_index(quiet=quiet)