netrender: fix reload
authorMartin Poirier <theeth@yahoo.com>
Sat, 31 Jul 2010 19:23:22 +0000 (19:23 +0000)
committerMartin Poirier <theeth@yahoo.com>
Sat, 31 Jul 2010 19:23:22 +0000 (19:23 +0000)
Note: this is tested and work with metaclass registering. If it doesn't work with registering lists (as currently in svn), I can still commit the metaclass method...

release/scripts/io/netrender/__init__.py
release/scripts/io/netrender/ui.py

index 43f3094e628e227b25d1ddcdb76fc90348969e42..5a705e95aa82393030a3c00a3b6af3a1339f01d2 100644 (file)
 
 # This directory is a Python package.
 
-from netrender import model
-from netrender import operators
-from netrender import client
-from netrender import slave
-from netrender import master
-from netrender import master_html
-from netrender import utils
-from netrender import balancing
-from netrender import ui
-from netrender import repath
+# To support reload properly, try to access a package var, if it's there, reload everything
+try:
+    init_data
+
+    reload(model)
+    reload(operators)
+    reload(client)
+    reload(slave)
+    reload(master)
+    reload(master_html)
+    reload(utils)
+    reload(balancing)
+    reload(ui)
+    reload(repath)
+except:
+    from netrender import model
+    from netrender import operators
+    from netrender import client
+    from netrender import slave
+    from netrender import master
+    from netrender import master_html
+    from netrender import utils
+    from netrender import balancing
+    from netrender import ui
+    from netrender import repath
 
 jobs = []
 slaves = []
@@ -38,14 +53,10 @@ init_data = True
 init_address = True
 
 def register():
-    pass # TODO
+    ui.addProperties()
+    
 
 def unregister():
     import bpy
-
     bpy.types.Scene.RemoveProperty("network_render")
 
-    bpy.types.unregister(ui.NetRenderJob)
-    bpy.types.unregister(ui.NetRenderSettings)
-    bpy.types.unregister(ui.NetRenderSlave)
-
index c60b10c484a27dd985aba8673ca3975ab76f85aa..c82a031100b28c16389e942add95118a694d61b0 100644 (file)
@@ -337,138 +337,139 @@ class NetRenderSlave(bpy.types.IDPropertyGroup):
 class NetRenderJob(bpy.types.IDPropertyGroup):
     pass
 
