44
44
"""
45
45
import concurrent
46
46
import copy
47
+ import functools
47
48
import glob
48
49
import inspect
49
50
import json
128
129
# Directory name in which to store reproducibility files
129
130
REPROD = 'reprod'
130
131
132
+ CHECKSUMS_JSON = 'checksums.json'
133
+
131
134
_log = fancylogger .getLogger ('easyblock' )
132
135
133
136
137
+ def _obtain_file_update_progress_bar_on_return (func ):
138
+ """Decorator for obtain_file() to update the progress bar upon return"""
139
+ @functools .wraps (func )
140
+ def wrapper (* args , ** kwargs ):
141
+ result = func (* args , ** kwargs )
142
+ filename = args [1 ]
143
+
144
+ # We don't account for the checksums file in the progress bar
145
+ if filename != CHECKSUMS_JSON :
146
+ update_progress_bar (PROGRESS_BAR_DOWNLOAD_ALL )
147
+
148
+ return result
149
+ return wrapper
150
+
151
+
134
152
class EasyBlock :
135
153
"""Generic support for building and installing software, base class for actual easyblocks."""
136
154
@@ -452,7 +470,7 @@ def get_checksums_from_json(self, always_read=False):
452
470
:param always_read: always read the checksums.json file, even if it has been read before
453
471
"""
454
472
if always_read or self .json_checksums is None :
455
- path = self .obtain_file ("checksums.json" , no_download = True , warning_only = True )
473
+ path = self .obtain_file (CHECKSUMS_JSON , no_download = True , warning_only = True )
456
474
if path is not None :
457
475
self .log .info ("Loading checksums from file %s" , path )
458
476
json_txt = read_file (path )
@@ -789,6 +807,7 @@ def collect_exts_file_info(self, fetch_files=True, verify_checksums=True):
789
807
790
808
return exts_sources
791
809
810
+ @_obtain_file_update_progress_bar_on_return
792
811
def obtain_file (self , filename , extension = False , urls = None , download_filename = None , force_download = False ,
793
812
git_config = None , no_download = False , download_instructions = None , alt_location = None ,
794
813
warning_only = False ):
@@ -812,8 +831,8 @@ def obtain_file(self, filename, extension=False, urls=None, download_filename=No
812
831
srcpaths = source_paths ()
813
832
814
833
# We don't account for the checksums file in the progress bar
815
- if filename != 'checksum.json' :
816
- update_progress_bar (PROGRESS_BAR_DOWNLOAD_ALL , label = filename )
834
+ if filename != CHECKSUMS_JSON :
835
+ update_progress_bar (PROGRESS_BAR_DOWNLOAD_ALL , progress_size = 0 , label = filename )
817
836
818
837
if alt_location is None :
819
838
location = self .name
@@ -5051,7 +5070,7 @@ def inject_checksums_to_json(ecs, checksum_type):
5051
5070
raise EasyBuildError ("Found existing checksum for %s, use --force to overwrite them" % filename )
5052
5071
5053
5072
# actually write the checksums
5054
- with open (os .path .join (ec_dir , 'checksums.json' ), 'w' ) as outfile :
5073
+ with open (os .path .join (ec_dir , CHECKSUMS_JSON ), 'w' ) as outfile :
5055
5074
json .dump (existing_checksums , outfile , indent = 2 , sort_keys = True )
5056
5075
5057
5076
0 commit comments