Some stuff from old exception-based error handling approach
This commit is contained in:
@@ -10,12 +10,17 @@ from . import bpackage as bpkg
|
||||
|
||||
class RepositoryProperty(PropertyGroup):
|
||||
url = bpy.props.StringProperty(name="URL")
|
||||
# status = bpy.props.EnumProperty(name="Status")
|
||||
status = bpy.props.EnumProperty(name="Status", items=[
|
||||
("OK", "Okay", "FILE_TICK"),
|
||||
("NOTFOUND", "Not found", "ERROR"),
|
||||
("NOCONNECT", "Could not connect", "QUESTION"),
|
||||
])
|
||||
|
||||
|
||||
class PACKAGE_UL_repositories(UIList):
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||
split = layout.split(0.3)
|
||||
split.label(item.status)
|
||||
split.prop(item, "name")
|
||||
split.prop(item, "url")
|
||||
|
||||
@@ -42,29 +47,34 @@ class PackagePreferences(AddonPreferences):
|
||||
|
||||
@subprocess_operator
|
||||
class PACKAGE_OT_refresh(Operator):
|
||||
"""
|
||||
Operator which checks for updates to known package lists
|
||||
"""
|
||||
"""Check for new and updated packages"""
|
||||
bl_idname = "package.refresh"
|
||||
bl_label = "Refresh package list(s)"
|
||||
bl_label = "Refresh Packages"
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
def invoke(self, context, event):
|
||||
prefs = context.user_preferences.addons[__package__].preferences
|
||||
|
||||
if 'repositories' not in prefs:
|
||||
if 'repositories' not in prefs or len(prefs['repositories']) <= 0:
|
||||
self.log.debug(prefs)
|
||||
self.report({'WARNING'}, "No respositories to refresh")
|
||||
return {'FINISHED'}
|
||||
|
||||
# HACK: just do the active repo for now
|
||||
# HACK: just use the active repo until we do multi-repo support
|
||||
repo = bpkg.Repository(prefs['repositories'][prefs.active_repository].to_dict())
|
||||
|
||||
self.proc_kwargs = {'target': subprocess_function(repo.refresh, pipe=self.pipe)}
|
||||
|
||||
return {'RUNNING_MODAL'}
|
||||
|
||||
def modal(self, context, event):
|
||||
# try:
|
||||
self.poll_subprocess()
|
||||
# except:
|
||||
try:
|
||||
self.poll_subprocess()
|
||||
except bpkg.repository.MissingURLError:
|
||||
self.report({'WARNING'}, "No URL specified")
|
||||
|
||||
|
||||
return {'RUNNING_MODAL'}
|
||||
|
||||
def handle_response(self, resp):
|
||||
|
Reference in New Issue
Block a user