Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr38 committed Jul 16, 2024
1 parent 208895b commit 69af09f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
20 changes: 10 additions & 10 deletions linupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@ def main():
exit_code = 0

try:
# Instanciate classes
my_exit = Exit()
my_app = App()
my_app_config = Config()
my_args = Args()
my_system = System()
my_module = Module()
my_package = Package()
my_service = Service()

# Get current date and time
todaydatetime = datetime.now()
date = todaydatetime.strftime('%Y-%m-%d')
Expand All @@ -49,6 +39,16 @@ def main():
Path(logsdir).mkdir(parents=True, exist_ok=True)
Path(logsdir).chmod(0o750)

# Instanciate classes
my_exit = Exit()
my_app = App()
my_app_config = Config()
my_args = Args()
my_system = System()
my_module = Module()
my_package = Package()
my_service = Service()

# Pre-parse arguments to check if --from-agent param is passed
my_args.preParse()

Expand Down
3 changes: 3 additions & 0 deletions src/controllers/App/App.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def setLock(self):
#
#-------------------------------------------------------------------------------------------------------------------
def removeLock(self):
if not Path('/tmp/linupdate.lock').is_file():
return

try:
Path('/tmp/linupdate.lock').unlink()
except Exception as e:
Expand Down
12 changes: 9 additions & 3 deletions src/controllers/Exit.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@ def cleanExit(self, exit_code = 0, send_mail: bool = True, logfile: str = None):
my_config = Config()
my_mail = Mail()

# Get mail settings
mail_enabled = my_config.getMailEnabled()
mail_recipient = my_config.getMailRecipient()
# Try to get mail settings
# It could fail if the config file is not found or if the mail section is not defined (e.g. first execution)
try:
mail_enabled = my_config.getMailEnabled()
mail_recipient = my_config.getMailRecipient()
except Exception as e:
send_mail = False
mail_enabled = False
mail_recipient = None

# Send mail unless send_mail is False (in some case mail is not needed, like when exiting at update confirmation)
if send_mail is True:
Expand Down

0 comments on commit 69af09f

Please sign in to comment.