Пример #1
0
def create_user(self):
    username = self.hbox_username.get_text()
    name = self.hbox_name.get_text()
    atype = self.combo_account_type.get_active_text()
    password = self.hbox_password.get_text()
    confirm_password = self.hbox_confirm_password.get_text()
    user_password = "******" + username + ":" + password

    try:
        command = "groupadd -r sambashare"
        Functions.subprocess.call(command.split(" "),
                                  shell=False,
                                  stdout=Functions.subprocess.PIPE,
                                  stderr=Functions.subprocess.STDOUT)
    except Exception as e:
        print(e)

    if password == confirm_password:
        if atype == "Administrator":
            useradd = 'useradd -m -G audio,video,network,storage,rfkill,wheel,autologin,sambashare -c "' + name + '" -s /bin/bash ' + username
            os.system(useradd)
            os.system(user_password + " | " + "chpasswd -c SHA512")
        else:
            useradd = 'useradd -m -G audio,video,network,storage,rfkill,autologin,sambashare -c "' + name + '" -s /bin/bash ' + username
            os.system(useradd)
            os.system(user_password + " | " + "chpasswd -c SHA512")
        print("User has been created")
        GLib.idle_add(Functions.show_in_app_notification, self,
                      "User has been created")
    else:
        GLib.idle_add(Functions.show_in_app_notification, self,
                      "Passwords are not the same")
        Functions.MessageBox(self, "Message", "Passwords are not the same")
Пример #2
0
def choose_smb_conf(self, widget):
    choice = self.samba_choices.get_active_text()

    #options_samba = ['ArcoLinux', 'Example', 'Original']
    if choice == "ArcoLinux":
        Functions.copy_samba("arco")
        print("smb.conf from ArcoLinux")
        GLib.idle_add(Functions.show_in_app_notification, self,
                      "Smb.conf from ArcoLinux")
    elif choice == "Easy":
        Functions.copy_samba("example")
        GLib.idle_add(Functions.show_in_app_notification, self,
                      "Smb.conf easy configuration applied")
    elif choice == "Usershares":
        Functions.copy_samba("usershares")
        GLib.idle_add(Functions.show_in_app_notification, self,
                      "Smb.conf usershares configuration applied")
    elif choice == "Windows":
        Functions.copy_samba("windows")
        GLib.idle_add(Functions.show_in_app_notification, self,
                      "Smb.conf windows configuration applied")
    elif choice == "Original":
        Functions.copy_samba("original")
        print("Smb.conf from gitlab of Samba")
        GLib.idle_add(Functions.show_in_app_notification, self,
                      "Smb.conf from gitlab of Samba")
Пример #3
0
def set_lightdm_value(self, lists, value, session, state):
    try:
        com = Functions.subprocess.run(["sh", "-c", "su - " + Functions.sudo_username + " -c groups"], shell=False, stdout=Functions.subprocess.PIPE)
        groups = com.stdout.decode().strip().split(" ")
        # print(groups)
        if "autologin" not in groups:
            Functions.subprocess.run(["gpasswd", "-a", Functions.sudo_username, "autologin"], shell=False)            
        
        pos = Functions._get_position(lists, "autologin-user="******"autologin-session=")

        if state:
            lists[pos] = "autologin-user="******"\n"
            lists[pos_session] = "autologin-session=" + session + "\n"
        else:
            if "#" not in lists[pos]:
                lists[pos] = "#" + lists[pos]
                lists[pos_session] = "#" + lists[pos_session]

        with open(Functions.lightdm_conf, "w") as f:
            f.writelines(lists)
            f.close()

        GLib.idle_add(Functions.show_in_app_notification, self, "Settings Saved Successfully")

        # GLib.idle_add(Functions.MessageBox,self, "Success!!", "Settings applied successfully")
    except Exception as e:
        print(e)
        Functions.MessageBox(self, "Failed!!", "There seems to have been a problem in \"set_lightdm_value\"")
