def view_users_dialog(self): form = auto_ui.UI_Form() form.set_title("View users") form.add_query("master_password", "Enter master password to view passwords, else press enter", default_value = "") self._render.run(form) results = self._render.get_results() form = auto_ui.UI_Form() form.add_description("Use 'sudo pdbedit -L -v' in terminal to list all active samba accounts") for username in self._config.get_usernames(): user = self._config.get_user(username, results["master_password"]) form.add_description(username + ": " + str(user)) self._render.run(form)
def view_backup_locations_dialog(self): form = auto_ui.UI_Form() form.set_title("View backup locations") for backup_location_name in self._config.get_backup_location_names(): form.add_description(backup_location_name + ": " + str(self._config.get_backup_location(backup_location_name))) self._render.run(form)
def view_shares_dialog(self): form = auto_ui.UI_Form() form.set_title("View shares") form.add_description("To view all shares recognised by samba run 'sudo net usershare info' in terminal") for share_name in self._config.get_share_names(): form.add_description(share_name + ": " + str(self._config.get_share(share_name))) self._render.run(form) self._render.get_results()
def save_configuration_dialog(self): form = auto_ui.UI_Form() form.set_title("Save configuration") form.add_query("file_path", "File path of config", default_value = defaults.CONFIG_DEFAULT_FILEPATH) self._render.run(form) results = self._render.get_results() actions.save_configuration( self._config, results["file_path"])
def set_private_share_directory(self): form = auto_ui.UI_Form() form.set_title("Set default share directory") form.add_query("directory", "Directory") self._render.run(form) results = self._render.get_results() actions.set_private_share_directory( self._config, results["directory"])
def remove_backup_location_dialog(self): form = auto_ui.UI_Form() form.set_title("Remove backup location") form.add_query("location_name", "Name of backup location") self._render.run(form) results = self._render.get_results() actions.remove_backup_location( self._config, results["location_name"])
def create_menu(self, title, menu_options, descriptions = []): form = auto_ui.UI_Form() form.set_title(title) for description in descriptions: form.add_description(description) for i, menu_option in enumerate(menu_options): form.add_description(str(i) + "." + menu_option) ## get_option_func = lambda number : menu_options[int(number)] form.add_query("option", "Enter menu option number", int) return form
def add_backup_location_dialog(self): form = auto_ui.UI_Form() form.set_title("Add backup location") form.add_query("location_name", "Name of backup location") form.add_query("directory", "Backup directory") self._render.run(form) results = self._render.get_results() actions.add_backup_location( self._config, results["location_name"], results["directory"])
def remove_share_dialog(self): form = auto_ui.UI_Form() form.set_title("Delete share") form.add_query("share_name", "Share name") form.add_query("delete_share_folder", "Delete the share folder (Y/N)?", lambda choice:choice.upper() == "Y") self._render.run(form) results = self._render.get_results() actions.remove_share( self._config, results["share_name"], results["delete_share_folder"])
def remove_user_dialog(self): form = auto_ui.UI_Form() form.set_title("Remove a user") form.add_query("username", "Enter username") form.add_query("delete_private_share", "Delete the private share folder of the user (Y/N)?", lambda choice:choice.upper() == "Y") self._render.run(form) results = self._render.get_results() actions.remove_user( self._config, results["username"], results["delete_private_share"])
def run_backup_dialog(self): form = auto_ui.UI_Form() form.set_title("Run backup") form.add_query("master_password", "Enter master password") self._render.run(form) results = self._render.get_results() failed_shares, backup_locations_used = actions.run_backup(self._config, results["master_password"]) form = auto_ui.UI_Form() form.set_title("Backup outcome") form.add_description("Backup locations used:") for backup_location in backup_locations_used: form.add_description(backup_location) form.add_description("Failed shares:") for failed_share in failed_shares: form.add_description(failed_share) self._render.run(form)
def add_user_dialog(self): form = auto_ui.UI_Form() form.set_title("Add a user") form.add_query("username", "Enter username") form.add_query("password", "Enter password") form.add_query("private_share", "Add private share (Y/N)?", lambda choice:choice.upper() == "Y") form.add_query("master_password", "Enter the master password") self._render.run(form) results = self._render.get_results() actions.add_user( self._config, results["username"], results["password"], results["private_share"], results["master_password"])
def add_share_dialog(self): form = auto_ui.UI_Form() form.set_title("Add a share") form.add_query("share_name", "Share name") form.add_query("share_dir", "Share directory") form.add_query("share_comment", "Share Comment") form.add_query("acl", "Share access control list(ACL)") form.add_query("guest_access", "Guest access (Y/N)", lambda value: value.lower()) self._render.run(form) results = self._render.get_results() actions.add_share( self._config, results["share_name"], results["share_dir"], results["share_comment"], results["acl"], results["guest_access"])