示例#1
0
 def detect_version_str(self):
     """
     Detect which version by scanning the README for the latest release
     """
     cmd_path = run_matlab_cmd("which('{}')".format(self.test_func))
     pkg_root = op.join(op.dirname(cmd_path), '..')
     readmes = [f for f in os.listdir(pkg_root) if 'readme' in f.lower()]
     if not readmes:
         raise ArcanaVersionNotDetectableError(
             "Did not find a README in STI package root ({})".format(
                 pkg_root))
     elif len(readmes) > 1:
         raise ArcanaVersionNotDetectableError(
             "Found multiple READMEs in STI package root ({})".format(
                 pkg_root))
     readme_path = op.join(pkg_root, readmes[0])
     with open(readme_path, 'rb') as f:
         contents = f.read()
     # Cut out citations text as there can be non-decodable characters in
     # there
     contents = contents.split(b'TERMS OF USE')[0]
     if PY3:
         contents = contents.decode('utf-8')
     # Get dummy version so we can use its 'regex' property
     dummy_version_obj = self.version_cls(self, 1)
     versions = dummy_version_obj.regex.findall(contents)
     latest_version = sorted(versions)[-1]
     return latest_version
示例#2
0
文件: matlab.py 项目: MonashBI/arcana
 def detect_version_str(self):
     """
     Finds the version of Matlab requirement that is accessible in
     the current environment.
     """
     # The matlab version should be included in the opening splash
     return run_matlab_cmd("version('-release')")
示例#3
0
 def detect_version_str(self):
     """
     Try to detect version of package from command help text. Bit of a long
     shot as they are typically included
     """
     help_text = run_matlab_cmd("help('{}')".format(self.test_func))
     if not help_text:
         raise ArcanaRequirementNotFoundError(
             "Did not find test function '{}' for {}".format(
                 self.test_func, self))
     return self.parse_help_text(help_text)
示例#4
0
文件: matlab.py 项目: MonashBI/arcana
 def detect_version_str(self):
     """
     Try to detect version of package from command help text. Bit of a long
     shot as they are typically included
     """
     try:
         help_text = run_matlab_cmd("help('{}')".format(self.test_func))
     except IOError as e:
         if str(e).startswith('No command "matlab"'):
             raise ArcanaVersionNotDetectableError(
                 "Could not detect version of MatlabRequirement '{}' as "
                 "matlab was not found in the environment (or was not "
                 "loaded)".format(self.name))
     if not help_text:
         raise ArcanaRequirementNotFoundError(
             "Did not find test function '{}' for {}".format(
                 self.test_func, self))
     return self.parse_help_text(help_text)