Пример #4
0
def gtk3_save_settings(value, item):

    if os.path.isfile(Functions.gtk3_settings):
        if not os.path.isfile(Functions.gtk3_settings + ".bak"):
            Functions.shutil.copy(Functions.gtk3_settings,
                                  Functions.gtk3_settings + ".bak")

        with open(Functions.gtk3_settings, 'r', encoding='utf-8') as f:
            lines = f.readlines()
            f.close()
        try:
            data = Functions.gtk_check_value(lines, item)
            if not data:
                print("Lines = " + str(len(lines)))
                pos = 4
                print("Pos = " + str(pos))
                lines.insert(pos, ''.join([item, "=", str(value), "\n"]))
            else:
                pos = int(Functions.gtk_get_position(lines, item))
                lines[pos] = ''.join([item, "=", str(value), "\n"])

            with open(Functions.gtk3_settings, 'w') as f:
                f.writelines(lines)
                f.close()
        except:
            GLib.idle_add(
                Functions.MessageBox, "ERROR!!",
                "An error has occured getting this setting \'gtk3_save_settings\'"
            )
Пример #5
0
def set_lightdm_value(self, lists, value, session, state):
    try:
        pos = Functions._get_position(lists, "autologin-user="******"autologin-session=")

        if state:
            lists[pos] = "autologin-user="******"\n"
            lists[pos_session] = "autologin-session=" + session + "\n"
        else:
            if not "#" in lists[pos]:
                lists[pos] = "#" + lists[pos]
                lists[pos_session] = "#" + lists[pos_session]

        with open(Functions.lightdm_conf, "w") as f:
            f.writelines(lists)
            f.close()

        GLib.idle_add(Functions.show_in_app_notification, self,
                      "Settings Saved Successfully")

        # GLib.idle_add(Functions.MessageBox,self, "Success!!", "Settings applied successfully")
    except Exception as e:
        print(e)
        Functions.MessageBox(
            self, "Failed!!",
            "There seems to have been a problem in \"set_lightdm_value\"")
Пример #6
0
def set_xfce_settings(theme, icon, cursor, cursize):
    if os.path.isfile(Functions.xfce_config):
        if not os.path.isfile(Functions.xfce_config + ".bak"):
            Functions.shutil.copy(Functions.xfce_config,
                                  Functions.xfce_config + ".bak")
        try:
            with open(Functions.xfce_config, "r") as f:
                lines = f.readlines()
                f.close()

            for i in range(len(lines)):
                if "name=\"ThemeName\"" in lines[i]:
                    val = re.search(r"value=\"(.*?)\"", lines[i]).group(0)
                    lines[i] = lines[i].replace(val,
                                                "value=\"" + str(theme) + "\"")
                if "name=\"IconThemeName\"" in lines[i]:
                    val = re.search(r"value=\"(.*?)\"", lines[i]).group(0)
                    lines[i] = lines[i].replace(val,
                                                "value=\"" + str(icon) + "\"")
                if "name=\"CursorThemeName\"" in lines[i]:
                    val = re.search(r"value=\"(.*?)\"", lines[i]).group(0)
                    lines[i] = lines[i].replace(
                        val, "value=\"" + str(cursor) + "\"")

                if "name=\"CursorThemeSize\"" in lines[i]:
                    val = re.search(r"value=\"(.*?)\"", lines[i]).group(0)
                    lines[i] = lines[i].replace(
                        val, "value=\"" + str(cursize) + "\"")

                # if "name=\"FontName\"" in lines[i]:
                #     val = re.search(r"value=\"(.*?)\"",lines[i]).group(0)
                #     lines[i] = lines[i].replace(val, "value=\"" + str(fonts) + "\"")

                # if "name=\"MonospaceFontName\"" in lines[i]:
                #     val = re.search(r"value=\"(.*?)\"",lines[i]).group(0)
                #     lines[i] = lines[i].replace(val, "value=\"" + str(monofonts) + "\"")

            with open(Functions.xfce_config, "w") as f:
                f.writelines(lines)
                f.close()
            # tree = et.parse(Functions.xfce_config)
            # for rank in tree.iter('property'):
            #     if rank.get("name") == "ThemeName":
            #         rank.set("value", str(theme))
            #     if rank.get("name") == "IconThemeName":
            #         rank.set("value", str(icon))
            #     if rank.get("name") == "CursorThemeName":
            #         rank.set("value", str(cursor))
            #     if rank.get("name") == "CursorThemeSize":
            #         rank.set("value", str(cursize))

            # tree.write(Functions.xfce_config, encoding="utf-8", xml_declaration=True)
        except:
            GLib.idle_add(
                Functions.MessageBox, "ERROR!!",
                "An error has occured setting this setting \'set_xfce_settings\'"
            )
