@@ -43,19 +43,27 @@ def __init__(self, process_run, filename, location=None, location_name=None, loc
4343 self .filename = filename
4444
4545 if location is not None :
46+ self .logger .info ('Location object provided.' )
4647 self .location = location
4748 elif location_path is not None :
49+ self .logger .info ('Location path provided. Creating Location object.' )
4850 self .location = LocationTracker (location_name = location_name , location_path = location_path )
4951 else :
5052 raise Exception ('A location object or location_path must be provided.' )
5153
54+ self .logger .info ('Registering extract.' )
55+
5256 self .extract = self .data_store .get_or_create_item (model = Extract
5357 , extract_filename = filename
5458 , extract_location_id = self .location .location .location_id )
5559
5660 if location_path is not None :
61+ self .logger .info ('Location path was provided so building file path from it.' )
62+
5763 self .full_filename = join (location_path , filename )
5864 else :
65+ self .logger .info ('Location provided so building file path from it.' )
66+
5967 self .full_filename = join (self .location .location_path , self .extract .extract_filename )
6068
6169 # Getting all status types in the event there are custom status types added later.
@@ -74,8 +82,10 @@ def __init__(self, process_run, filename, location=None, location_name=None, loc
7482 self .extract_process = self .retrieve_extract_process ()
7583
7684 if status is not None :
85+ self .logger .info ('Status was provided by user.' )
7786 self .change_extract_status (new_status = status )
7887 else :
88+ self .logger .info ('Status was not provided. Initializing.' )
7989 self .extract .extract_status_id = self .extract_status_initializing
8090
8191 self .session .commit ()
@@ -85,7 +95,6 @@ def change_extract_status(self, new_status):
8595 Change an extract record status.
8696 :return:
8797 """
88-
8998 status_date = datetime .now ()
9099 if new_status in self .extract_status_types :
91100 self .logger .info ('Setting extract status to %s' % new_status )
@@ -100,6 +109,7 @@ def change_extract_status(self, new_status):
100109 self .session .commit ()
101110
102111 else :
112+ self .logger .error ('%s is not a valid extract status type.' % new_status )
103113 raise Exception ('%s is not a valid extract status type. '
104114 'Please add the status to extract_status_lkup' % new_status )
105115
@@ -108,7 +118,9 @@ def get_extract_status_types(self):
108118 Get list of process status types and return dictionary.
109119 :return:
110120 """
111- status_types = {}
121+ self .logger .info ('Obtaining extract status types.' )
122+
123+ status_types = dict ()
112124
113125 for record in self .session .query (ExtractStatus ):
114126 status_types [record .extract_status_name ] = record .extract_status_id
@@ -121,14 +133,16 @@ def retrieve_extract_process(self):
121133 :return:
122134 """
123135
136+ self .logger .info ('Associating extract to given process.' )
137+
124138 extract_process = self .data_store .get_or_create_item (model = ExtractProcess
125139 , extract_tracking_id = self .extract .extract_id
126140 , process_tracking_id = self .process_run .process_tracking_run
127141 .process_tracking_id )
128142
129143 # Only need to set to 'initializing' when it's the first time a process run is trying to work with files.
130144 if extract_process .extract_process_status_id is None :
131-
145+ self . logger . info ( 'Extract process status must also be set. Initializing.' )
132146 extract_process .extract_process_status_id = self .extract_status_initializing
133147 self .session .commit ()
134148
0 commit comments