|
1
|
|
|
# useful methods to measure time performance by small pieces of code |
|
2
|
|
|
from codetiming import Timer |
|
3
|
|
|
# Custom package specific to this project |
|
4
|
|
|
from db_extractor.BasicNeeds import BasicNeeds |
|
5
|
|
|
from db_extractor.LoggingNeeds import LoggingNeeds |
|
6
|
|
|
from db_extractor.FileOperations import datetime, os, FileOperations |
|
7
|
|
|
from db_extractor.ParameterHandling import ParameterHandling |
|
8
|
|
|
# get current script name |
|
9
|
|
|
CURRENT_SCRIPT_NAME = os.path.basename(__file__).replace('.py', '') |
|
10
|
|
|
SCRIPT_LANGUAGE = 'ro_RO' |
|
11
|
|
|
REFERENCE_EXPRESION = 'CalculatedDate_CYCMCDCH_-48' |
|
12
|
|
|
|
|
13
|
|
|
# instantiate Logger class |
|
14
|
|
|
c_ln = LoggingNeeds() |
|
15
|
|
|
# initiate logger |
|
16
|
|
|
c_ln.initiate_logger(CURRENT_SCRIPT_NAME + '.log', CURRENT_SCRIPT_NAME) |
|
17
|
|
|
# instantiate File Operations class |
|
18
|
|
|
c_fo = FileOperations(SCRIPT_LANGUAGE) |
|
19
|
|
|
# instantiate File Operations class |
|
20
|
|
|
c_ph = ParameterHandling(SCRIPT_LANGUAGE) |
|
21
|
|
|
older_to_newer_barrier = c_ph.eval_expression(c_ln.logger, REFERENCE_EXPRESION, 1) |
|
22
|
|
|
barrier = datetime.strptime(older_to_newer_barrier, c_ph.output_standard_formats.get('hour')) |
|
23
|
|
|
print('Older to Newer barrier is ' + str(barrier)) |
|
24
|
|
|
# define global timer to use |
|
25
|
|
|
t = Timer(CURRENT_SCRIPT_NAME, text = 'Time spent is {seconds}', logger = c_ln.logger.debug) |
|
26
|
|
|
# pick all JSON files from this folder |
|
27
|
|
|
relevant_files = c_fo.fn_build_relevant_file_list(c_ln.logger, t, |
|
28
|
|
|
os.path.dirname(__file__), '*.json') |
|
29
|
|
|
for current_file in relevant_files: |
|
30
|
|
|
current_file_modified_datetime = datetime.fromtimestamp(os.path.getmtime(current_file)) |
|
31
|
|
|
file_verdict = c_fo.fn_get_file_datetime_verdict(c_ln.logger, current_file, |
|
32
|
|
|
'last modified', barrier) |
|
33
|
|
|
print(current_file + ' => ' + str(current_file_modified_datetime) |
|
34
|
|
|
+ ' vs. ' + str(barrier) + ' => ' + file_verdict) |
|
35
|
|
|
# instantiate Basic Needs class |
|
36
|
|
|
c_bn = BasicNeeds(SCRIPT_LANGUAGE) |
|
37
|
|
|
# just final message |
|
38
|
|
|
c_bn.fn_final_message(c_ln.logger, CURRENT_SCRIPT_NAME + '.log', |
|
39
|
|
|
t.timers.total(CURRENT_SCRIPT_NAME)) |
|
40
|
|
|
|