Пример #7
0
def delete_user(self, widget):

    username = self.samba_users.get_active_text()

    if username:
        userdel = 'userdel ' + username
        Functions.os.system(userdel)
        print("The user " + username +
              " has been completely deleted from your system")
        GLib.idle_add(Functions.show_in_app_notification, self,
                      "User deleted from system")
    else:
        print("Something went wrong")
Пример #8
0
def restart_smb(self, widget):

    if Functions.check_service("smb"):
        restart = 'systemctl restart smb'
        Functions.os.system(restart)
        print("Restarting smb service...")
        GLib.idle_add(Functions.show_in_app_notification, self,
                      "Restarting smb service...")
    else:
        print("Did you install samba - check for errors")
        print("Type in a terminal")
        print("   sudo systemctl status smb")
        GLib.idle_add(Functions.show_in_app_notification, self,
                      "Did you install samba - check for errors")
Пример #9
0
def delete_samba_user(self, widget):

    username = self.samba_users.get_active_text()

    if username:
        Functions.install_alacritty(self)
        Functions.subprocess.call("alacritty -e /usr/bin/smbpasswd -x " +
                                  username,
                                  shell=True,
                                  stdout=Functions.subprocess.PIPE,
                                  stderr=Functions.subprocess.STDOUT)
        print("Deleting the selected user from Samba...")
        GLib.idle_add(Functions.show_in_app_notification, self,
                      "Deleting the selected user from Samba...")
    else:
        print("Make a selection")
        GLib.idle_add(Functions.show_in_app_notification, self,
                      "Make a selection")
Пример #10
0
def set_sddm_cursor(self, lists, cursor):
    try:

        pos_theme = Functions._get_position(lists, "CursorTheme=")
        lists[pos_theme] = "CursorTheme=" + cursor + "\n"

        with open(Functions.sddm_default, "w") as f:
            f.writelines(lists)
            f.close()

        GLib.idle_add(Functions.show_in_app_notification, self,
                      "Settings Saved Successfully")

    except Exception as e:
        print(e)
        Functions.MessageBox(
            self, "Failed!!",
            "There seems to have been a problem in \"set_sddm_value\"")
Пример #11
0
def create_user(self):
    username = self.hbox_username.get_text()
    name = self.hbox_name.get_text()
    atype = self.combo_account_type.get_active_text()
    password = self.hbox_password.get_text()
    confirm_password = self.hbox_confirm_password.get_text()
    user_password = "******" + username + ":" + password    
    
    if password == confirm_password :
        if atype == "Administrator" :
            useradd ='useradd -m -G audio,video,network,storage,rfkill,wheel -c "'  + name + '" -s /bin/bash ' + username
            os.system(useradd)          
            os.system(user_password + " | " + "chpasswd -c SHA512")
        else:
            useradd ='useradd -m -G audio,video,network,storage,rfkill -c "'  + name + '" -s /bin/bash ' + username
            os.system(useradd)
            os.system(user_password + " | " + "chpasswd -c SHA512")
        GLib.idle_add(Functions.show_in_app_notification, self, "User has been created")
    else:
        GLib.idle_add(Functions.show_in_app_notification, self, "Passwords are not the same")
        Functions.MessageBox(self, "Message", "Passwords are not the same")
