Skip to content

Commit

Permalink
0.3 beta
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Titov committed Apr 14, 2020
1 parent e14a872 commit 3522bed
Show file tree
Hide file tree
Showing 14 changed files with 260 additions and 73 deletions.
4 changes: 3 additions & 1 deletion Package-Manager.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{"path": "C:/Users/MarkWilson/Documents/Houdini-Package-Manager"}
{
"path": "C:/Users/MarkWilson/Documents/Houdini-Package-Manager"
}
1 change: 1 addition & 0 deletions package.setup
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Package Manager",
"author": "Ivan Titov",
"version": "0.3-beta",
"source": "Houdini-Packages/Houdini-Package-Manager",
"source_type": "github"
}
19 changes: 0 additions & 19 deletions python2.7libs/package_manager/__main__.py

This file was deleted.

3 changes: 0 additions & 3 deletions python2.7libs/package_manager/choose_version_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
from PySide2.QtCore import *


# import hou


class ChooseVersionDialog(QDialog):
def __init__(self, parent=None):
super(ChooseVersionDialog, self).__init__(parent)
Expand Down
8 changes: 0 additions & 8 deletions python2.7libs/package_manager/core.py

This file was deleted.

23 changes: 11 additions & 12 deletions python2.7libs/package_manager/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
import hou
import requests

from .package import isPackage, NotPackageError, Package
from .local_package import isPackage, NotPackageError, LocalPackage
from .houdini_license import fullHoudiniLicenseName, HOUDINI_COMMERCIAL_LICENSE
from .choose_version_dialog import ChooseVersionDialog
from .version import Version
from .web_package import WebPackage


class RepoNotFound(Exception):
Expand Down Expand Up @@ -177,6 +178,7 @@ def updatePackageDataFile(repo_data, web_package, package_location, version, ver
data = json.load(file)
except (IOError, ValueError):
data = {}
web_package = web_package or WebPackage()
if not data.get('name'):
data['name'] = web_package.name or repo_data['name']
if not data.get('description'):
Expand Down Expand Up @@ -212,8 +214,12 @@ def downloadRepoZipArchive(repo_data, version=None, dst_location='$TEMP'):
return zip_file_path


def installFromGitHubRepo(web_package, dst_location='$HOUDINI_USER_PREF_DIR'):
repo_owner, repo_name = ownerAndRepoName(web_package.source)
def installFromGitHubRepo(web_package_or_link, dst_location='$HOUDINI_USER_PREF_DIR'):
if isinstance(web_package_or_link, WebPackage):
repo_owner, repo_name = ownerAndRepoName(web_package_or_link.source)
else:
repo_owner, repo_name = ownerAndRepoName(web_package_or_link)
web_package_or_link = None
api_repo_url = 'https://api.github.com/repos/{}/{}'.format(repo_owner, repo_name)
repo_data = GitHubAPICache.get(api_repo_url)
version = None
Expand All @@ -235,12 +241,5 @@ def installFromGitHubRepo(web_package, dst_location='$HOUDINI_USER_PREF_DIR'):
os.remove(zip_file) # Todo: optional
if len(versions) == 0:
version = repo_data['pushed_at']
updatePackageDataFile(repo_data, web_package, package_location, version, version_type)
Package.install(package_location)


def checkUpdates():
from .package import findInstalledPackages
for package in findInstalledPackages():
if package.source:
pass
updatePackageDataFile(repo_data, web_package_or_link, package_location, version, version_type)
LocalPackage.install(package_location)
2 changes: 1 addition & 1 deletion python2.7libs/package_manager/houdini_license.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ def fullHoudiniLicenseName(name_or_lic):
HOUDINI_INDIE_LICENSE: u'Indie',
HOUDINI_EDUCATION_LICENSE: u'Education',
HOUDINI_APPRENTICE_LICENSE: u'Apprentice'
}[lic]
}.get(lic)
85 changes: 85 additions & 0 deletions python2.7libs/package_manager/install_local_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
try:
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
except ImportError:
from PySide2.QtWidgets import *
from PySide2.QtGui import *
from PySide2.QtCore import *

import hou


class FolderField(QWidget):
def __init__(self, content=''):
super(FolderField, self).__init__()

layout = QHBoxLayout(self)
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(4)

self.edit = QLineEdit(content)
layout.addWidget(self.edit)

self.pick_folder_button = QPushButton()
self.pick_folder_button.setToolTip('Pick location')
self.pick_folder_button.setFixedSize(24, 24)
self.pick_folder_button.setIcon(hou.qt.Icon('BUTTONS_chooser_folder', 16, 16))
self.pick_folder_button.clicked.connect(self._pickLocation)
layout.addWidget(self.pick_folder_button)

def text(self):
return self.edit.text()

def path(self):
return hou.expandString(self.edit.text())

def _pickLocation(self):
path = QFileDialog.getExistingDirectory(self, 'Package Folder', self.path())
if path:
path = path.replace('\\', '/')
self.edit.setText(path)


class InstallFromFolderPathDialog(QDialog):
def __init__(self, parent=None):
super(InstallFromFolderPathDialog, self).__init__(parent)

self.setWindowTitle('Install from Local Folder')
self.resize(500, 50)

# Layout
main_layout = QVBoxLayout(self)
main_layout.setContentsMargins(4, 4, 4, 4)
main_layout.setSpacing(4)

form_layout = QFormLayout()
form_layout.setContentsMargins(4, 0, 0, 2)
form_layout.setSpacing(4)
main_layout.addLayout(form_layout)

self.folder_path_field = FolderField()
form_layout.addRow('Folder Path', self.folder_path_field)

self.setup_scheme_combo = QComboBox()
self.setup_scheme_combo.setDisabled(True)
form_layout.addRow('Setup Scheme', self.setup_scheme_combo)

buttons_layout = QHBoxLayout()
main_layout.addLayout(buttons_layout)

spacer = QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Ignored)
buttons_layout.addSpacerItem(spacer)

ok_button = QPushButton('OK')
ok_button.clicked.connect(self.accept)
buttons_layout.addWidget(ok_button)

cancel_button = QPushButton('Cancel')
cancel_button.clicked.connect(self.reject)
buttons_layout.addWidget(cancel_button)

@classmethod
def getInstallationData(cls, parent=None):
dialog = cls(parent)
return dialog.exec_(), dialog.folder_path_field.text()
56 changes: 56 additions & 0 deletions python2.7libs/package_manager/install_web_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
try:
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
except ImportError:
from PySide2.QtWidgets import *
from PySide2.QtGui import *
from PySide2.QtCore import *


class InstallFromWebLinkDialog(QDialog):
def __init__(self, parent=None):
super(InstallFromWebLinkDialog, self).__init__(parent)

self.setWindowTitle('Install from Web Link')
self.resize(500, 50)

main_layout = QVBoxLayout(self)
main_layout.setContentsMargins(4, 4, 4, 4)
main_layout.setSpacing(4)

supported_links = QLabel('Currently, only GitHub repositories are supported')
supported_links.setAlignment(Qt.AlignCenter)
main_layout.addWidget(supported_links)

form_layout = QFormLayout()
form_layout.setContentsMargins(4, 0, 0, 2)
form_layout.setSpacing(4)
main_layout.addLayout(form_layout)

self.web_link_field = QLineEdit()
self.web_link_field.setPlaceholderText('https://github.com/Houdini-Packages/Houdini-Package-Manager')
form_layout.addRow('Web Link', self.web_link_field)

self.setup_scheme_combo = QComboBox()
self.setup_scheme_combo.setDisabled(True)
form_layout.addRow('Setup Scheme', self.setup_scheme_combo)

buttons_layout = QHBoxLayout()
main_layout.addLayout(buttons_layout)

spacer = QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Ignored)
buttons_layout.addSpacerItem(spacer)

ok_button = QPushButton('OK')
ok_button.clicked.connect(self.accept)
buttons_layout.addWidget(ok_button)

cancel_button = QPushButton('Cancel')
cancel_button.clicked.connect(self.reject)
buttons_layout.addWidget(cancel_button)

@classmethod
def getInstallationData(cls, parent=None):
dialog = cls(parent)
return dialog.exec_(), dialog.web_link_field.text()
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def findFiles(path, ignore_folders=True, recursive=False):
break


class Package:
class LocalPackage:
def __init__(self, package_file):
self.package_file = os.path.normpath(package_file).replace('\\', '/')

Expand Down Expand Up @@ -283,4 +283,4 @@ def jsonsFromFolderAlphabetical(path):

# Todo: support dynamic setting of the package dir if possible

return tuple(Package(path) for path in json_paths)
return tuple(LocalPackage(path) for path in json_paths)
29 changes: 20 additions & 9 deletions python2.7libs/package_manager/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@

import hou

from .package import Package, findInstalledPackages
from .local_package import LocalPackage, findInstalledPackages
from .package_list import *
from .package_content import *
from .web_package_list import *
from .web_package_content import WebPackageInfoView
from .github import GitHubAPICache
from .github import GitHubAPICache, installFromGitHubRepo
from .settings import SettingsWidget
from .install_web_dialog import InstallFromWebLinkDialog
from .install_local_dialog import InstallFromFolderPathDialog


class MainWindow(QWidget):
Expand All @@ -38,11 +40,11 @@ def __init__(self, parent=None):
main_layout.addLayout(top_layout)

local_install_button = QPushButton('Install Local Package')
local_install_button.clicked.connect(self.chooseAndInstallPackageFolder)
local_install_button.clicked.connect(self.pickAndInstallPackageFolder)
top_layout.addWidget(local_install_button)

web_install_button = QPushButton('Install Web Package')
web_install_button.clicked.connect(lambda: print)
web_install_button.clicked.connect(self.installPackageFromWebLink)
top_layout.addWidget(web_install_button)

top_spacer = QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Ignored)
Expand Down Expand Up @@ -190,12 +192,21 @@ def updateContentSource(self):
def updateWebContentSource(self):
self.web_info_view.setWebPackage(self.current_web_package)

def chooseAndInstallPackageFolder(self):
path = QFileDialog.getExistingDirectory(self, 'Package Folder')
if not path: # Canceled
return
Package.install(path)
def pickAndInstallPackageFolder(self):
ok, path = InstallFromFolderPathDialog.getInstallationData(self)
if ok and path:
LocalPackage.install(path)
self.updateLocalPackageList()
hou.ui.setStatusMessage('Successfully installed',
hou.severityType.ImportantMessage)

def installPackageFromWebLink(self):
ok, link = InstallFromWebLinkDialog.getInstallationData(self)
if ok and link:
installFromGitHubRepo(link)
self.updateLocalPackageList()
hou.ui.setStatusMessage('Successfully installed',
hou.severityType.ImportantMessage)

def _setCurrentPackage(self, index):
package = index.data(Qt.UserRole)
Expand Down
1 change: 1 addition & 0 deletions python2.7libs/package_manager/package_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def __init__(self):

# Update
self.update_group = QGroupBox('Update')
self.update_group.hide()
self.update_group.setDisabled(True)
main_layout.addWidget(self.update_group)

Expand Down
Loading

0 comments on commit 3522bed

Please sign in to comment.