diff --git a/atdb/atdb/settings/base.py b/atdb/atdb/settings/base.py index fc212fbe894e98bdaec3511d8669c44fe2fa5cfb..91112c06377fce1835246d92bdd9831c1ff41193 100644 --- a/atdb/atdb/settings/base.py +++ b/atdb/atdb/settings/base.py @@ -156,17 +156,12 @@ LOGGING = { 'class': 'logging.StreamHandler', 'formatter': 'my_formatter', }, - 'my_file_handler': { - 'level': 'INFO', - 'class': 'logging.FileHandler', - 'formatter': 'my_formatter', - 'filename': 'logs/atdb.log' - }, + }, 'loggers': { 'taskdatabase': { #'handlers': ['my_handler','mail_admins'], - 'handlers': ['my_handler', 'my_file_handler'], + 'handlers': ['my_handler'], 'level': 'INFO', }, 'django': { diff --git a/atdb/logs/atdb.log b/atdb/logs/atdb.log deleted file mode 100644 index c47e73e3ebb4a84d419fdd911fc3fa88fe26c51e..0000000000000000000000000000000000000000 --- a/atdb/logs/atdb.log +++ /dev/null @@ -1,72 +0,0 @@ -logging[14/Apr/2023 14:17:24,827] unsupported operand type(s) for +=: 'NoneType' and 'str' -[14/Apr/2023 14:17:24,828] task 25485 - (regular) - 146233 has no plots, skipped. -[14/Apr/2023 14:17:26,041] unsupported operand type(s) for +=: 'NoneType' and 'str' -[14/Apr/2023 14:17:26,042] task 25485 - (regular) - 146233 has no plots, skipped. -[01/May/2023 17:07:12,510] unsupported operand type(s) for &: 'bool' and 'str' -[01/May/2023 17:07:12,512] task 25485 - (regular) - 146233 has no plots, skipped. -[01/May/2023 17:07:17,635] unsupported operand type(s) for &: 'bool' and 'str' -[01/May/2023 17:07:17,635] task 25485 - (regular) - 146233 has no plots, skipped. -[01/May/2023 17:07:28,708] unsupported operand type(s) for &: 'bool' and 'str' -[01/May/2023 17:07:28,709] unsupported operand type(s) for &: 'bool' and 'str' -[01/May/2023 17:07:28,709] unsupported operand type(s) for &: 'bool' and 'str' -[01/May/2023 17:07:28,718] task 25485 - (regular) - 146233 has no plots, skipped. -[01/May/2023 17:07:28,718] task 25485 - (regular) - 146233 has no plots, skipped. -[01/May/2023 17:07:28,718] task 25484 - (regular) - 146232 has no plots, skipped. -[01/May/2023 17:07:29,725] unsupported operand type(s) for &: 'bool' and 'str' -[01/May/2023 17:07:29,725] task 25484 - (regular) - 146232 has no plots, skipped. -[01/May/2023 17:07:30,279] unsupported operand type(s) for &: 'bool' and 'str' -[01/May/2023 17:07:30,279] task 25484 - (regular) - 146232 has no plots, skipped. -[01/May/2023 17:07:30,718] unsupported operand type(s) for &: 'bool' and 'str' -[01/May/2023 17:07:30,718] task 25484 - (regular) - 146232 has no plots, skipped. -[01/May/2023 17:07:47,382] unsupported operand type(s) for &: 'bool' and 'str' -[01/May/2023 17:07:47,382] task 25485 - (regular) - 146233 has no plots, skipped. -[01/May/2023 17:07:48,568] unsupported operand type(s) for &: 'bool' and 'str' -[01/May/2023 17:07:48,569] task 25485 - (regular) - 146233 has no plots, skipped. -[01/May/2023 17:07:12,510] unsupported operand type(s) for &: 'bool' and 'str' -[01/May/2023 17:07:12,512] task 25485 - (regular) - 146233 has no plots, skipped. -[01/May/2023 17:07:17,635] unsupported operand type(s) for &: 'bool' and 'str' -[01/May/2023 17:07:17,635] task 25485 - (regular) - 146233 has no plots, skipped. -[01/May/2023 17:07:28,708] unsupported operand type(s) for &: 'bool' and 'str' -[01/May/2023 17:07:28,709] unsupported operand type(s) for &: 'bool' and 'str' -[01/May/2023 17:07:28,709] unsupported operand type(s) for &: 'bool' and 'str' -[01/May/2023 17:07:28,718] task 25485 - (regular) - 146233 has no plots, skipped. -[01/May/2023 17:07:28,718] task 25485 - (regular) - 146233 has no plots, skipped. -[01/May/2023 17:07:28,718] task 25484 - (regular) - 146232 has no plots, skipped. -[01/May/2023 17:07:29,725] unsupported operand type(s) for &: 'bool' and 'str' -[01/May/2023 17:07:29,725] task 25484 - (regular) - 146232 has no plots, skipped. -[01/May/2023 17:07:30,279] unsupported operand type(s) for &: 'bool' and 'str' -[01/May/2023 17:07:30,279] task 25484 - (regular) - 146232 has no plots, skipped. -[01/May/2023 17:07:30,718] unsupported operand type(s) for &: 'bool' and 'str' -[01/May/2023 17:07:30,718] task 25484 - (regular) - 146232 has no plots, skipped. -[01/May/2023 17:07:47,382] unsupported operand type(s) for &: 'bool' and 'str' -[01/May/2023 17:07:47,382] task 25485 - (regular) - 146233 has no plots, skipped. -[01/May/2023 17:07:48,568] unsupported operand type(s) for &: 'bool' and 'str' -[01/May/2023 17:07:48,569] task 25485 - (regular) - 146233 has no plots, skipped. -[04/May/2023 14:35:18,946] 'NoneType' object is not subscriptable -[04/May/2023 14:35:18,946] task 25378 - (regular) - 116876 has no plots, skipped. -[04/May/2023 14:35:21,861] 'NoneType' object is not subscriptable -[04/May/2023 14:35:21,861] task 25378 - (regular) - 116876 has no plots, skipped. -[04/May/2023 14:35:52,010] 'NoneType' object is not subscriptable -[04/May/2023 14:35:52,010] task 25378 - (regular) - 116876 has no plots, skipped. -[04/May/2023 14:35:52,100] 'NoneType' object is not subscriptable -[04/May/2023 14:35:52,100] task 25378 - (regular) - 116876 has no plots, skipped. -[04/May/2023 14:35:52,193] 'NoneType' object is not subscriptable -[04/May/2023 14:35:52,193] task 25378 - (regular) - 116876 has no plots, skipped. -[04/May/2023 14:35:52,294] 'NoneType' object is not subscriptable -[04/May/2023 14:35:52,294] task 25378 - (regular) - 116876 has no plots, skipped. -[09/May/2023 08:47:20,610] 'NoneType' object is not subscriptable -[09/May/2023 08:47:20,610] task 25378 - (regular) - 116876 has no plots, skipped. -[09/May/2023 08:47:20,725] 'NoneType' object is not subscriptable -[09/May/2023 08:47:20,725] task 25378 - (regular) - 116876 has no plots, skipped. -[09/May/2023 08:47:20,822] 'NoneType' object is not subscriptable -[09/May/2023 08:47:20,823] task 25378 - (regular) - 116876 has no plots, skipped. -[09/May/2023 08:47:20,932] 'NoneType' object is not subscriptable -[09/May/2023 08:47:20,933] task 25378 - (regular) - 116876 has no plots, skipped. -[09/May/2023 08:47:32,444] 'NoneType' object is not subscriptable -[09/May/2023 08:47:32,445] task 25378 - (regular) - 116876 has no plots, skipped. -[09/May/2023 08:47:33,063] 'NoneType' object is not subscriptable -[09/May/2023 08:47:33,064] task 25378 - (regular) - 116876 has no plots, skipped. -[09/May/2023 08:47:33,649] 'NoneType' object is not subscriptable -[09/May/2023 08:47:33,650] task 25378 - (regular) - 116876 has no plots, skipped. -[09/May/2023 08:47:34,165] 'NoneType' object is not subscriptable -[09/May/2023 08:47:34,165] task 25378 - (regular) - 116876 has no plots, skipped. diff --git a/atdb/taskdatabase/services/algorithms.py b/atdb/taskdatabase/services/algorithms.py index 428662350e76a3896c5e69e9bce65db729f88a6b..abdc4326ea22c490a123c00391bd64d806c99049 100644 --- a/atdb/taskdatabase/services/algorithms.py +++ b/atdb/taskdatabase/services/algorithms.py @@ -680,13 +680,42 @@ def unique_values_for_aggregation_key(queryset, aggregation_key): return list(map(lambda x: x[aggregation_key], queryset.values(aggregation_key).distinct())) -def add_plots(task, token, translation, results, expand_image="False"): +def add_plots(task, results, expand_image="False"): # keep a temporary list of filenames to check uniqueness plot_files = [] + # translate the path to a url for the original plots location + try: + srm_to_url = Configuration.objects.get(key='dcache:srm_to_url').value + except: + srm_to_url = "srm://srm.grid.sara.nl/pnfs/grid.sara.nl/data/lofar/ops/disk/ldv/::https://webdav.grid.surfsara.nl/" + + # translate the path to a url for when the plots are moved by the archiver + try: + srm_to_url_archive_disk = Configuration.objects.get(key='dcache:srm_to_url_archive_disk').value + except: + srm_to_url_archive_disk = "srm://srm.grid.sara.nl/pnfs/grid.sara.nl/data/lofar/ops/disk/projects/::https://webdav.grid.surfsara.nl/projects/" + + # retrieve the current tokens for both the original and archived locations + token_original = str(Configuration.objects.get(key='dcache:token').value) + token_archive_disk = str(Configuration.objects.get(key='dcache:token_archive_disk').value) + plots = task.quality_json["plots"] count = 0 + for plot in plots: + # check where the plot lives and provide the translation + try: + # is the plot already moved to its final location on disk in the lta? + base_surl = plot['surl_lta'] + translation = srm_to_url_archive_disk.split("::") + token = token_archive_disk + except: + # assume the orignal location. + base_surl = plot['surl'] + translation = srm_to_url.split("::") + token = token_original + basename = plot['basename'] checksum = plot['checksum'] # plot_file = basename + str(plot['size']) @@ -695,8 +724,7 @@ def add_plots(task, token, translation, results, expand_image="False"): # only add unique files if not plot_file in plot_files: count = count + 1 - surl = plot['surl'] + "?action=show&authz=" + str(token) - + surl = base_surl + "?action=show&authz=" + str(token) url = surl.replace(translation[0], translation[1]) if basename.endswith('png') and expand_image=="True": @@ -737,20 +765,11 @@ def add_plots(task, token, translation, results, expand_image="False"): def construct_inspectionplots(task, expand_image="False", source='task_id'): - # translate the path to a url - try: - srm_to_url = Configuration.objects.get(key='dcache:srm_to_url').value - except: - srm_to_url = "srm://srm.grid.sara.nl/pnfs/grid.sara.nl/data/lofar/ops/disk/ldv/::https://webdav.grid.surfsara.nl/" - - token = str(Configuration.objects.get(key='dcache:token').value) - translation = srm_to_url.split("::") - # find the plots in the quality json structure if source == 'task_id': results = "<h4>Inspection Plots and Summary Logs</h4>" results += "<p>Clicking a link will redirect to SURF SARA in a new browser window. </p>" - results = add_plots(task, token, translation, results, expand_image) + results = add_plots(task, results, expand_image) elif source == 'sas_id': sas_id = task.sas_id @@ -767,7 +786,7 @@ def construct_inspectionplots(task, expand_image="False", source='task_id'): try: results += '<tr style="background-color:#7EB1C4"><td colspan="3"><b>Task ' + str(task.id) + '</b></td></tr>' - results = add_plots(task, token, translation, results, expand_image) + results = add_plots(task, results, expand_image) except Exception as error: logger.error(error) @@ -829,7 +848,7 @@ def construct_summary(task): line += '<tr><td colspan="3">' for filename in added: line += '<tr><td colspan="3">' + filename + '<td></tr>' - except Exception as error: + except: pass try: @@ -838,13 +857,14 @@ def construct_summary(task): line += '<th>Deleted</th>' for filename in deleted: line += '<tr><td colspan="3">' +filename + '<td></tr>' - except Exception as error: + + except: pass results += line - except Exception as error: - logger.error(error) + except: + pass totals += '<th>Totals</th><th></th><th></th>' totals += '<tr><td colspan="2"><b>Input size</b></td><td>' + str(total_size_input) + '</td></tr>' diff --git a/atdb/taskdatabase/templates/taskdatabase/index.html b/atdb/taskdatabase/templates/taskdatabase/index.html index 38abbccf3af932c550035ecc10009419b79ce094..fe379d56a22ba4039202c443c51483e215ce917b 100644 --- a/atdb/taskdatabase/templates/taskdatabase/index.html +++ b/atdb/taskdatabase/templates/taskdatabase/index.html @@ -31,7 +31,7 @@ {% include 'taskdatabase/pagination.html' %} </div> </div> - <p class="footer"> Version 9 May 2023 + <p class="footer"> Version 10 May 2023 </div> {% include 'taskdatabase/refresh.html' %}