Пример #12
0
def create_samba_user(self, widget):

    username = Functions.sudo_username
    #password = self.entry_password.get_text()

    if username:
        #user_password = "******" + username + ":" + password

        # com = Functions.subprocess.run(["sh", "-c", "su - " + Functions.sudo_username + " -c groups"], shell=False, stdout=Functions.subprocess.PIPE)
        # groups = com.stdout.decode().strip().split(" ")
        # # print(groups)
        # if "sambashare" not in groups:
        #     Functions.subprocess.run(["gpasswd", "-a", Functions.sudo_username, "sambashare"], shell=False)

        # useradd ='useradd -m -G autologin,audio,video,network,storage,rfkill,wheel,sambashare -c "'  + username + '" -s /bin/bash ' + username
        # Functions.os.system(useradd)
        # Functions.os.system(user_password + " | " + "chpasswd -c SHA512")

        Functions.install_alacritty(self)
        print("Type in your password for the Sambashare")
        print(
            "Although the user name is shared with Linux system, Samba uses a password"
        )
        print("separate from that of the Linux user accounts.")
        try:
            Functions.subprocess.call("alacritty -e /usr/bin/smbpasswd -a " +
                                      username,
                                      shell=True,
                                      stdout=Functions.subprocess.PIPE,
                                      stderr=Functions.subprocess.STDOUT)
            print("Created a password for the current user")
            GLib.idle_add(Functions.show_in_app_notification, self,
                          "Created a password for the current user")
        except Exception as e:
            print(e)
    else:
        print("First fill in your username")
        GLib.idle_add(Functions.show_in_app_notification, self,
                      "First fill in your username")
Пример #13
0
def skel_run(self, cat):
    count = cat.__len__()
    if(count > 0):
        prog = (count/count)/count
        self.ecode = 0
        for item in cat:
            # print(item[0])
            GLib.idle_add(setProgress, self.progressbar1, self.progressbar1.get_fraction() + prog)
            old = item[0]
            new = old.replace("/etc/skel", Functions.home)
            if os.path.isdir(old):
                Functions.copy_func(old,  os.path.split(new)[0], True)                
            if os.path.isfile(old):
                Functions.copy_func(old, new)
            Functions.permissions(new)
    GLib.idle_add(button_toggles, self, True)
    GLib.idle_add(setMessage,self.label_info1, "Idle ...")
    GLib.idle_add(setProgress, self.progressbar1, 0)
Пример #14
0
def choose_nsswitch(self, widget):
    choice = self.nsswitch_choices.get_active_text()

    #options = ['ArcoLinux', 'Garuda', 'Arch Linux', 'EndeavourOS']
    if choice == "ArcoLinux":
        Functions.copy_nsswitch("arco")
        print("Nsswitch from ArcoLinux")
        GLib.idle_add(Functions.show_in_app_notification, self,
                      "Nsswitch from ArcoLinux")
    elif choice == "Garuda":
        Functions.copy_nsswitch("garuda")
        print("Nsswitch from Garuda")
        GLib.idle_add(Functions.show_in_app_notification, self,
                      "Nsswitch from Garuda")
    elif choice == "Arch Linux":
        Functions.copy_nsswitch("arch")
        print("Nsswitch from Arch Linux")
        GLib.idle_add(Functions.show_in_app_notification, self,
                      "Nsswitch from Arch Linux")
    else:
        Functions.copy_nsswitch("eos")
        print("Nsswitch from EndeavourOS")
        GLib.idle_add(Functions.show_in_app_notification, self,
                      "Nsswitch from EndeavourOS")
