-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
11 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() | ||
|
@@ -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.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
kudkudak
Author
Member
|
||
self._export_stats_to(self.export_stats_to) | ||
|
||
def _export_stats_to(self, file_name): | ||
|
@@ -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: | ||
|
@@ -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.
Sorry, something went wrong. |
||
except IOError as e: | ||
print e | ||
pass | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I don't really understand a point of added condition.