Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions check_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/python3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vyskocilpavel We need to decide the final version of the sync output and how the probe should respond.

import sys
import datetime

# Replace with correct path
FILE_PATH = 'testdir/test.csv'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to change it? Does it have to be hardcoded in this script?
I would prefer reading some environment variable, or reading a special config file, consuming a request parameter or something similar.


current_time = datetime.datetime.now()

# Replace with correct time limit
time_limit = datetime.timedelta(hours=2, minutes=30)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, how the parameter will be passed?


with open(FILE_PATH) as f:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should mention the expected format of the file contents.

next(f)
line = f.readline().split(';')
status = line[0]
timestamp = datetime.datetime.strptime(line[1], "%Y-%m-%d %H:%M:%S")
actual_difference = current_time - timestamp

if status.upper() == "OK":
if actual_difference <= time_limit:
print("Files imported successfully")
sys.exit(0)
else:
print("Files imported, but not within the time limit")
sys.exit(1)

print("Problem with importing files")
sys.exit(1)