diff --git a/lib/attributes.py b/lib/attributes.py index 221e40f..6d4e317 100644 --- a/lib/attributes.py +++ b/lib/attributes.py @@ -104,14 +104,16 @@ def run(self, project_id, repository_root): attribute.reference.init(cursor) with self.database.cursor() as cursor: + #this line below has a bug. timeout becomes zero from the second attribute timeout = utilities.parse_datetime_delta(attribute.timeout) - process = multiprocessing.Process( target=attribute.run, args=(project_id, repository_path, cursor, outq) ) process.start() - process.join(timeout=timeout.total_seconds()) + #hardcoding timeout as a quick fix + # to a bug in reading the timeout + process.join(timeout=21600) if not outq.empty(): (bresult, rresult) = outq.get() diff --git a/lib/run.py b/lib/run.py index e648a85..97d4fea 100644 --- a/lib/run.py +++ b/lib/run.py @@ -71,14 +71,24 @@ def _save(self, project_id, rresults, table): if len([i for i in _rresults.values() if i is not None]) > 0: updatable = True _rresults.update(rresults) - + # score calculated here has a bug + # it calculates score if the project + # is already there in the reaper_results table + # but in absence gives zero score score = self.attributes.score(_rresults) - self._print_outcome(project_id, score) if self.attributes.is_persistence_enabled: if is_existing is True and updatable is False: return + # calculating score again with new found values + # this will override zero score with actual score + # in prior function call + # for the projects that were not already + # in the reaper_results table + score = self.attributes.score(rresults) + self._print_outcome(project_id, score) + columns = ('project_id', 'score') values = (project_id, score) for key in rresults: @@ -86,7 +96,7 @@ def _save(self, project_id, rresults, table): if rresults[key] is not None: columns += (key,) values += (rresults[key],) - + if is_existing: # Update query = SQL_UPDATE.format( diff --git a/lib/utilities.py b/lib/utilities.py index 18adce4..8034b60 100644 --- a/lib/utilities.py +++ b/lib/utilities.py @@ -226,7 +226,7 @@ def url_to_json(url, headers={}): try: response = urllib.request.urlopen(request) - raw_data = response.readall().decode('utf-8') + raw_data = response.read().decode('utf-8') result = json.loads(raw_data) except Exception as e: # TODO: Properly handle error. For now, just return empty dictionary. diff --git a/requirements.txt b/requirements.txt index 2458682..e7f1e49 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -mysql-connector-python>=2.0.3,<3.0 +https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip#md5=3df394d89300db95163f17c843ef49df Pygments>=2.0.2,<3.0 networkx>=1.9.1,<2.0 APScheduler>=3.0.2,<4.0