MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / VersionCheckState

Class VersionCheckState

src/scancode/outdated.py:84–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82
83
84class VersionCheckState:
85
86 def __init__(self):
87 self.statefile_path = os.path.join(
88 scancode_cache_dir, 'scancode-version-check.json')
89 self.lockfile_path = self.statefile_path + '.lockfile'
90 # Load the existing state
91 try:
92 with open(self.statefile_path) as statefile:
93 self.state = json.load(statefile)
94 except (IOError, ValueError, KeyError):
95 self.state = {}
96
97 def save(self, latest_version, current_time):
98 # Attempt to write out our version check file
99 with lockfile.FileLock(self.lockfile_path).locked(timeout=10):
100 state = {
101 'last_check': current_time.strftime(SELFCHECK_DATE_FMT),
102 'latest_version': latest_version,
103 }
104 with open(self.statefile_path, 'w') as statefile:
105 json.dump(state, statefile, sort_keys=True,
106 separators=(',', ':'))
107
108
109def build_outdated_message(installed_version, release_date, newer_version=''):

Callers 1

fetch_newer_versionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected