Fix: Renaming add-on directory and updating index.json
- Add-on directory name was not a proper identifier before. - index.json was formatted incorrectly (missing commas); new version is generated with updated generate-json.py (which seems to fail for addons_contrib at the moment), and contains data for add-ons in addons repo.
This commit is contained in:
80
package_manager/__init__.py
Normal file
80
package_manager/__init__.py
Normal file
@@ -0,0 +1,80 @@
|
||||
# ====================== BEGIN GPL LICENSE BLOCK ======================
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 3
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# ======================= END GPL LICENSE BLOCK ========================
|
||||
|
||||
bl_info = {
|
||||
"name": "Package Manager",
|
||||
"author": "Peter Cassetta",
|
||||
"version": (1, 0),
|
||||
"blender": (2, 77, 0),
|
||||
"location": "User Preferences > Add-ons > System: Package Manager",
|
||||
"description": "Download new add-ons and update current ones",
|
||||
"support": 'TESTING',
|
||||
"warning": "Early development",
|
||||
"wiki_url": "",
|
||||
"category": "System",
|
||||
}
|
||||
|
||||
|
||||
import bpy
|
||||
from bpy.types import Operator, AddonPreferences
|
||||
from bpy.props import StringProperty, BoolProperty, IntProperty, CollectionProperty
|
||||
|
||||
from . import networking
|
||||
|
||||
class PackageManagerAddon(bpy.types.PropertyGroup):
|
||||
source = StringProperty()
|
||||
name = StringProperty()
|
||||
description = StringProperty()
|
||||
author = StringProperty()
|
||||
wiki_url = StringProperty()
|
||||
tracker_url = StringProperty()
|
||||
location = StringProperty()
|
||||
category = StringProperty()
|
||||
version = StringProperty()
|
||||
blender = StringProperty()
|
||||
warning = StringProperty()
|
||||
support = StringProperty()
|
||||
filename = StringProperty()
|
||||
|
||||
class PackageManagerPreferences(AddonPreferences):
|
||||
# this must match the addon name, use '__package__'
|
||||
# when defining this in a submodule of a python package.
|
||||
bl_idname = __name__
|
||||
|
||||
pm_addons = CollectionProperty(type=PackageManagerAddon)
|
||||
|
||||
pm_addons_index = IntProperty()
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.operator("wm.update_index", text="Update List", icon='FILE_REFRESH')
|
||||
rows = 1 if len(self.pm_addons) == 0 else 6
|
||||
layout.template_list("UI_UL_list", "addons_list", self, "pm_addons",
|
||||
self, "pm_addons_index", rows=rows)
|
||||
|
||||
def register():
|
||||
networking.register()
|
||||
bpy.utils.register_class(PackageManagerAddon)
|
||||
bpy.utils.register_class(PackageManagerPreferences)
|
||||
|
||||
def unregister():
|
||||
networking.unregister()
|
||||
bpy.utils.unregister_class(PackageManagerAddon)
|
||||
bpy.utils.unregister_class(PackageManagerPreferences)
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
76
package_manager/networking.py
Normal file
76
package_manager/networking.py
Normal file
@@ -0,0 +1,76 @@
|
||||
# ====================== BEGIN GPL LICENSE BLOCK ======================
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 3
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# ======================= END GPL LICENSE BLOCK ========================
|
||||
|
||||
import bpy
|
||||
import json
|
||||
import urllib.request
|
||||
|
||||
|
||||
class UpdateIndex(bpy.types.Operator):
|
||||
"""Update the list of add-ons available for download"""
|
||||
bl_idname = "wm.update_index"
|
||||
bl_label = "Update list of add-ons"
|
||||
|
||||
def execute(self, context):
|
||||
try:
|
||||
req = urllib.request.urlopen("https://git.blender.org/gitweb/gitweb.cgi/"
|
||||
"blender-package-manager-addon.git/blob_plain/HEAD:/addons/index.json")
|
||||
index_file = req.read()
|
||||
del req
|
||||
except urllib.error.HTTPError as err:
|
||||
self.report({'ERROR'}, "Error requesting update: "
|
||||
+ str(err.code) + " " + err.reason)
|
||||
return {'CANCELLED'}
|
||||
|
||||
try:
|
||||
addon_list = json.loads(index_file)
|
||||
except ValueError:
|
||||
self.report({'ERROR'}, "Error: JSON file could not parse.")
|
||||
return {'CANCELLED'}
|
||||
|
||||
for addon_list["addons"] as name, content:
|
||||
addon = PackageManagerAddon()
|
||||
addon.name = name
|
||||
addon.source = content["source"]
|
||||
addon.description = content["description"]
|
||||
addon.author = content["author"]
|
||||
addon.wiki_url = content["wiki_url"]
|
||||
addon.tracker_url = content["tracker_url"]
|
||||
addon.location = content["location"]
|
||||
addon.category = content["category"]
|
||||
for content["version"] as item:
|
||||
# TODO: add multi-version functionality
|
||||
for item as version, value:
|
||||
addon.version = key
|
||||
addon.blender = value["blender"]
|
||||
addon.support = value["support"].upper()
|
||||
try:
|
||||
addon.warning = content["warning"]
|
||||
except Exception:
|
||||
pass
|
||||
addon.filename = value["filename"]
|
||||
|
||||
print(index_file)
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
def register():
|
||||
bpy.utils.register_class(UpdateIndex)
|
||||
|
||||
def unregister():
|
||||
bpy.utils.unregister_class(UpdateIndex)
|
Reference in New Issue
Block a user