Skip to content

Commit

Permalink
latest
Browse files Browse the repository at this point in the history
  • Loading branch information
“Erick committed Oct 28, 2021
1 parent 8530511 commit 516ee1a
Show file tree
Hide file tree
Showing 13 changed files with 287 additions and 269 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__/
24 changes: 12 additions & 12 deletions Snap-Tool/modules/ConfigurationClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
from modules.LoggerClass import Logger

"""
Class that manages everything related to the Snap-Tool
configuration file.
Class that manages everything related to the Snap-Tool configuration file.
"""
class Configuration:
"""
Expand All @@ -18,7 +17,7 @@ class Configuration:
logger = None

"""
Property that stores an object of type FormDialogs.
Property that stores an object of type FormDialog.
"""
form_dialog = None

Expand All @@ -32,6 +31,7 @@ class Configuration:
Parameters:
self -- An instantiated object of the Configuration class.
form_dialog -- FormDialog class object.
"""
def __init__(self, form_dialog):
self.logger = Logger()
Expand Down Expand Up @@ -60,7 +60,7 @@ def createConfiguration(self):
valid_certificate = self.form_dialog.getDataYesOrNo("\nDo you want the certificate for SSL/TLS communication to be validated?", "Certificate Validation")
if valid_certificate == "ok":
data_conf.append(True)
path_cert_file = self.form_dialog.getFile('/etc/Snap-Tool', "Select the CA certificate:")
path_cert_file = self.form_dialog.getFile('/etc/Snap-Tool', "Select the CA certificate:", ".pem")
data_conf.append(path_cert_file)
else:
data_conf.append(False)
Expand All @@ -86,10 +86,10 @@ def createConfiguration(self):
data_conf.append(False)
self.createFileConfiguration(data_conf)
if path.exists(self.conf_file):
self.form_dialog.d.msgbox("\nConfiguration file created", 7, 50, title = "Notification Message")
self.form_dialog.d.msgbox(text = "\nConfiguration file created", height = 7, width = 50, title = "Notification Message")
self.logger.createSnapToolLog("Configuration file created", 2)
else:
self.form_dialog.d.msgbox("\nError creating configuration file. For more information, see the logs.", 8, 50, title = "Error Message")
self.form_dialog.d.msgbox(text = "\nError creating configuration file. For more information, see the logs.", height = 8, width = 50, title = "Error Message")
self.form_dialog.mainMenu()

"""
Expand Down Expand Up @@ -190,13 +190,13 @@ def updateConfiguration(self):
del data_conf['path_certificate']
data_conf['valid_certificate'] = False
elif opt_valid_cert_true == "Certificate File":
path_cert_file = self.form_dialog.getFile(data_conf['path_certificate'], "Select the CA certificate:")
path_cert_file = self.form_dialog.getFile(data_conf['path_certificate'], "Select the CA certificate:", ".pem")
data_conf['path_certificate'] = path_cert_file
else:
opt_valid_cert_false = self.form_dialog.getDataRadioList("Select a option:", options_valid_cert_false, "Certificate Validation")
if opt_valid_cert_false == "Enable":
data_conf['valid_certificate'] = True
path_cert_file = self.form_dialog.getFile('/etc/Snap-Tool', "Select the CA certificate:")
path_cert_file = self.form_dialog.getFile('/etc/Snap-Tool', "Select the CA certificate:", ".pem")
valid_cert_json = { 'path_certificate' : path_cert_file }
data_conf.update(valid_cert_json)
else:
Expand All @@ -205,7 +205,7 @@ def updateConfiguration(self):
data_conf['use_ssl'] = True
valid_certificate = self.form_dialog.getDataYesOrNo("\nDo you want the certificates for SSL/TLS communication to be validated?", "Certificate Validation")
if valid_certificate == "ok":
path_cert_file = self.form_dialog.getFile('/etc/Snap-Tool', "Select the CA certificate:")
path_cert_file = self.form_dialog.getFile('/etc/Snap-Tool', "Select the CA certificate:", ".pem")
valid_cert_json = { 'valid_certificate' : True, 'path_certificate' : path_cert_file }
else:
valid_cert_json = { 'valid_certificate' : False }
Expand Down Expand Up @@ -258,14 +258,14 @@ def updateConfiguration(self):
self.utils.createYamlFile(data_conf, self.conf_file, 'w')
hash_data_conf_upd = self.utils.getHashToFile(self.conf_file)
if hash_data_conf == hash_data_conf_upd:
self.form_dialog.d.msgbox("\nThe configuration file was not modified.", 7, 50, title = "Notification Message")
self.form_dialog.d.msgbox(text = "\nThe configuration file was not modified.", height = 7, width = 50, title = "Notification Message")
else:
self.logger.createSnapToolLog("The configuration file was modified", 1)
self.form_dialog.d.msgbox("\nThe configuration file was modified.", 7, 50, title = "Notification Message")
self.form_dialog.d.msgbox(text = "\nThe configuration file was modified.", height = 7, width = 50, title = "Notification Message")
self.form_dialog.mainMenu()
except (OSError, KeyError) as exception:
self.logger.createSnapToolLog(exception, 3)
self.form_dialog.d.msgbox("\nError modifying the configuration file. For more information, see the logs.", 8, 50, title = "Error Message")
self.form_dialog.d.msgbox(text = "\nError modifying the configuration file. For more information, see the logs.", height = 8, width = 50, title = "Error Message")
self.form_dialog.mainMenu()

"""
Expand Down
Loading

0 comments on commit 516ee1a

Please sign in to comment.