def has_stale_manifest(self): if self._manifest is None: logger(__name__).debug( 'Upgrade manager\'s manifest is nonexistent') if datetime.now() - self._last_check > cli_config().update_frequency: logger(__name__).debug( f'Upgrade manager\'s last check occured at {self._last_check}.' ) logger(__name__).debug( f'Was longer ago than update frequency ({cli_config().update_frequency}) allows.' ) return (self._manifest is None) or (datetime.now() - self._last_check > cli_config().update_frequency)
def compile(self, build_args: List[str], scan_build: Optional[bool] = None): if scan_build is None: from pros.config.cli_config import cli_config scan_build = cli_config().use_build_compile_commands return self.make_scan_build(build_args) if scan_build else self.make( build_args)
def __init__(self, file=None): if file is None: file = os.path.join(cli_config().directory, 'upgrade.pros.json') self._last_check: datetime = datetime.min self._manifest: Optional[UpgradeManifestV1] = None self.release_channel: ReleaseChannel = ReleaseChannel.Stable super().__init__(file)
def get_remote_templates(self, auto_check_freq: Optional[timedelta] = None, force_check: bool = False, **kwargs): if auto_check_freq is None: auto_check_freq = getattr(self, 'update_frequency', cli_config().update_frequency) logger(__name__).info( f'Last check of {self.name} was {self.last_remote_update} ' f'({datetime.now() - self.last_remote_update} vs {auto_check_freq}).' ) if force_check or datetime.now( ) - self.last_remote_update > auto_check_freq: with ui.Notification(): ui.echo(f'Updating {self.name}... ', nl=False) self.update_remote_templates(**kwargs) ui.echo('Done', color='green') for t in self.remote_templates: t.metadata['origin'] = self.name return self.remote_templates