def install_deb_pack(self, pack="*"): """ :param pack: :return: """ if pack == "*": data = self.get_deb_packs() for deb_item in data: sep = str(deb_item[2]).split("/") file = sep[-1] annimations_cgi.DebPacks.installing_package(deb_item[1]) if not self.check_file_downloaded(deb_item[2]): check_output( f"cd ./deb_bins && wget {deb_item[2]} && cd ..") check_output("sudo apt install ./deb_packs/" + file) else: if not self.check_debpack_exists(pack): raise self.PackageNotFound() data_pack = self.cursor.execute( "select nm_pack, link_download, vl_installed from DebPacks;" ).fetchone() sep = str(data_pack[1]).split('/') if not self.check_file_downloaded(data_pack[1]): check_output(f"cd ./deb_bins && wget {data_pack[1]}") if int(data_pack[2]) != 1: self.alt_deb_pack("vl_installed", 1, data_pack[0]) annimations_cgi.DebPacks.installing_package(data_pack[0]) check_output(f"sudo apt install ./{sep[-1]} && cd ..")
def config_repo(cls, repo="--all", dir_to_clone="--pwd"): """Configure the repositories""" if dir_to_clone != "--pwd": chdir(dir_to_clone) if repo == "--all": all_ = cls.cursor.execute("select * from Gits;") for i in all_.fetchall(): a = check_output("git clone " + i[2]) annimations_cgi.GitterAnimations.clone_repo(i[1]) del a chdir(i[1]) a = check_output("git remote add " + i[3] + " " + i[2]) del a a = check_output("git config --global user.name = " + i[5]) del a a = check_output("git config --global user.email = " + i[4]) annimations_cgi.GitterAnimations.config_repo(i[1]) chdir("..") del a else: if not cls.repo_exists(repo): raise cls.RepositoryNotFound() all_ = cls.cursor.execute( f"select * from Gits where Nm_Git = '{repo}';").fetchall()[0] a = check_output("git clone " + all_[2]) del a chdir(all_[1]) a = check_output("git remote add " + all_[3] + " " + all_[2]) del a a = check_output("git config --global user.name = " + all_[5]) del a a = check_output("git config --global user.email = " + all_[4]) chdir("..") del a annimations_cgi.GitterAnimations.clone_repo(repo)
def config_repo(self, repo_nm: str = "*"): """ Configure a repository, setting if it's a ppa or not :param repo_nm: The repository to configure. default = '*' if '*', then configure all repositories, ppa or not ppa """ if repo_nm == "*": all_ppa_repos = self.get_ppa_repos() all_reg_repos = self.get_regular_repos() for ppa_repo in all_ppa_repos: self.add_repo_ppa(ppa_repo[2]) for reg_repo in all_reg_repos: self.add_repo_regular(reg_repo[2]) del all_reg_repos, all_ppa_repos else: if not self.check_repo_exists(repo_nm): raise self.RepositoryNotFoundError() query_repo_data = self.cursor.execute( f"select * from Repositories where nm_repo='{repo_nm}';" ).fetchone() if self.get_bool_index(query_repo_data[3]): self.add_repo_ppa(query_repo_data[2]) else: self.add_repo_regular(query_repo_data[2]) del query_repo_data command_update = check_output( "sudo apt-get update") # update the list of the linux. del command_update
def getVersion(): version = "-"; try: output = os.check_output(["git", "describe", "--abbrev=8", "--versions", "--always", "--dirty"]) output = output.replace('\n', '') if len(output) > 0: version = output return version except: return version
def add_repo_regular(repo: str): """ Configures a non-ppa repository, writing it on /etc/apt/sources.list. The system'll comment 'Added By FIL' in the repository line, after the repository, of course. :param repo: The repository host to add in /etc/apt/sources.list """ command = check_output( f"sudo -sh -c \"{repo} # Added By The FIL\" >> /etc/apt/sources.list" ) del command
def add_repo_ppa(repo: str): """ Configure a ppa repository, using command 'sudo add-apt-repository ppa: %repository$/ppa' :param repo: The repository to add, it's need to have '/ppa', else it'll raise a error, of course by the shell. :type repo: str """ if "/ppa" not in repo: repo += "/ppa" command = check_output("sudo add-apt-repository ppa:" + repo) del command
def install_package(cls, package="--all"): """Install the typed package, if it's not defined, install all packages in database""" if package == "--all": a = cls.cursor.execute("select Command from Packages;") for i in a.fetchall(): pack = cls.cursor.execute( f"select Nm_Pack from Packages where Command = '{i[0]}';" ).fetchall()[0][0] annimations_cgi.InstallerAnimation.install_pack(pack) b = check_output(i[0]) del b del a else: if not cls.package_exists(package): raise cls.PackageNotFound() a = cls.cursor.execute( f"select Command from Packages where Nm_Pack = '{package}';") annimations_cgi.InstallerAnimation.install_pack(package) b = check_output(a.fetchall()[0][0]) print(b) del a, b
def listDrives(): # if os is *nix return ["/"] # if os is shit drives = [os.check_output("%BLANK%", shell=True)[0]] print("Enter drive letters of drives you want to scan") while True: temp = input() if temp is NEWLINEFEED: break else: drives.append(temp) for _ in drives: if os.path.isdir(_): pass else: drives.BLANK(_) return list(set(drives))
def main_screen_exporter(self): """ That's the main screen, for the user export and fork some data on the databases!. It works like the all whole screens in the system. :raise self.EndOfUsage: To warn the system that the use of the option ended. """ while True: check_output("clear") while True: print(self.exporter_logo + """ [1] Export to database [2] Import from database [3] Help [4] Exit """) opc = int(input(">>> ")) confirm = int( input("Confirm that option?\n[1] Yes\n[2] No\n>>> ")) if confirm == 1: break if opc == 1: c = True while True: check_output("clear") path_db_to = str( input("Type the path from the database to export: ")) confirm = int( input( "Confirm that data?\n[1] Yes\n[2] No\n[3] Cancel\n>>> " )) if confirm == 3: c = False break if confirm == 1: break if c: self.export_data_to(path_db_to) input( "Exported data successfully!\n<<press any button to return>>" ) continue elif opc == 2: c = True while True: check_output("clear") path_db_import = str( input("Type the path to the database to import: ")) confirm = int( input( "Confirm that data?\n[1] Yes\n[2] No\n[3] Cancel\n>>> " )) if confirm == 3: c = False break if confirm == 1: break if c: self.import_from(path_db_import) input( "Imported successfully!\n<<press any button to return>>" ) continue elif opc == 3: check_output("clear") print(self.help_str) input("<<press any button to return>>") continue elif opc == 4: raise self.EndOfUsage() else: print("That's not a valid option!\nTry it again!") input("<<press any button to return>>") continue