def get_foreman_version(self):
home_page = requests.get(<EOL>self.url,<EOL>timeout=self.get_timeout('<STR_LIT:GET>'),<EOL>**self._req_params<EOL>)<EOL>match = re.search(<EOL>r'<STR_LIT>',<EOL>home_page.text,<EOL>)<EOL>if match:<EOL><INDENT>return match.groupdict()['<STR_LIT:version>']<EOL><DEDENT>else:<EOL><INDENT>res = self.session.get(<EOL>self.url + '<STR_LIT>',<EOL>timeout=self.get_timeout('<STR_LIT:GET>'),<EOL>**self._req_params<EOL>)<EOL>if res.status_code < <NUM_LIT:200> or res.status_code >= <NUM_LIT>:<EOL><INDENT>raise ForemanException(<EOL>res,<EOL>'<STR_LIT>' % res_to_str(res)<EOL>)<EOL><DEDENT>res = res.json()<EOL>if '<STR_LIT:version>' in res:<EOL><INDENT>return res['<STR_LIT:version>']<EOL><DEDENT>else:<EOL><INDENT>raise ForemanVersionException('<STR_LIT>')<EOL><DEDENT><DEDENT>
Even if we have an api method that returns the foreman version, we need
the version first to know its path, so instead of that we get the
main page and extract the version from the footer.