Пример #15
0
def restore_item(self):
    backup_path = Functions.home + "/" + Functions.bd + "/" + self.backs.get_active_text(
    ) + "/"
    treeselect = self.treeView2.get_selection()
    (model, pathlist) = treeselect.get_selected_rows()
    if len(pathlist) > 0:
        GLib.idle_add(setProgress, self.progressbar, 0.1)

        GLib.idle_add(self.progressbar.set_pulse_step, 0.2)
        timeout_id = None
        timeout_id = GLib.timeout_add(100, do_pulse, None, self,
                                      self.progressbar)

        for path in pathlist:
            tree_iter = model.get_iter(path)
            value = model.get_value(tree_iter, 0)
            file_path = backup_path + value
        if value.__len__() > 0:
            if os.path.isfile(file_path):
                Functions.copy_func(
                    file_path,
                    Functions.home + "/" + value.split("-backup")[0])
                Functions.permissions(Functions.home + "/" +
                                      value.split("-backup")[0])
            elif os.path.isdir(file_path):
                dirs = Functions.home + "/" + value.split("-backup")[0]
                # old_dir = Functions.home + "/" + value
                GLib.idle_add(setMessage, self.label_info,
                              "Removing Existing Destination Folder ...")
                Functions.subprocess.call(["rm", "-rf", dirs])
                GLib.idle_add(
                    setMessage, self.label_info,
                    "Copying " + value + " to " + value.split("-backup")[0])
                Functions.copy_func(file_path, dirs, True)
                Functions.permissions(dirs)

    GLib.source_remove(timeout_id)
    timeout_id = None
    GLib.idle_add(button_toggles, self, True)
    GLib.idle_add(setMessage, self.label_info, "Idle ...")
    GLib.idle_add(setProgress, self.progressbar, 0)
Пример #16
0
def processing(self, active_text, label, progress):
    now = datetime.datetime.now()

    Functions.check_backups(now)

    GLib.idle_add(setProgress, progress, 0.1)

    GLib.idle_add(self.progressbar.set_pulse_step, 0.2)
    timeout_id = None
    timeout_id = GLib.timeout_add(100, do_pulse, None, self, progress)

    # ============================
    #       CONFIG
    # ============================
    GLib.idle_add(setMessage, label, "Backing up .config")
    Functions.copy_func(
        Functions.home + '/.config', Functions.home + '/' + Functions.bd +
        "/Backup-" + now.strftime("%Y-%m-%d %H") + '/.config-backup-' +
        now.strftime("%Y-%m-%d %H:%M:%S"), True)
    Functions.permissions(Functions.home + '/' + Functions.bd + "/Backup-" +
                          now.strftime("%Y-%m-%d %H") + '/.config-backup-' +
                          now.strftime("%Y-%m-%d %H:%M:%S"))

    # GLib.idle_add(setProgress, self, 0.3)
    GLib.source_remove(timeout_id)
    timeout_id = None

    GLib.idle_add(setProgress, progress, 0.5)
    # ============================
    #       LOACAL
    # ============================
    GLib.idle_add(setMessage, label, "Backing up .local")
    Functions.copy_func(
        Functions.home + '/.local', Functions.home + '/' + Functions.bd +
        "/Backup-" + now.strftime("%Y-%m-%d %H") + '/.local-backup-' +
        now.strftime("%Y-%m-%d %H:%M:%S"), True)
    Functions.permissions(Functions.home + '/' + Functions.bd + "/Backup-" +
                          now.strftime("%Y-%m-%d %H") + '/.local-backup-' +
                          now.strftime("%Y-%m-%d %H:%M:%S"))

    GLib.idle_add(setProgress, progress, 0.7)
    # ============================
    #       BASH
    # ============================

    if os.path.isfile(Functions.home + '/.bashrc'):
        GLib.idle_add(setMessage, label, "Backing up .bashrc")
        Functions.copy_func(
            Functions.home + '/.bashrc', Functions.home + "/" + Functions.bd +
            "/Backup-" + now.strftime("%Y-%m-%d %H") + "/.bashrc-backup-" +
            now.strftime("%Y-%m-%d %H:%M:%S"))
        Functions.permissions(Functions.home + "/" + Functions.bd +
                              "/Backup-" + now.strftime("%Y-%m-%d %H") +
                              "/.bashrc-backup-" +
                              now.strftime("%Y-%m-%d %H:%M:%S"))

    GLib.idle_add(setProgress, progress, 0.8)
    # ============================
    #       ZSH
    # ============================
    if os.path.isfile(Functions.home + '/.zshrc'):
        GLib.idle_add(setMessage, label, "Backing up .zshrc")
        Functions.copy_func(
            Functions.home + '/.zshrc', Functions.home + "/" + Functions.bd +
            "/Backup-" + now.strftime("%Y-%m-%d %H") + "/.zshrc-backup-" +
            now.strftime("%Y-%m-%d %H:%M:%S"))
        Functions.permissions(Functions.home + "/" + Functions.bd +
                              "/Backup-" + now.strftime("%Y-%m-%d %H") +
                              "/.zshrc-backup-" +
                              now.strftime("%Y-%m-%d %H:%M:%S"))
    GLib.idle_add(setProgress, progress, 0.9)

    # ============================
    #       CONKY
    # ============================
    if os.path.exists(Functions.home + '/.lua'):
        GLib.idle_add(setMessage, label, "Backing up .lua")
        Functions.copy_func(
            Functions.home + '/.lua', Functions.home + '/' + Functions.bd +
            "/Backup-" + now.strftime("%Y-%m-%d %H") + '/.lua-backup-' +
            now.strftime("%Y-%m-%d %H:%M:%S"), True)
        Functions.permissions(Functions.home + '/' + Functions.bd +
                              "/Backup-" + now.strftime("%Y-%m-%d %H") +
                              '/.lua-backup-' +
                              now.strftime("%Y-%m-%d %H:%M:%S"))

    if os.path.isfile(Functions.home + '/.conkyrc'):
        GLib.idle_add(setMessage, label, "Backing up .cokyrc")
        Functions.copy_func(
            Functions.home + '/.conkyrc', Functions.home + "/" + Functions.bd +
            "/Backup-" + now.strftime("%Y-%m-%d %H") + "/.conkyrc-backup-" +
            now.strftime("%Y-%m-%d %H:%M:%S"))
        Functions.permissions(Functions.home + "/" + Functions.bd +
                              "/Backup-" + now.strftime("%Y-%m-%d %H") +
                              "/.conkyrc-backup-" +
                              now.strftime("%Y-%m-%d %H:%M:%S"))

    GLib.idle_add(setProgress, progress, 1.0)

    GLib.idle_add(setMessage, label, "Done")

    if not active_text == "BACKUP":
        pass
        GLib.idle_add(setMessage, label, "Running Skel")

        GLib.idle_add(skel_run, self, active_text)
    else:
        GLib.idle_add(button_toggles, self, True)
        GLib.idle_add(setMessage, label, "Idle...")
        GLib.idle_add(setProgress, progress, 0)

    GLib.idle_add(refresh, self)
    GLib.idle_add(refresh_inner, self)