-bpy.types.Scene.PointerProperty(attr="network_render", type=NetRenderSettings, name="Network Render", description="Network Render Settings")
-
-NetRenderSettings.StringProperty( attr="server_address",
-                name="Server address",
-                description="IP or name of the master render server",
-                maxlen = 128,
-                default = "[default]")
-
-NetRenderSettings.IntProperty( attr="server_port",
-                name="Server port",
-                description="port of the master render server",
-                default = 8000,
-                min=1,
-                max=65535)
-
-NetRenderSettings.BoolProperty( attr="master_broadcast",
-                name="Broadcast",
-                description="broadcast master server address on local network",
-                default = True)
-
-NetRenderSettings.BoolProperty( attr="slave_clear",
-                name="Clear on exit",
-                description="delete downloaded files on exit",
-                default = True)
-
-NetRenderSettings.BoolProperty( attr="slave_thumb",
-                name="Generate thumbnails",
-                description="Generate thumbnails on slaves instead of master",
-                default = False)
-
-NetRenderSettings.BoolProperty( attr="slave_outputlog",
-                name="Output render log on console",
-                description="Output render text log to console as well as sending it to the master",
-                default = True)
-
-NetRenderSettings.BoolProperty( attr="master_clear",
-                name="Clear on exit",
-                description="delete saved files on exit",
-                default = False)
-
-default_path = os.environ.get("TEMP")
-
-if not default_path:
-    if os.name == 'nt':
-        default_path = "c:/tmp/"
-    else:
-        default_path = "/tmp/"
-elif not default_path.endswith(os.sep):
-    default_path += os.sep
-
-NetRenderSettings.StringProperty( attr="path",
-                name="Path",
-                description="Path for temporary files",
-                maxlen = 128,
-                default = default_path,
-                subtype='FILE_PATH')
-
-NetRenderSettings.StringProperty( attr="job_name",
-                name="Job name",
-                description="Name of the job",
-                maxlen = 128,
-                default = "[default]")
-
-NetRenderSettings.StringProperty( attr="job_category",
-                name="Job category",
-                description="Category of the job",
-                maxlen = 128,
-                default = "")
-
-NetRenderSettings.IntProperty( attr="chunks",
-                name="Chunks",
-                description="Number of frame to dispatch to each slave in one chunk",
-                default = 5,
-                min=1,
-                max=65535)
-
-NetRenderSettings.IntProperty( attr="priority",
-                name="Priority",
-                description="Priority of the job",
-                default = 1,
-                min=1,
-                max=10)
-
-NetRenderSettings.StringProperty( attr="job_id",
-                name="Network job id",
-                description="id of the last sent render job",
-                maxlen = 64,
-                default = "")
-
-NetRenderSettings.IntProperty( attr="active_slave_index",
-                name="Index of the active slave",
-                description="",
-                default = -1,
-                min= -1,
-                max=65535)
-
-NetRenderSettings.IntProperty( attr="active_blacklisted_slave_index",
-                name="Index of the active slave",
-                description="",
-                default = -1,
-                min= -1,
-                max=65535)
-
-NetRenderSettings.IntProperty( attr="active_job_index",
-                name="Index of the active job",
-                description="",
-                default = -1,
-                min= -1,
-                max=65535)
-
-NetRenderSettings.EnumProperty(attr="mode",
-                        items=(
-                                        ("RENDER_CLIENT", "Client", "Act as render client"),
-                                        ("RENDER_MASTER", "Master", "Act as render master"),
-                                        ("RENDER_SLAVE", "Slave", "Act as render slave"),
-                                    ),
-                        name="Network mode",
-                        description="Mode of operation of this instance",
-                        default="RENDER_CLIENT")
-
-NetRenderSettings.CollectionProperty(attr="slaves", type=NetRenderSlave, name="Slaves", description="")
-NetRenderSettings.CollectionProperty(attr="slaves_blacklist", type=NetRenderSlave, name="Slaves Blacklist", description="")
-NetRenderSettings.CollectionProperty(attr="jobs", type=NetRenderJob, name="Job List", description="")
-
-NetRenderSlave.StringProperty( attr="name",
-                name="Name of the slave",
-                description="",
-                maxlen = 64,
-                default = "")
-
-NetRenderJob.StringProperty( attr="name",
-                name="Name of the job",
-                description="",
-                maxlen = 128,
-                default = "")
+def addProperties():
+    bpy.types.Scene.PointerProperty(attr="network_render", type=NetRenderSettings, name="Network Render", description="Network Render Settings")
+    
+    NetRenderSettings.StringProperty( attr="server_address",
+                    name="Server address",
+                    description="IP or name of the master render server",
+                    maxlen = 128,
+                    default = "[default]")
+    
+    NetRenderSettings.IntProperty( attr="server_port",
+                    name="Server port",
+                    description="port of the master render server",
+                    default = 8000,
+                    min=1,
+                    max=65535)
+    
+    NetRenderSettings.BoolProperty( attr="master_broadcast",
+                    name="Broadcast",
+                    description="broadcast master server address on local network",
+                    default = True)
+    
+    NetRenderSettings.BoolProperty( attr="slave_clear",
+                    name="Clear on exit",
+                    description="delete downloaded files on exit",
+                    default = True)
+    
+    NetRenderSettings.BoolProperty( attr="slave_thumb",
+                    name="Generate thumbnails",
+                    description="Generate thumbnails on slaves instead of master",
+                    default = False)
+    
+    NetRenderSettings.BoolProperty( attr="slave_outputlog",
+                    name="Output render log on console",
+                    description="Output render text log to console as well as sending it to the master",
+                    default = True)
+    
+    NetRenderSettings.BoolProperty( attr="master_clear",
+                    name="Clear on exit",
+                    description="delete saved files on exit",
+                    default = False)
+    
+    default_path = os.environ.get("TEMP")
+    
+    if not default_path:
+        if os.name == 'nt':
+            default_path = "c:/tmp/"
+        else:
+            default_path = "/tmp/"
+    elif not default_path.endswith(os.sep):
+        default_path += os.sep
+    
+    NetRenderSettings.StringProperty( attr="path",
+                    name="Path",
+                    description="Path for temporary files",
+                    maxlen = 128,
+                    default = default_path,
+                    subtype='FILE_PATH')
+    
+    NetRenderSettings.StringProperty( attr="job_name",
+                    name="Job name",
+                    description="Name of the job",
+                    maxlen = 128,
+                    default = "[default]")
+    
+    NetRenderSettings.StringProperty( attr="job_category",
+                    name="Job category",
+                    description="Category of the job",
+                    maxlen = 128,
+                    default = "")
+    
+    NetRenderSettings.IntProperty( attr="chunks",
+                    name="Chunks",
+                    description="Number of frame to dispatch to each slave in one chunk",
+                    default = 5,
+                    min=1,
+                    max=65535)
+    
+    NetRenderSettings.IntProperty( attr="priority",
+                    name="Priority",
+                    description="Priority of the job",
+                    default = 1,
+                    min=1,
+                    max=10)
+    
+    NetRenderSettings.StringProperty( attr="job_id",
+                    name="Network job id",
+                    description="id of the last sent render job",
+                    maxlen = 64,
+                    default = "")
+    
+    NetRenderSettings.IntProperty( attr="active_slave_index",
+                    name="Index of the active slave",
+                    description="",
+                    default = -1,
+                    min= -1,
+                    max=65535)
+    
+    NetRenderSettings.IntProperty( attr="active_blacklisted_slave_index",
+                    name="Index of the active slave",
+                    description="",
+                    default = -1,
+                    min= -1,
+                    max=65535)
+    
+    NetRenderSettings.IntProperty( attr="active_job_index",
+                    name="Index of the active job",
+                    description="",
+                    default = -1,
+                    min= -1,
+                    max=65535)
+    
+    NetRenderSettings.EnumProperty(attr="mode",
+                            items=(
+                                            ("RENDER_CLIENT", "Client", "Act as render client"),
+                                            ("RENDER_MASTER", "Master", "Act as render master"),
+                                            ("RENDER_SLAVE", "Slave", "Act as render slave"),
+                                        ),
+                            name="Network mode",
+                            description="Mode of operation of this instance",
+                            default="RENDER_CLIENT")
+    
+    NetRenderSettings.CollectionProperty(attr="slaves", type=NetRenderSlave, name="Slaves", description="")
+    NetRenderSettings.CollectionProperty(attr="slaves_blacklist", type=NetRenderSlave, name="Slaves Blacklist", description="")
+    NetRenderSettings.CollectionProperty(attr="jobs", type=NetRenderJob, name="Job List", description="")
+    
+    NetRenderSlave.StringProperty( attr="name",
+                    name="Name of the slave",
+                    description="",
+                    maxlen = 64,
+                    default = "")
+    
+    NetRenderJob.StringProperty( attr="name",
+                    name="Name of the job",
+                    description="",
+                    maxlen = 128,
+                    default = "")