MCPcopy
hub / github.com/freedomofpress/dangerzone / should_check_for_updates

Function should_check_for_updates

dangerzone/updater/releases.py:138–174  ·  view source on GitHub ↗

Determine if we can check for release updates based on settings and user prefs. Note that this method only checks if the user has expressed an interest for learning about new updates, and not whether we should actually make an update check. Those two things are distinct, actually. For e

(settings: Settings)

Source from the content-addressed store, hash-verified

136
137
138def should_check_for_updates(settings: Settings) -> bool:
139 """Determine if we can check for release updates based on settings and user prefs.
140
141 Note that this method only checks if the user has expressed an interest for
142 learning about new updates, and not whether we should actually make an update
143 check. Those two things are distinct, actually. For example:
144
145 * A user may have expressed that they want to learn about new updates.
146 * A previous update check may have found out that there's a new version out.
147 * Thus we will always show to the user the cached info about the new version,
148 and won't make a new update check.
149 """
150 check = settings.get("updater_check_all")
151
152 if settings.get("updater_last_check") is None:
153 log.debug("Dangerzone is running for the first time, updates are stalled")
154 settings.set("updater_last_check", 0, autosave=True)
155 # If no container is bundled and none is installed, prompt the user
156 # to enable updates immediately, otherwise Dangerzone won't work.
157 if not is_container_tar_bundled() and not is_container_image_installed():
158 log.debug("No container available, prompting user to enable updates")
159 raise errors.NeedUserInputNoContainer()
160 return False
161
162 if check is False or check is None:
163 if check is None:
164 log.debug("User has not been asked yet for update checks")
165
166 if not is_container_tar_bundled() and not is_container_image_installed():
167 log.debug("No container available, prompting user to enable updates")
168 raise errors.NeedUserInputNoContainer()
169 raise errors.NeedUserInput()
170 elif not check:
171 log.debug("User has expressed that they don't want to check for updates")
172 return False
173
174 return True
175
176
177def check_for_updates(

Callers

nothing calls this directly

Calls 4

is_container_tar_bundledFunction · 0.85
getMethod · 0.80
setMethod · 0.80

Tested by

no test coverage detected