diff --git a/package.py b/package.py index 6f6ecb2..61c92f8 100644 --- a/package.py +++ b/package.py @@ -4,7 +4,7 @@ authors = ['John Su'] -version = '1.0.1' +version = '2.0.0' uuid = 'johnsu.rez-manager' @@ -34,4 +34,4 @@ def commands(): env.PATH.append('{root}/path') env.MANAGER_RESOURCES_FOLDER = '{root}/resources' - alias('manager', 'python -m rez_manager') + alias('rez-manager', 'python -m rez_manager') diff --git a/src/rez_manager/models.py b/src/rez_manager/models.py index 9c0a5bf..fb26ecb 100644 --- a/src/rez_manager/models.py +++ b/src/rez_manager/models.py @@ -5,7 +5,6 @@ from rez import packages from rez.config import config from rez.package_repository import package_repository_manager -from rez.package_copy import copy_package from .utils import catch_exception @@ -55,7 +54,6 @@ def generate_item_text(item): class RezPackagesModel(QtGui.QStandardItemModel): cookingStarted = QtCore.Signal() cookingEnded = QtCore.Signal() - packagesChanged = QtCore.Signal() def __init__(self, parent=None): self.repos = config.get('packages_path') @@ -110,19 +108,13 @@ def _make_row(self, row, family_name): def reload(self): self.logger.info('Reloading..') package_repository_manager.clear_caches() - family_names = set(f.name for f in packages.iter_package_families()) + family_names = list(set( + f.name for f in packages.iter_package_families() + )) self.setRowCount(len(family_names)) + family_names.sort(key=lambda x: x.lower()) for row, family_name in enumerate(family_names): self._make_row(row, family_name) self.logger.info(f'{len(family_names)} packages collected.') - - @catch_exception - def localise(self, packages): - local_repo = config.get('local_packages_path') - self.logger.info('Localising..') - for package in packages: - copy_package(package, local_repo, keep_timestamp=True) - self.logger.info(f'{len(packages)} packages localised.') - self.packagesChanged.emit() diff --git a/src/rez_manager/views.py b/src/rez_manager/views.py index d904057..9b390d3 100644 --- a/src/rez_manager/views.py +++ b/src/rez_manager/views.py @@ -6,6 +6,7 @@ import qtawesome as qta from Qt import QtWidgets, QtCore from rez.config import config +from rez.package_copy import copy_package from .utils import catch_exception @@ -45,8 +46,7 @@ def delete_local(packages, all_version: bool): class SpreadsheetView(QtWidgets.QTreeView): - packageDeleted = QtCore.Signal() - # packageLocalised = QtCore.Signal() + packagesChanged = QtCore.Signal() def __init__(self, parent=None): super(SpreadsheetView, self).__init__(parent) @@ -128,7 +128,7 @@ def _add_localise_package_menu( actions.append(menu.addAction( qta.icon('fa.cloud-download'), 'Localise', - partial(self.model().localise, to_localise) + partial(self.localise, to_localise) )) return actions @@ -155,7 +155,7 @@ def _add_multiple_packages_menu(self, menu, indexes): def on_delete_local(self, packages, all_version): self.logger.info('Deleting..') folders_deleted = delete_local(packages, all_version) - self.packageDeleted.emit() + self.packagesChanged.emit() self.logger.info('Folder(s) deleted:\n' + format_list(folders_deleted)) @catch_exception @@ -164,7 +164,7 @@ def delete_empty_folder(self, folders): for folder in folders: shutil.rmtree(folder) self.logger.info('Folder(s) deleted:\n' + format_list(folders)) - self.packageDeleted.emit() + self.packagesChanged.emit() @catch_exception def open_folder(self, index): @@ -178,11 +178,11 @@ def open_folder(self, index): ) os.startfile(folder) - # @catch_exception - # def localise(self, packages): - # local_repo = config.get('local_packages_path') - # self.logger.info('Localising..') - # for package in packages: - # copy_package(package, local_repo, keep_timestamp=True) - # self.logger.info(f'{len(packages)} packages localised.') - # self.packageLocalised.emit() + @catch_exception + def localise(self, packages): + local_repo = config.get('local_packages_path') + self.logger.info('Localising..') + for package in packages: + copy_package(package, local_repo, keep_timestamp=True) + self.logger.info(f'{len(packages)} packages localised.') + self.packagesChanged.emit() diff --git a/src/rez_manager/window.py b/src/rez_manager/window.py index b425559..e1f0b5b 100644 --- a/src/rez_manager/window.py +++ b/src/rez_manager/window.py @@ -41,16 +41,10 @@ def __init__(self): self.spreadsheet.model().reload() def _connect(self): - slot_reload = self.spreadsheet.model().reload - model = self.spreadsheet.model() - - self.spreadsheet.packageDeleted.connect( - partial(self.show_status_message, 'Deleted.') + self.spreadsheet.packagesChanged.connect( + self.spreadsheet.model().reload ) - self.spreadsheet.packageDeleted.connect(slot_reload) - model.packagesChanged.connect(slot_reload) - def setup_window(self): """Do the general ui setup work.""" # Layout