Skip to content

Commit

Permalink
2.0.0 rolled back the structure adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
suxiaojiang committed Mar 21, 2021
1 parent b7e900b commit 977c37b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 35 deletions.
4 changes: 2 additions & 2 deletions package.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

authors = ['John Su']

version = '1.0.1'
version = '2.0.0'

uuid = 'johnsu.rez-manager'

Expand Down Expand Up @@ -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')
16 changes: 4 additions & 12 deletions src/rez_manager/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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()
26 changes: 13 additions & 13 deletions src/rez_manager/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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):
Expand All @@ -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()
10 changes: 2 additions & 8 deletions src/rez_manager/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 977c37b

Please sign in to comment.