Пример #17
0
def bash_upgrade(self):

    now = datetime.datetime.now()
    GLib.idle_add(setMessage, self.label_info1, "Running Backup")

    Functions.check_backups(now)

    if os.path.isfile(Functions.home + '/.bashrc'):
        Functions.copy_func(
            Functions.home + '/.bashrc', Functions.home + "/" + Functions.bd +
            "/Backup-" + now.strftime("%Y-%m-%d %H") + "/.bashrc-backup-" +
            now.strftime("%Y-%m-%d %H:%M:%S"))
        Functions.permissions(Functions.home + "/" + Functions.bd +
                              "/Backup-" + now.strftime("%Y-%m-%d %H") +
                              "/.bashrc-backup-" +
                              now.strftime("%Y-%m-%d %H:%M:%S"))

    GLib.idle_add(setMessage, self.label_info1, "Upgrading Bashrc")

    if os.path.isfile("/etc/skel/.bashrc"):
        Functions.copy_func("/etc/skel/.bashrc", Functions.home + "/.bashrc")
        Functions.permissions(Functions.home + "/.bashrc")
        GLib.idle_add(setMessage, self.label_info1, ".bashrc upgrade done")

        GLib.idle_add(Functions.show_in_app_notification, self,
                      "bashrc upgraded")
    else:
        GLib.idle_add(
            Functions.MessageBox, self, "Failed!!",
            "bashrc upgrade failed, you dont have a .bashrc in skel")

    Functions.source_shell(self)

    GLib.idle_add(setMessage, self.label_info1, "Idle ...")
    GLib.idle_add(refresh, self)
    GLib.idle_add(button_toggles, self, True)
