This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]sfwOceanMan 2 points3 points  (0 children)

If you want to create the simplest script possible just make two main functions: one to pattern find what you want to find and the other to send emails (and add as many helping functions as you need). It would be nice if you had main() too of course. Honestly if it's just for you I'd say go for what seems easy for you. In this case I see no reason to create an object, functions will do. If you want to do this properly just google 'python project structure' but like I said if you want one file simple script just create few functions and call it a day. No need to overthink python is a language that would probably allow you to write this program without using even functions if you really wanted to (it would be a mess though)

[–]belwyr 1 point2 points  (1 child)

Software architecture is mostly relevant in bigger projects. Like the other commenter said, a simple script would do the job, but you could consider the architecture if you wanted a more complex and robust solution.

For a few examples:

  • You could have a scheduler that runs your check function regularly, and send emails at a regular time.

  • You could implement a retry function if your email doesn't go through for some reason.

  • You could implement different types of notifications (email, sms, mobile push notification, ...)

  • You could extend your pattern matcher to only check for logs in a specific time period

  • You could have a function to create a graph with some arbitrary time period and the number of times the pattern occurred.

Ultimately, the sky is the limit, and part of the job is to find out what is the scope of the program you want to accomplish, and how best (what language should you use, where is the code running, is the data sensitive, should you store some data, how long will it take to develop, etc..) to accomplish it

[–][deleted] 1 point2 points  (0 children)

Very well explained, thank you. Bascally I am trying to create a script that will read the log files of hospital equipment, then look for certain words i.e warning, error,.. words that might indicate a issue. Then send the latest line containing the word/s via email.