Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
16 changes: 13 additions & 3 deletions lib/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,32 @@ 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:
if self.attributes.get(key).persist:
if rresults[key] is not None:
columns += (key,)
values += (rresults[key],)

if is_existing:
# Update
query = SQL_UPDATE.format(
Expand Down
2 changes: 1 addition & 1 deletion lib/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down