mirror of
https://github.com/Snigdha-OS/snigdhaos-blackbox.git
synced 2025-09-22 04:25:04 +02:00
add on_packages_import_clicked()
This commit is contained in:

committed by
GitHub

parent
03a2abf7dc
commit
d08b08a82d
@@ -517,4 +517,109 @@ class Main(Gtk.Window): # Basic OOPS Concept
|
|||||||
message_dialog.show_all()
|
message_dialog.show_all()
|
||||||
message_dialog.run()
|
message_dialog.run()
|
||||||
message_dialog.hide()
|
message_dialog.hide()
|
||||||
message_dialog.destroy()
|
message_dialog.destroy()
|
||||||
|
|
||||||
|
def recache_clicked(self, widget):
|
||||||
|
fn.logger.info("Recache applications - start")
|
||||||
|
fn.cache_btn()
|
||||||
|
|
||||||
|
def on_package_search_clicked(self, widget):
|
||||||
|
fn.logger.debug("Showing Package Search window")
|
||||||
|
self.toggle_popover()
|
||||||
|
package_search_win = PackageSearchWindow()
|
||||||
|
package_search_win.show_all()
|
||||||
|
|
||||||
|
# def on_arcolinux_iso_packages_clicked(self, widget):
|
||||||
|
# fn.logger.debug("Showing ArcoLinux ISO Packages window")
|
||||||
|
# arcolinux_iso_packages_window = ISOPackagesWindow()
|
||||||
|
# arcolinux_iso_packages_window.show()
|
||||||
|
|
||||||
|
def on_about_app_clicked(self, widget):
|
||||||
|
fn.logger.debug("Showing About dialog")
|
||||||
|
self.toggle_popover()
|
||||||
|
about = AboutDialog()
|
||||||
|
about.run()
|
||||||
|
about.hide()
|
||||||
|
about.destroy()
|
||||||
|
|
||||||
|
def on_packages_export_clicked(self, widget):
|
||||||
|
self.toggle_popover()
|
||||||
|
dialog_packagelist = PackageListDialog()
|
||||||
|
dialog_packagelist.show_all()
|
||||||
|
|
||||||
|
def on_packages_import_clicked(self, widget):
|
||||||
|
self.toggle_popover()
|
||||||
|
try:
|
||||||
|
if not os.path.exists(fn.pacman_lockfile):
|
||||||
|
package_file = "%s/packages-x86_64.txt" % (fn.export_dir,)
|
||||||
|
package_import_logfile = "%spackages-install-status-%s-%s.log" % (
|
||||||
|
fn.log_dir,
|
||||||
|
fn.datetime.today().date(),
|
||||||
|
fn.datetime.today().time().strftime("%H-%M-%S"),
|
||||||
|
)
|
||||||
|
if os.path.exists(package_file):
|
||||||
|
# check we have a valid file
|
||||||
|
lines = None
|
||||||
|
with open(package_file, encoding="utf-8", mode="r") as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
if lines is not None:
|
||||||
|
if (
|
||||||
|
"# This file was auto-generated by the ArchLinux Tweak Tool on"
|
||||||
|
in lines[0]
|
||||||
|
or "# This file was auto-generated by Blackbox on"
|
||||||
|
in lines[0]
|
||||||
|
):
|
||||||
|
fn.logger.info("Package list file is valid")
|
||||||
|
packages_list = []
|
||||||
|
for line in lines:
|
||||||
|
if not line.startswith("#"):
|
||||||
|
packages_list.append(line.strip())
|
||||||
|
|
||||||
|
if len(packages_list) > 0:
|
||||||
|
dialog_package_import = PackagesImportDialog(
|
||||||
|
package_file,
|
||||||
|
packages_list,
|
||||||
|
package_import_logfile,
|
||||||
|
)
|
||||||
|
dialog_package_import.show_all()
|
||||||
|
|
||||||
|
else:
|
||||||
|
message_dialog = MessageDialog(
|
||||||
|
"Error",
|
||||||
|
"Package file is not valid %s" % package_file,
|
||||||
|
"Export a list of packages first using the Show Installed Packages button",
|
||||||
|
"",
|
||||||
|
"error",
|
||||||
|
False,
|
||||||
|
)
|
||||||
|
|
||||||
|
message_dialog.show_all()
|
||||||
|
message_dialog.run()
|
||||||
|
message_dialog.hide()
|
||||||
|
else:
|
||||||
|
message_dialog = MessageDialog(
|
||||||
|
"Warning",
|
||||||
|
"Cannot locate export package file %s" % package_file,
|
||||||
|
"Export a list of packages first using the Show Installed Packages button",
|
||||||
|
"",
|
||||||
|
"warning",
|
||||||
|
False,
|
||||||
|
)
|
||||||
|
|
||||||
|
message_dialog.show_all()
|
||||||
|
message_dialog.run()
|
||||||
|
message_dialog.hide()
|
||||||
|
else:
|
||||||
|
message_dialog = MessageDialog(
|
||||||
|
"Error",
|
||||||
|
"Pacman lock file found %s" % fn.pacman_lockfile,
|
||||||
|
"Cannot proceed, another pacman process is running",
|
||||||
|
"",
|
||||||
|
"error",
|
||||||
|
False,
|
||||||
|
)
|
||||||
|
message_dialog.show_all()
|
||||||
|
message_dialog.run()
|
||||||
|
message_dialog.hide()
|
||||||
|
except Exception as e:
|
||||||
|
fn.logger.error("Exception in on_packages_import_clicked(): %s" % e)
|
Reference in New Issue
Block a user