Пример #18
0
def Flush_All(self):
    count = os.listdir(Functions.home + "/" + Functions.bd).__len__()

    if count > 0:
        count = ((count / count) / count)
        GLib.idle_add(setMessage, self.label_info, "Deleting Backup")
        for filename in os.listdir(Functions.home + "/" + Functions.bd):
            if os.path.isdir(Functions.home + "/" + Functions.bd + "/" +
                             filename):
                GLib.idle_add(setProgress, self.progressbar,
                              self.progressbar.get_fraction() + count)
                Functions.shutil.rmtree(Functions.home + "/" + Functions.bd +
                                        "/" + filename)

        GLib.idle_add(Functions.show_in_app_notification, self,
                      "Backups directory has been cleaned.")
        GLib.idle_add(refresh, self)
        GLib.idle_add(refresh_inner, self)
        GLib.idle_add(setProgress, self.progressbar, 0)
    GLib.idle_add(button_toggles, self, True)
    GLib.idle_add(setMessage, self.label_info, "Idle ...")
Пример #19
0
def Delete_Inner_Backup(self):
    count = os.listdir(Functions.home + "/" + Functions.bd).__len__()

    if count > 0:
        GLib.idle_add(setMessage, self.label_info, "Removing ...")
        GLib.idle_add(setProgress, self.progressbar, 0.3)
        treeselect = self.treeView2.get_selection()

        for filename in os.listdir(Functions.home + "/" + Functions.bd + "/" +
                                   self.backs.get_active_text()):
            (model, pathlist) = treeselect.get_selected_rows()
            for path in pathlist:
                tree_iter = model.get_iter(path)
                value = model.get_value(tree_iter, 0)
                if filename == value:
                    # print(value)
                    if os.path.isdir(Functions.home + "/" + Functions.bd +
                                     "/" + self.backs.get_active_text() + "/" +
                                     filename):
                        Functions.shutil.rmtree(Functions.home + "/" +
                                                Functions.bd + "/" +
                                                self.backs.get_active_text() +
                                                "/" + filename)
                    elif os.path.isfile(Functions.home + "/" + Functions.bd +
                                        "/" + self.backs.get_active_text() +
                                        "/" + filename):
                        os.unlink(Functions.home + "/" + Functions.bd + "/" +
                                  self.backs.get_active_text() + "/" +
                                  filename)

        GLib.idle_add(refresh_inner, self)
        GLib.idle_add(setProgress, self.progressbar, 1)
        GLib.idle_add(Functions.show_in_app_notification, self,
                      "Config backups cleaned.")
        GLib.idle_add(setMessage, self.label_info, "Idle ...")
    GLib.idle_add(button_toggles, self, True)
    GLib.idle_add(setProgress, self.progressbar, 0)
Пример #20
0
def Delete_Backup(self):
    count = os.listdir(Functions.home + "/" + Functions.bd).__len__()

    if count > 0:
        GLib.idle_add(setMessage, self.label_info, "Removing ...")
        GLib.idle_add(setProgress, self.progressbar, 0.3)
        for filename in os.listdir(Functions.home + "/" + Functions.bd):
            if filename == self.backs.get_active_text():
                Functions.shutil.rmtree(Functions.home + "/" + Functions.bd +
                                        "/" + filename)
        GLib.idle_add(refresh, self)
        GLib.idle_add(refresh_inner, self)
        GLib.idle_add(setProgress, self.progressbar, 1)
        GLib.idle_add(Functions.show_in_app_notification, self,
                      "Config backups cleaned.")
    GLib.idle_add(button_toggles, self, True)
    GLib.idle_add(setMessage, self.label_info, "Idle ...")
    GLib.idle_add(setProgress, self.progressbar, 0)