Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr38 committed Oct 25, 2024
1 parent 63a1418 commit 5c4f5b5
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/build-and-test-deb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ jobs:
- name: "Run test: set mail recipient"
run: python3 /opt/linupdate/linupdate.py --set-mail-recipient [email protected],[email protected]

- name: "Run test: set mail smtp host"
run: python3 /opt/linupdate/linupdate.py --set-mail-smtp-host localhost

- name: "Run test: get mail smtp host"
run: python3 /opt/linupdate/linupdate.py --get-mail-smtp-host

- name: "Run test: set mail smtp port"
run: python3 /opt/linupdate/linupdate.py --set-mail-smtp-port 25

- name: "Run test: get mail smtp port"
run: python3 /opt/linupdate/linupdate.py --get-mail-smtp-port

- name: "Run test: set package exclusions"
run: python3 /opt/linupdate/linupdate.py --exclude "kernel.*"

Expand Down Expand Up @@ -237,6 +249,18 @@ jobs:
- name: "Run test: set mail recipient"
run: python3 /opt/linupdate/linupdate.py --set-mail-recipient [email protected],[email protected]

- name: "Run test: set mail smtp host"
run: python3 /opt/linupdate/linupdate.py --set-mail-smtp-host localhost

- name: "Run test: get mail smtp host"
run: python3 /opt/linupdate/linupdate.py --get-mail-smtp-host

- name: "Run test: set mail smtp port"
run: python3 /opt/linupdate/linupdate.py --set-mail-smtp-port 25

- name: "Run test: get mail smtp port"
run: python3 /opt/linupdate/linupdate.py --get-mail-smtp-port

- name: "Run test: set package exclusions"
run: python3 /opt/linupdate/linupdate.py --exclude "kernel.*"

Expand Down Expand Up @@ -328,6 +352,18 @@ jobs:
- name: "Run test: set mail recipient"
run: python3 /opt/linupdate/linupdate.py --set-mail-recipient [email protected],[email protected]

- name: "Run test: set mail smtp host"
run: python3 /opt/linupdate/linupdate.py --set-mail-smtp-host localhost

- name: "Run test: get mail smtp host"
run: python3 /opt/linupdate/linupdate.py --get-mail-smtp-host

- name: "Run test: set mail smtp port"
run: python3 /opt/linupdate/linupdate.py --set-mail-smtp-port 25

- name: "Run test: get mail smtp port"
run: python3 /opt/linupdate/linupdate.py --get-mail-smtp-port

- name: "Run test: set package exclusions"
run: python3 /opt/linupdate/linupdate.py --exclude "kernel.*"

Expand Down Expand Up @@ -416,6 +452,18 @@ jobs:
- name: "Run test: set mail recipient"
run: sudo python3 /opt/linupdate/linupdate.py --set-mail-recipient [email protected],[email protected]

- name: "Run test: set mail smtp host"
run: sudo python3 /opt/linupdate/linupdate.py --set-mail-smtp-host localhost

- name: "Run test: get mail smtp host"
run: sudo python3 /opt/linupdate/linupdate.py --get-mail-smtp-host

- name: "Run test: set mail smtp port"
run: sudo python3 /opt/linupdate/linupdate.py --set-mail-smtp-port 25

- name: "Run test: get mail smtp port"
run: sudo python3 /opt/linupdate/linupdate.py --get-mail-smtp-port

- name: "Run test: set package exclusions"
run: sudo python3 /opt/linupdate/linupdate.py --exclude "kernel.*"

Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/build-and-test-rpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,18 @@ jobs:
- name: "Run test: set mail recipient"
run: python3 /opt/linupdate/linupdate.py --set-mail-recipient [email protected],[email protected]

- name: "Run test: set mail smtp host"
run: python3 /opt/linupdate/linupdate.py --set-mail-smtp-host localhost

- name: "Run test: get mail smtp host"
run: python3 /opt/linupdate/linupdate.py --get-mail-smtp-host

- name: "Run test: set mail smtp port"
run: python3 /opt/linupdate/linupdate.py --set-mail-smtp-port 25

- name: "Run test: get mail smtp port"
run: python3 /opt/linupdate/linupdate.py --get-mail-smtp-port

- name: "Run test: set package exclusions"
run: python3 /opt/linupdate/linupdate.py --exclude "kernel.*"

Expand Down Expand Up @@ -275,6 +287,18 @@ jobs:
- name: "Run test: set mail recipient"
run: python3 /opt/linupdate/linupdate.py --set-mail-recipient [email protected],[email protected]

- name: "Run test: set mail smtp host"
run: python3 /opt/linupdate/linupdate.py --set-mail-smtp-host localhost

- name: "Run test: get mail smtp host"
run: python3 /opt/linupdate/linupdate.py --get-mail-smtp-host

- name: "Run test: set mail smtp port"
run: python3 /opt/linupdate/linupdate.py --set-mail-smtp-port 25

- name: "Run test: get mail smtp port"
run: python3 /opt/linupdate/linupdate.py --get-mail-smtp-port

