@@ -43,33 +43,26 @@ def index_events(project, bucket, debug=False, dry_run=False):
4343 }
4444 )
4545
46- with tempfile .TemporaryFile (mode = "w+" ) as htmlfile , tempfile .TemporaryFile (
47- mode = "w+"
48- ) as jsonlfile :
49- html_index = html_template .render (
50- archives = sorted (
51- archives , key = lambda archive : archive ["date" ], reverse = True
52- ),
53- generated_time = datetime .utcnow ().isoformat () + "Z" ,
54- )
55-
56- if debug :
57- print (html_index )
46+ html_index = html_template .render (
47+ archives = sorted (
48+ archives , key = lambda archive : archive ["date" ], reverse = True
49+ ),
50+ generated_time = datetime .utcnow ().isoformat () + "Z" ,
51+ )
5852
59- htmlfile .write (html_index )
53+ if debug :
54+ print (html_index )
6055
61- for archive in archives :
62- jsonlfile .write (json .dumps (archive ) + "\n " )
6356
64- htmlfile . seek ( 0 )
65- jsonlfile . seek ( 0 )
57+ for archive in archives :
58+ jsonl_index = json . dumps ( archive ) + " \n "
6659
67- if not dry_run :
68- html_blob = bucket .blob ("index.html" )
69- html_blob .upload_from_file ( htmlfile , content_type = "text/html" )
70- print ("Uploaded index.html" )
71- bucket .blob ("index.jsonl" ).upload_from_file ( jsonlfile )
72- print ("Uploaded index.jsonl" )
60+ if not dry_run :
61+ html_blob = bucket .blob ("index.html" )
62+ html_blob .upload_from_string ( html_index , content_type = "text/html" )
63+ print ("Uploaded index.html" )
64+ bucket .blob ("index.jsonl" ).upload_from_string ( jsonl_index )
65+ print ("Uploaded index.jsonl" )
7366
7467 # Upload static assets
7568 for static_file in STATIC_FILES :
0 commit comments