@@ -86,11 +86,11 @@ def run(self):
8686 raise Exception (msg )
8787
8888 # if there are no transactions in response, there will be no merchant id.
89- if self .merchant_id not in response .content and not self .is_empty_transaction_allowed :
89+ if self .merchant_id . encode ( 'utf8' ) not in response .content and not self .is_empty_transaction_allowed :
9090 raise Exception ('No transactions to process.' )
9191
9292 with self .output ().open ('w' ) as output_file :
93- output_file .write (response .content )
93+ output_file .write (response .content . decode ( 'utf8' ) )
9494
9595 def output (self ):
9696 """Output is in the form {output_root}/cybersource/{CCYY-mm}/cybersource_{merchant}_{CCYYmmdd}.csv"""
@@ -230,10 +230,12 @@ def __init__(self, *args, **kwargs):
230230 path_targets = PathSetTask ([path ], include = [file_pattern ], include_zero_length = True ).output ()
231231 paths = list (set ([os .path .dirname (target .path ) for target in path_targets ]))
232232 dates = [path .rsplit ('/' , 2 )[- 1 ] for path in paths ]
233- latest_date = sorted (dates )[- 1 ]
234-
235- latest_completion_date = datetime .datetime .strptime (latest_date , "dt=%Y-%m-%d" ).date ()
236- run_date = latest_completion_date + datetime .timedelta (days = 1 )
233+ if dates :
234+ latest_date = sorted (dates )[- 1 ]
235+ latest_completion_date = datetime .datetime .strptime (latest_date , "dt=%Y-%m-%d" ).date ()
236+ run_date = latest_completion_date + datetime .timedelta (days = 1 )
237+ else :
238+ run_date = self .interval_start
237239
238240 # Limit intervals to merchant account close date(if any).
239241 if self .merchant_close_date :
0 commit comments