@@ -554,11 +554,7 @@ def execute(args):
554
554
func = _retrieve_user_days ,
555
555
args = (file_registry ['local_aoi_path' ],
556
556
file_registry ['compressed_aoi_path' ],
557
- args ['start_year' ], args ['end_year' ],
558
- os .path .basename (file_registry ['pud_results_path' ]),
559
- os .path .basename (file_registry ['tud_results_path' ]),
560
- os .path .basename (file_registry ['pud_monthly_table_path' ]),
561
- os .path .basename (file_registry ['tud_monthly_table_path' ]),
557
+ args ['start_year' ], args ['end_year' ],file_suffix ,
562
558
output_dir , server_url , file_registry ['server_version' ]),
563
559
target_path_list = [file_registry ['compressed_aoi_path' ],
564
560
file_registry ['pud_results_path' ],
@@ -650,9 +646,7 @@ def _copy_aoi_no_grid(source_aoi_path, dest_aoi_path):
650
646
651
647
def _retrieve_user_days (
652
648
local_aoi_path , compressed_aoi_path , start_year , end_year ,
653
- pud_results_filename , tud_results_filename ,
654
- pud_monthly_table_filename , tud_monthly_table_filename ,
655
- output_dir , server_url , server_version_pickle ):
649
+ file_suffix , output_dir , server_url , server_version_pickle ):
656
650
"""Calculate photo-user-days (PUD) on the server and send back results.
657
651
658
652
All of the client-server communication happens in this scope. The local AOI
@@ -664,10 +658,7 @@ def _retrieve_user_days(
664
658
compressed_aoi_path (string): path to zip file storing compressed AOI
665
659
start_year (int/string): lower limit of date-range for PUD queries
666
660
end_year (int/string): upper limit of date-range for PUD queries
667
- pud_results_filename (string): filename for a vector with PUD results
668
- tud_results_filename (string): filename for a vector with TUD results
669
- pud_monthly_table_filename (string): filename for monthly PUD results CSV
670
- tud_monthly_table_filename (string): filename for monthly TUD results CSV
661
+ file_suffix (string): to append to filenames of files created by server
671
662
output_dir (string): path to output workspace where results are
672
663
unpacked.
673
664
server_url (string): URL for connecting to the server
@@ -761,27 +752,13 @@ def _retrieve_user_days(
761
752
temporary_output_dir )
762
753
763
754
for filename in os .listdir (temporary_output_dir ):
764
- shutil .copy (os .path .join (temporary_output_dir , filename ), output_dir )
755
+ # Results are returned from the server without a results_suffix.
756
+ pre , post = os .path .splitext (filename )
757
+ shutil .copy (
758
+ os .path .join (temporary_output_dir , filename ),
759
+ os .path .join (output_dir , f'{ pre } { file_suffix } { post } ' ))
765
760
shutil .rmtree (temporary_output_dir )
766
761
767
- # Results are returned from the server without a results_suffix.
768
- if dataset == 'flickr' :
769
- renamed_table = pud_monthly_table_filename
770
- renamed_vector = pud_results_filename
771
- else :
772
- renamed_table = tud_monthly_table_filename
773
- renamed_vector = tud_results_filename
774
- shutil .move (
775
- os .path .join (output_dir , f'{ acronym_lookup [dataset ]} _monthly_table.csv' ),
776
- os .path .join (output_dir , renamed_table ))
777
- driver = gdal .GetDriverByName ('ESRI Shapefile' )
778
- source_path = os .path .join (
779
- output_dir , f'{ acronym_lookup [dataset ]} _results.shp' )
780
- source = gdal .OpenEx (source_path , gdal .OF_VECTOR )
781
- driver .CreateCopy (
782
- os .path .join (output_dir , renamed_vector ), source )
783
- driver .Delete (source_path )
784
-
785
762
LOGGER .info ('connection release' )
786
763
recmodel_manager ._pyroRelease ()
787
764
0 commit comments