Skip to content

Commit

Permalink
Passing 1000 test, #146
Browse files Browse the repository at this point in the history
  • Loading branch information
kudkudak committed May 14, 2014
1 parent 118f63e commit a948957
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions graph_workers/spidercrab.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ def __init__(
@param master: master Spidercrab object
@type master: Spidercrab
"""

# Clean logs. TODO: do not use unix command
os.system("rm "+self.STANDARD_STATS_EXPORT_FILE)

self.logger = logger
# Config used to be stored inside the database (only values from file)
self.given_config = dict()
Expand Down Expand Up @@ -279,7 +283,7 @@ def _end_run(self):
info_level,
self.fullname + ' Finished!\nStats:\n' + str(self.stats))
self._export_stats_to(self.STANDARD_STATS_EXPORT_FILE)
if not self.export_stats_to is None:
if not self.export_stats_to is None and self.export_stats_to != self.STANDARD_STATS_EXPORT_FILE:

This comment has been minimized.

Copy link
@ktalik

ktalik May 18, 2014

Member

I don't really understand a point of added condition.

This comment has been minimized.

Copy link
@kudkudak

kudkudak May 18, 2014

Author Member

I was trying out things when debugging spidercrab and left it by mistake

This comment has been minimized.

Copy link
@ktalik

ktalik May 18, 2014

Member

So I assume it is safe to reset this line to the previous version.

self._export_stats_to(self.export_stats_to)

def _export_stats_to(self, file_name):
Expand All @@ -288,12 +292,14 @@ def _export_stats_to(self, file_name):
'runtime_id': self.runtime_id,
'stats': self.stats
}
data = None
if not os.path.isfile(file_name):
with open(file_name, 'w') as json_file:
json_file.write(json.dumps({}))
try:
with open(file_name, 'r') as json_file:
data = json.load(json_file)
with open(file_name, 'r') as json_file:
x= json_file.read()
data = json.loads(x)
try:
graph_worker_id = self.config[self.C_GRAPH_WORKER_ID]
if graph_worker_id not in data:
Expand All @@ -303,7 +309,7 @@ def _export_stats_to(self, file_name):
data[graph_worker_id][self.level].append(json_export)
finally:
with open(file_name, 'w') as json_file:
json_file.write(json.dumps(data, indent=4, sort_keys=True))
json_file.write(json.dumps(data))

This comment has been minimized.

Copy link
@ktalik

ktalik May 18, 2014

Member

Does formatting generate some issues?

except IOError as e:
print e
pass
Expand Down
2 changes: 1 addition & 1 deletion tests/spidercrab_1000_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def run_slave():
]

NUMBER_OF_SLAVES = 10
NEWS_TO_BE_FETCHED = 25 # for each slave
NEWS_TO_BE_FETCHED = 50 # for each slave

print 'Running', __file__
print '\nNOTE: You need following file to run this test ' \
Expand Down

0 comments on commit a948957

Please sign in to comment.