File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed
Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 88from singularity .logman import bot
99
1010from singularity .utils import (
11+ calculate_folder_size ,
1112 format_container_name ,
1213 read_file ,
1314 zip_up
Original file line number Diff line number Diff line change @@ -62,5 +62,6 @@ def test_packaging(self):
6262 self .assertTrue (os .path .exists (image1_extraction ))
6363 shutil .rmtree (os .path .dirname (image1_extraction ))
6464
65+
6566if __name__ == '__main__' :
6667 unittest .main ()
Original file line number Diff line number Diff line change @@ -229,6 +229,24 @@ def read_file(filename,mode="r"):
229229 return content
230230
231231
232+ ############################################################################
233+ ## OTHER MISC. #############################################################
234+ ############################################################################
235+
236+
237+ def calculate_folder_size (folder_path ):
238+ '''calculate_folder size recursively walks a directory to calculate
239+ a total size (in)
240+ :param folder_path: the path to calculate size for
241+ '''
242+ total_size = 0
243+ for dirpath , dirnames , filenames in os .walk (folder_path ):
244+ for filey in filenames :
245+ fp = os .path .join (dirpath , filey )
246+ total_size += os .path .getsize (fp )
247+ return total_size
248+
249+
232250def remove_unicode_dict (input_dict ):
233251 '''remove unicode keys and values from dict, encoding in utf8
234252 '''
You can’t perform that action at this time.
0 commit comments