Fix bugs, add checks and enable configuration of default module packs source on first time start.
This commit is contained in:
@@ -719,8 +719,7 @@ class ConditionClauseWidget(QtWidgets.QFrame):
|
||||
newItem = QtWidgets.QTreeWidgetItem()
|
||||
newItem.setText(0, entityDropdownTriplet[0])
|
||||
newItem.setText(1, entityDropdownTriplet[1])
|
||||
resizedIcon = resizePictureFromBuffer(entityDropdownTriplet[2], (40, 40))
|
||||
newItem.setIcon(2, resizedIcon)
|
||||
newItem.setIcon(2, entityDropdownTriplet[2])
|
||||
graphEntitiesDropdown.addTopLevelItem(newItem)
|
||||
|
||||
self.gcSecondaryInputLayout.addWidget(graphEntitiesDropdown)
|
||||
|
||||
@@ -124,8 +124,9 @@ class ModulesManager:
|
||||
|
||||
self.mainWindow.RESOURCEHANDLER.loadModuleAssets(modulePath)
|
||||
moduleEntities = self.mainWindow.RESOURCEHANDLER.loadModuleEntities(modulePath)
|
||||
moduleResolutions = self.mainWindow.RESOLUTIONMANAGER.loadResolutionsFromDir(
|
||||
modulePath / "Resolutions")
|
||||
moduleResolutionsDir = modulePath / "Resolutions"
|
||||
moduleResolutions = self.mainWindow.RESOLUTIONMANAGER.loadResolutionsFromDir(moduleResolutionsDir) \
|
||||
if moduleResolutionsDir.exists() else []
|
||||
self.loadedModules[f"{modulePath.parent.name} | {moduleName}"] = \
|
||||
{'author': author, 'version': version, 'name': moduleName, 'description': description,
|
||||
'entities': moduleEntities, 'resolutions': moduleResolutions}
|
||||
@@ -235,6 +236,15 @@ class ModulesManager:
|
||||
self.mainWindow.MESSAGEHANDLER.error(f'Could not sync source {sourceURI}: {gitErr}',
|
||||
popUp=True, exc_info=True)
|
||||
return False
|
||||
except ValueError:
|
||||
# Force update the local repo.
|
||||
repo = pygit2.Repository(destinationPath)
|
||||
remote = repo.remotes['origin']
|
||||
current_branch_name = repo.head.shorthand
|
||||
remote.fetch()
|
||||
remote_branch = repo.lookup_reference(f'refs/remotes/origin/{current_branch_name}')
|
||||
repo.reset(remote_branch.target, pygit2.GIT_RESET_HARD)
|
||||
|
||||
else:
|
||||
try:
|
||||
shutil.copytree(Path(sourceURI), destinationPath, dirs_exist_ok=True)
|
||||
@@ -836,8 +846,9 @@ class InstallRequirementsThread(QtCore.QThread):
|
||||
for module in packDetails['modules']:
|
||||
modulePath = self.modulesManager.modulesBaseDirectoryPath / self.sourceUUID / module
|
||||
moduleRequirements = modulePath / 'requirements.txt'
|
||||
with open(moduleRequirements, 'r') as file:
|
||||
[requirementsSet.add(line) for line in file.read().splitlines() if not line.startswith('#')]
|
||||
if moduleRequirements.exists():
|
||||
with open(moduleRequirements, 'r') as file:
|
||||
[requirementsSet.add(line) for line in file.read().splitlines() if not line.startswith('#')]
|
||||
|
||||
with open(self.modulesManager.modulesRequirementsPath, 'r') as reqFile:
|
||||
[requirementsSet.add(line) for line in reqFile.read().splitlines() if not line.startswith('#')]
|
||||
|
||||
@@ -42,6 +42,7 @@ def resizePictureFromBuffer(picBuffer: QByteArray, newSize: tuple) -> QByteArray
|
||||
|
||||
return pictureByteArray
|
||||
|
||||
|
||||
def resizeSVG(byteString: bytes, resize: tuple):
|
||||
bytesWidth = str(resize[0]).encode('UTF-8')
|
||||
bytesHeight = str(resize[1]).encode('UTF-8')
|
||||
@@ -138,10 +139,10 @@ class ResourceHandler:
|
||||
thumbnail.save(imageBuffer, "PNG")
|
||||
imageBuffer.close()
|
||||
except ValueError as ve:
|
||||
# Image type is unsupported (for ImageQt)
|
||||
# Supported types: 1, L, P, RGB, RGBA
|
||||
self.mainWindow.MESSAGEHANDLER.warning(f'Invalid Image selected: {str(ve)}', popUp=True)
|
||||
pictureByteArray = None
|
||||
# Image type is unsupported (for ImageQt)
|
||||
# Supported types: 1, L, P, RGB, RGBA
|
||||
self.mainWindow.MESSAGEHANDLER.warning(f'Invalid Image selected: {str(ve)}', popUp=True)
|
||||
pictureByteArray = None
|
||||
|
||||
return pictureByteArray
|
||||
|
||||
@@ -289,14 +290,17 @@ class ResourceHandler:
|
||||
def loadModuleEntities(self, modulePath: Path) -> list:
|
||||
entitiesPath = modulePath / 'Entities'
|
||||
allModuleEntitiesAdded = []
|
||||
for entFile in listdir(entitiesPath):
|
||||
if entFile.endswith('.xml'):
|
||||
allModuleEntitiesAdded += self.addRecognisedEntityTypes(entitiesPath / entFile)
|
||||
if entitiesPath.exists():
|
||||
for entFile in listdir(entitiesPath):
|
||||
if entFile.endswith('.xml'):
|
||||
allModuleEntitiesAdded += self.addRecognisedEntityTypes(entitiesPath / entFile)
|
||||
return allModuleEntitiesAdded
|
||||
|
||||
def loadModuleAssets(self, modulePath: Path):
|
||||
self.moduleAssetPaths.append(modulePath / "Assets")
|
||||
self.loadModuleBanners(modulePath)
|
||||
moduleAssetsPath = modulePath / "Assets"
|
||||
if moduleAssetsPath.exists():
|
||||
self.moduleAssetPaths.append(moduleAssetsPath)
|
||||
self.loadModuleBanners(modulePath)
|
||||
|
||||
def getEntityJson(self, entityType: str, jsonData=None) -> Union[dict, None]:
|
||||
eJson = {'uid': str(uuid4())}
|
||||
|
||||
@@ -1912,8 +1912,9 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
|
||||
if self.SETTINGS.value("Program/Usage/First Time Start", 'true') == 'true':
|
||||
FirstTimeUseDialog().exec()
|
||||
#self.MODULEMANAGER.installSource({'URI': '', 'Remote': '', 'AuthType': None,
|
||||
# 'AuthCreds': None, 'SchemaType': '', 'UUID': str(uuid4())})
|
||||
# Technically no need to give the full dict, but it doesn't hurt.
|
||||
self.MODULEMANAGER.installSource({'URI': 'https://github.com/AccentuSoft/LinkScope-Module-Packs',
|
||||
'Remote': True, 'Auth': None, 'SchemaType': 3, 'UUID': str(uuid4())})
|
||||
self.SETTINGS.setValue("Program/Usage/First Time Start", 'false')
|
||||
|
||||
if self.UPDATEMANAGER.isUpdateAvailable():
|
||||
|
||||
Reference in New Issue
Block a user