scripts/mycroft/version/__init__.py
Go to the documentation of this file.
1 # Copyright 2017 Mycroft AI Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 #
15 import json
16 
17 from genericpath import exists, isfile
18 from os.path import join, expanduser
19 
20 from mycroft.configuration import Configuration
21 from mycroft.util.log import LOG
22 
23 
24 # The following lines are replaced during the release process.
25 # START_VERSION_BLOCK
26 CORE_VERSION_MAJOR = 19
27 CORE_VERSION_MINOR = 2
28 CORE_VERSION_BUILD = 12
29 # END_VERSION_BLOCK
30 
31 CORE_VERSION_TUPLE = (CORE_VERSION_MAJOR,
32  CORE_VERSION_MINOR,
33  CORE_VERSION_BUILD)
34 CORE_VERSION_STR = '.'.join(map(str, CORE_VERSION_TUPLE))
35 
36 
38  @staticmethod
39  def get():
40  data_dir = expanduser(Configuration.get()['data_dir'])
41  version_file = join(data_dir, 'version.json')
42  if exists(version_file) and isfile(version_file):
43  try:
44  with open(version_file) as f:
45  return json.load(f)
46  except Exception:
47  LOG.error("Failed to load version from '%s'" % version_file)
48  return {"coreVersion": None, "enclosureVersion": None}
49 
50 
51 def check_version(version_string):
52  """
53  Check if current version is equal or higher than the
54  version string provided to the function
55 
56  Args:
57  version_string (string): version string ('Major.Minor.Build')
58  """
59  version_tuple = tuple(map(int, version_string.split('.')))
60  return CORE_VERSION_TUPLE >= version_tuple
def check_version(version_string)


mycroft_ros
Author(s):
autogenerated on Mon Apr 26 2021 02:35:40