initial (2017) commit
This commit is contained in:
26
__init__.py
Normal file
26
__init__.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
bl_info = {
|
||||||
|
'name': 'Package Manager',
|
||||||
|
'description': 'Testing package management',
|
||||||
|
'category': 'System',
|
||||||
|
'support': 'TESTING',
|
||||||
|
}
|
||||||
|
import bpy
|
||||||
|
|
||||||
|
class PackageSettings(bpy.types.PropertyGroup):
|
||||||
|
url = bpy.props.StringProperty(name="URL")
|
||||||
|
|
||||||
|
def register():
|
||||||
|
from . import (pkg_ops, pkg_ui)
|
||||||
|
|
||||||
|
bpy.utils.register_class(PackageSettings)
|
||||||
|
bpy.types.WindowManager.PackageManagerSettings = bpy.props.PointerProperty(type=PackageSettings)
|
||||||
|
pkg_ops.register()
|
||||||
|
pkg_ui.register()
|
||||||
|
|
||||||
|
def unregister():
|
||||||
|
from . import (pkg_ops, pkg_ui)
|
||||||
|
|
||||||
|
pkg_ops.unregister()
|
||||||
|
pkg_ui.unregister();
|
||||||
|
del bpy.types.WindowManager.PackageManagerSettings
|
||||||
|
|
12
blenderpack.py
Normal file
12
blenderpack.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# HACK: seems 'requests' module bundled with blender isn't bundled with 'idna' module. So force system python for now
|
||||||
|
import sys
|
||||||
|
sys.path.insert(0, '/usr/lib/python3.6/site-packages')
|
||||||
|
import requests
|
||||||
|
|
||||||
|
def fetch(url):
|
||||||
|
# TODO: do conditional request
|
||||||
|
re = requests.get(url)
|
||||||
|
print(re.json())
|
||||||
|
|
21
pkg_ops.py
Normal file
21
pkg_ops.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import bpy
|
||||||
|
from multiprocessing import Process
|
||||||
|
from . import blenderpack
|
||||||
|
|
||||||
|
class PACKAGE_OT_fetch_lists(bpy.types.Operator):
|
||||||
|
bl_idname = "package.fetch_lists"
|
||||||
|
bl_label = "Update package list(s)"
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
settings = context.window_manager.PackageManagerSettings
|
||||||
|
proc = Process(target=lambda: blenderpack.fetch(settings.url))
|
||||||
|
proc.start()
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
|
def register():
|
||||||
|
bpy.utils.register_class(PACKAGE_OT_fetch_lists)
|
||||||
|
|
||||||
|
def unregister():
|
||||||
|
bpy.utils.unregister_class(PACKAGE_OT_fetch_lists)
|
||||||
|
|
26
pkg_ui.py
Normal file
26
pkg_ui.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import bpy
|
||||||
|
from . import pkg_ops
|
||||||
|
|
||||||
|
class USERPREF_PT_packages(bpy.types.Panel):
|
||||||
|
bl_label = "Package Management"
|
||||||
|
bl_space_type = 'USER_PREFERENCES'
|
||||||
|
bl_region_type = 'WINDOW'
|
||||||
|
bl_options = {'HIDE_HEADER'}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
userpref = context.user_preferences
|
||||||
|
return (userpref.active_section == 'PACKAGES')
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(context.window_manager.PackageManagerSettings, "url")
|
||||||
|
row.operator(pkg_ops.PACKAGE_OT_fetch_lists.bl_idname, text="Fetch")
|
||||||
|
|
||||||
|
def register():
|
||||||
|
bpy.utils.register_class(USERPREF_PT_packages)
|
||||||
|
|
||||||
|
def unregister():
|
||||||
|
bpy.utils.unregister_class(USERPREF_PT_packages)
|
Reference in New Issue
Block a user