- name: "Run test: set package exclusions"
run: python3 /opt/linupdate/linupdate.py --exclude "kernel.*"

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ It should help you **installing** and starting using linupdate.
--mail-enable [true|false] Enable or disable mail reports
--get-mail-recipient Get current mail recipient(s)
--set-mail-recipient [EMAIL] Set mail recipient(s) (separated by commas)
--get-mail-stmp-host Get current mail SMTP host
--set-mail-stmp-host [HOST] Set mail SMTP host
--get-mail-stmp-port Get current mail SMTP port
--set-mail-stmp-port [PORT] Set mail SMTP port

Update options

Expand Down
32 changes: 32 additions & 0 deletions src/controllers/App/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,22 @@ def get_mail_recipient(self):
return configuration['main']['mail']['recipient']


#-----------------------------------------------------------------------------------------------
#
# Set mail smtp host
#
#-----------------------------------------------------------------------------------------------
def set_mail_smtp_host(self, smtp_host: str):
# Get current configuration
configuration = self.get_conf()

# Set smtp host
configuration['main']['mail']['smtp_host'] = smtp_host

# Write config file
self.write_conf(configuration)


#-----------------------------------------------------------------------------------------------
#
# Get mail smtp host
Expand All @@ -419,6 +435,22 @@ def get_mail_smtp_host(self):
return smtp_host


#-----------------------------------------------------------------------------------------------
#
# Set mail smtp host port
#
#-----------------------------------------------------------------------------------------------
def set_mail_smtp_port(self, smtp_port: int):
# Get current configuration
configuration = self.get_conf()

# Set smtp port
configuration['main']['mail']['smtp_port'] = smtp_port

# Write config file
self.write_conf(configuration)


#-----------------------------------------------------------------------------------------------
#
# Get mail smtp host port
Expand Down
76 changes: 76 additions & 0 deletions src/controllers/Args.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ def parse(self):
parser.add_argument("--get-mail-recipient", action="store_true", default="null")
# Set mail recipient
parser.add_argument("--set-mail-recipient", action="store", nargs='?', default="null")
# Get mail smtp host
parser.add_argument("--get-mail-smtp-host", action="store_true", default="null")
# Set mail smtp host
parser.add_argument("--set-mail-smtp-host", action="store", nargs='?', default="null")
# Get mail smtp port
parser.add_argument("--get-mail-smtp-port", action="store_true", default="null")
# Set mail smtp port
parser.add_argument("--set-mail-smtp-port", action="store", nargs='?', default="null")

# Packages to update list
parser.add_argument("--update", "-u", action="store", nargs='?', default="null")
Expand Down Expand Up @@ -299,6 +307,48 @@ def parse(self):
myExit.clean_exit(0, False)
except Exception as e:
raise ArgsException('Could not set mail recipient(s): ' + str(e))

#
# If --get-mail-smtp-host param has been set
#
if args.get_mail_smtp_host != "null":
try:
print(' Current mail SMTP host: ' + Fore.GREEN + myAppConfig.get_mail_smtp_host() + Style.RESET_ALL, end='\n\n')
myExit.clean_exit(0, False)
except Exception as e:
raise ArgsException('Could not get mail SMTP host: ' + str(e))

#
# If --set-mail-smtp-host param has been set
#
if args.set_mail_smtp_host != "null":
try:
myAppConfig.set_mail_smtp_host(args.set_mail_smtp_host)
print(' Mail SMTP host set to: ' + Fore.GREEN + args.set_mail_smtp_host + Style.RESET_ALL, end='\n\n')
myExit.clean_exit(0, False)
except Exception as e:
raise ArgsException('Could not set mail SMTP host: ' + str(e))

#
# If --get-mail-smtp-port param has been set
#
if args.get_mail_smtp_port != "null":
try:
print(' Current mail SMTP port: ' + Fore.GREEN + str(myAppConfig.get_mail_smtp_port()) + Style.RESET_ALL, end='\n\n')
myExit.clean_exit(0, False)
except Exception as e:
raise ArgsException('Could not get mail SMTP port: ' + str(e))

#
# If --set-mail-smtp-port param has been set
#
if args.set_mail_smtp_port != "null":
try:
myAppConfig.set_mail_smtp_port(args.set_mail_smtp_port)
print(' Mail SMTP port set to: ' + Fore.GREEN + str(args.set_mail_smtp_port) + Style.RESET_ALL, end='\n\n')
myExit.clean_exit(0, False)
except Exception as e:
raise ArgsException('Could not set mail SMTP port: ' + str(e))

#
# If --update param has been set
Expand Down Expand Up @@ -620,6 +670,32 @@ def help(self):
'option': 'EMAIL',
'description': 'Set mail recipient(s) (separated by commas)'
},
{
'args': [
'--get-mail-smtp-host'
],
'description': 'Get current mail SMTP host'
},
{
'args': [
'--set-mail-smtp-host'
],
'option': 'HOST',
'description': 'Set mail SMTP host'
},
{
'args': [
'--get-mail-smtp-port'
],
'description': 'Get current mail SMTP port'
},
{
'args': [
'--set-mail-smtp-port'
],
'option': 'PORT',
'description': 'Set mail SMTP port'
},
{
'title': 'Update options'
},
Expand Down

0 comments on commit 5c4f5b5

Please sign in to comment.