From 8cfa88d20feca2b9ea6547e461d03d27906793d2 Mon Sep 17 00:00:00 2001 From: nasif Date: Wed, 4 Jul 2018 13:11:42 -0400 Subject: [PATCH 1/5] updating readme file to fix download for myswl-connector-python-2.0.4 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 45dfee55bc5dcaadf791842800c2c8c5fd553cfd Mon Sep 17 00:00:00 2001 From: nasif Date: Wed, 4 Jul 2018 13:15:48 -0400 Subject: [PATCH 2/5] replacing deprecated method for html response --- lib/utilities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From 196647c7222cb62041b7a324a8ab475039808be4 Mon Sep 17 00:00:00 2001 From: nasif Date: Thu, 5 Jul 2018 23:19:28 -0400 Subject: [PATCH 3/5] quick fix for timeout bug --- lib/attributes.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/attributes.py b/lib/attributes.py index 221e40f..cd766a2 100644 --- a/lib/attributes.py +++ b/lib/attributes.py @@ -104,14 +104,15 @@ 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 timeout + process.join(timeout=21600) if not outq.empty(): (bresult, rresult) = outq.get() @@ -144,7 +145,6 @@ def get(self, name): def score(self, rresults): score = 0 - for (attribute, rresult) in rresults.items(): attribute = self.get(attribute) From ecc7f3756c498ea34c68cba871a0dd636a634de0 Mon Sep 17 00:00:00 2001 From: nasif Date: Thu, 5 Jul 2018 23:57:23 -0400 Subject: [PATCH 4/5] fixing bug in score. it was assigning a zero score if there was no existing info about the project in reaper_results. so calculating score again at a later point with the new found values of the attributes --- lib/attributes.py | 3 ++- lib/run.py | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/attributes.py b/lib/attributes.py index cd766a2..79be2d9 100644 --- a/lib/attributes.py +++ b/lib/attributes.py @@ -111,7 +111,7 @@ def run(self, project_id, repository_root): args=(project_id, repository_path, cursor, outq) ) process.start() - #hardcoding timeout as a quick fix to a bug in reading timeout + #hardcoding timeout as a quick fix to a bug in reading process.join(timeout=21600) if not outq.empty(): @@ -145,6 +145,7 @@ def get(self, name): def score(self, rresults): score = 0 + for (attribute, rresult) in rresults.items(): attribute = self.get(attribute) 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( From b1b3c22d74cecad1b9a6707518645a893d44b8f3 Mon Sep 17 00:00:00 2001 From: nasif Date: Fri, 6 Jul 2018 00:05:30 -0400 Subject: [PATCH 5/5] fix comment --- lib/attributes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/attributes.py b/lib/attributes.py index 79be2d9..6d4e317 100644 --- a/lib/attributes.py +++ b/lib/attributes.py @@ -111,7 +111,8 @@ def run(self, project_id, repository_root): args=(project_id, repository_path, cursor, outq) ) process.start() - #hardcoding timeout as a quick fix to a bug in reading + #hardcoding timeout as a quick fix + # to a bug in reading the timeout process.join(timeout=21600) if not outq.empty():