diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-01-31 17:46:28 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-01-31 17:46:28 +0300 |
commit | 95069f29099b40055c0a3e4d10f4a7b0c602a1df (patch) | |
tree | 150ab0c4796c71a89c628c62213df625e4a72670 /release/scripts/io | |
parent | fbadf21b00dba10945d269cf7a82e091833bfcb4 (diff) |
pep8 changes
Diffstat (limited to 'release/scripts/io')
-rw-r--r-- | release/scripts/io/export_obj.py | 2 | ||||
-rw-r--r-- | release/scripts/io/export_ply.py | 2 | ||||
-rw-r--r-- | release/scripts/io/export_x3d.py | 4 | ||||
-rw-r--r-- | release/scripts/io/netrender/__init__.py | 2 | ||||
-rw-r--r-- | release/scripts/io/netrender/balancing.py | 8 | ||||
-rw-r--r-- | release/scripts/io/netrender/master.py | 36 | ||||
-rw-r--r-- | release/scripts/io/netrender/master_html.py | 18 | ||||
-rw-r--r-- | release/scripts/io/netrender/slave.py | 8 | ||||
-rw-r--r-- | release/scripts/io/netrender/ui.py | 32 | ||||
-rw-r--r-- | release/scripts/io/netrender/utils.py | 20 |
10 files changed, 65 insertions, 67 deletions
diff --git a/release/scripts/io/export_obj.py b/release/scripts/io/export_obj.py index e87f1bd6578..ea076e3da5d 100644 --- a/release/scripts/io/export_obj.py +++ b/release/scripts/io/export_obj.py @@ -898,7 +898,7 @@ class ExportOBJ(bpy.types.Operator): path = StringProperty(name="File Path", description="File path used for exporting the OBJ file", maxlen= 1024, default= "") check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, hidden=True) - + # context group use_selection = BoolProperty(name="Selection Only", description="", default= False) use_all_scenes = BoolProperty(name="All Scenes", description="", default= False) diff --git a/release/scripts/io/export_ply.py b/release/scripts/io/export_ply.py index 28b601510bd..7c1f1d5a9f3 100644 --- a/release/scripts/io/export_ply.py +++ b/release/scripts/io/export_ply.py @@ -281,7 +281,6 @@ class ExportPLY(bpy.types.Operator): use_uvs = BoolProperty(name="UVs", description="Exort the active UV layer", default=True) use_colors = BoolProperty(name="Vertex Colors", description="Exort the active vertex color layer", default=True) - def poll(self, context): return context.active_object != None @@ -328,4 +327,3 @@ bpy.types.INFO_MT_file_export.append(menu_func) if __name__ == "__main__": bpy.ops.export.ply(path="/tmp/test.ply") - diff --git a/release/scripts/io/export_x3d.py b/release/scripts/io/export_x3d.py index 9d993d1a378..5e355001eb1 100644 --- a/release/scripts/io/export_x3d.py +++ b/release/scripts/io/export_x3d.py @@ -626,7 +626,7 @@ class x3d_class: texCoordList.append(uv) j=j+1 texIndexList.append(-1) - + if self.writingtexture == 0: self.file.write("\n\t\t\ttexCoordIndex=\"") texIndxStr="" @@ -1228,7 +1228,7 @@ class ExportX3D(bpy.types.Operator): # to the class instance from the operator settings before calling. path = StringProperty(name="File Path", description="File path used for exporting the X3D file", maxlen= 1024, default= "") check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, hidden=True) - + apply_modifiers = BoolProperty(name="Apply Modifiers", description="Use transformed mesh data from each object.", default=True) triangulate = BoolProperty(name="Triangulate", description="Triangulate quads.", default=False) compress = BoolProperty(name="Compress", description="GZip the resulting file, requires a full python install.", default=False) diff --git a/release/scripts/io/netrender/__init__.py b/release/scripts/io/netrender/__init__.py index b182ef7f452..ef50df3435a 100644 --- a/release/scripts/io/netrender/__init__.py +++ b/release/scripts/io/netrender/__init__.py @@ -34,4 +34,4 @@ blacklist = [] init_file = "" init_data = True -init_address = True
\ No newline at end of file +init_address = True diff --git a/release/scripts/io/netrender/balancing.py b/release/scripts/io/netrender/balancing.py index 344bacde90a..d3041466326 100644 --- a/release/scripts/io/netrender/balancing.py +++ b/release/scripts/io/netrender/balancing.py @@ -24,7 +24,7 @@ import netrender.model class RatingRule: def __init__(self): self.enabled = True - + def rate(self, job): return 0 @@ -58,7 +58,7 @@ class Balancer: for rule in self.exceptions: if id(rule) == rule_id: return rule - + return None def addRule(self, rule): @@ -129,7 +129,7 @@ class NewJobPriority(PriorityRule): def __init__(self, limit = 1): super().__init__() self.limit = limit - + def setLimit(self, value): self.limit = int(value) @@ -175,7 +175,7 @@ class ExcludeSlavesLimit(ExclusionRule): def setLimit(self, value): self.limit = float(value) - + def str_limit(self): return "more than %.0f%% of all slaves" % (self.limit * 100) diff --git a/release/scripts/io/netrender/master.py b/release/scripts/io/netrender/master.py index f95627135ba..0e3602563b4 100644 --- a/release/scripts/io/netrender/master.py +++ b/release/scripts/io/netrender/master.py @@ -75,9 +75,9 @@ class MRenderJob(netrender.model.RenderJob): self.last_update = 0 self.save_path = "" self.files = [MRenderFile(rfile.filepath, rfile.index, rfile.start, rfile.end) for rfile in job_info.files] - + self.resolution = None - + def initInfo(self): if not self.resolution: self.resolution = tuple(getFileInfo(self.files[0].filepath, ["bpy.context.scene.render_data.resolution_x", "bpy.context.scene.render_data.resolution_y", "bpy.context.scene.render_data.resolution_percentage"])) @@ -113,11 +113,11 @@ class MRenderJob(netrender.model.RenderJob): break else: self.status = JOB_FINISHED - + def pause(self, status = None): if self.status not in {JOB_PAUSED, JOB_QUEUED}: - return - + return + if status == None: self.status = JOB_PAUSED if self.status == JOB_QUEUED else JOB_QUEUED elif status: @@ -238,7 +238,7 @@ class RenderHandler(http.server.BaseHTTPRequestHandler): if match: job_id = match.groups()[0] frame_number = int(match.groups()[1]) - + job = self.server.getJobID(job_id) if job: @@ -249,9 +249,9 @@ class RenderHandler(http.server.BaseHTTPRequestHandler): self.send_head(http.client.ACCEPTED) elif frame.status == DONE: self.server.stats("", "Sending result to client") - + filename = job.save_path + "%04d" % frame_number + ".exr" - + f = open(filename, 'rb') self.send_head(content = "image/x-exr") shutil.copyfileobj(f, self.wfile) @@ -285,7 +285,7 @@ class RenderHandler(http.server.BaseHTTPRequestHandler): self.send_head(http.client.ACCEPTED) elif frame.status == DONE: filename = job.save_path + "%04d" % frame_number + ".exr" - + thumbname = thumbnail(filename) if thumbname: @@ -527,7 +527,7 @@ class RenderHandler(http.server.BaseHTTPRequestHandler): rule.setLimit(limit) except: pass # invalid type - + self.send_head() # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- elif self.path == "/balance_enable": @@ -537,7 +537,7 @@ class RenderHandler(http.server.BaseHTTPRequestHandler): rule = self.server.balancer.ruleByID(rule_id) if rule: rule.enabled = enabled - + self.send_head() # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- elif self.path.startswith("/cancel"): @@ -545,13 +545,13 @@ class RenderHandler(http.server.BaseHTTPRequestHandler): if match: length = int(self.headers['content-length']) - + if length > 0: info_map = eval(str(self.rfile.read(length), encoding='utf8')) clear = info_map.get("clear", False) else: clear = False - + job_id = match.groups()[0] job = self.server.getJobID(job_id) @@ -572,13 +572,13 @@ class RenderHandler(http.server.BaseHTTPRequestHandler): if match: length = int(self.headers['content-length']) - + if length > 0: info_map = eval(str(self.rfile.read(length), encoding='utf8')) status = info_map.get("status", None) else: status = None - + job_id = match.groups()[0] job = self.server.getJobID(job_id) @@ -597,7 +597,7 @@ class RenderHandler(http.server.BaseHTTPRequestHandler): elif self.path == "/clear": # cancel all jobs length = int(self.headers['content-length']) - + if length > 0: info_map = eval(str(self.rfile.read(length), encoding='utf8')) clear = info_map.get("clear", False) @@ -963,10 +963,10 @@ class RenderMasterServer(http.server.HTTPServer): def removeJob(self, job, clear_files = False): self.jobs.remove(job) self.jobs_map.pop(job.id) - + if clear_files: shutil.rmtree(job.save_path) - + for slave in self.slaves: if slave.job == job: slave.job = None diff --git a/release/scripts/io/netrender/master_html.py b/release/scripts/io/netrender/master_html.py index 029497db1ae..3557361b8e9 100644 --- a/release/scripts/io/netrender/master_html.py +++ b/release/scripts/io/netrender/master_html.py @@ -83,7 +83,7 @@ def get(handler): def endTable(): output("</table>") - + def checkbox(title, value, script=""): return """<input type="checkbox" title="%s" %s %s>""" % (title, "checked" if value else "", ("onclick=\"%s\"" % script) if script else "") @@ -114,29 +114,29 @@ def get(handler): headerTable("type", "enabled", "description", "limit") for rule in handler.server.balancer.rules: - rowTable( + rowTable( "rating", checkbox("", rule.enabled, "balance_enable('%i', '%s')" % (id(rule), str(not rule.enabled))), rule, - rule.str_limit() + + rule.str_limit() + """<button title="edit limit" onclick="balance_edit('%i', '%s');">edit</button>""" % (id(rule), str(rule.limit)) if hasattr(rule, "limit") else " " ) for rule in handler.server.balancer.priorities: - rowTable( + rowTable( "priority", checkbox("", rule.enabled, "balance_enable('%i', '%s')" % (id(rule), str(not rule.enabled))), rule, - rule.str_limit() + + rule.str_limit() + """<button title="edit limit" onclick="balance_edit('%i', '%s');">edit</button>""" % (id(rule), str(rule.limit)) if hasattr(rule, "limit") else " " ) for rule in handler.server.balancer.exceptions: - rowTable( + rowTable( "exception", checkbox("", rule.enabled, "balance_enable('%i', '%s')" % (id(rule), str(not rule.enabled))), rule, - rule.str_limit() + + rule.str_limit() + """<button title="edit limit" onclick="balance_edit('%i', '%s');">edit</button>""" % (id(rule), str(rule.limit)) if hasattr(rule, "limit") else " " ) @@ -218,14 +218,14 @@ def get(handler): output("<h2>Render Information</h2>") job.initInfo() - + startTable() rowTable("resolution", "%ix%i at %i%%" % job.resolution) endTable() - + output("<h2>Files</h2>") startTable() diff --git a/release/scripts/io/netrender/slave.py b/release/scripts/io/netrender/slave.py index c0848d7874f..7a1e2798913 100644 --- a/release/scripts/io/netrender/slave.py +++ b/release/scripts/io/netrender/slave.py @@ -217,11 +217,11 @@ def render_slave(engine, netsettings, threads): # send image back to server filename = JOB_PREFIX + "%06d" % frame.number + ".exr" - + # thumbnail first if netsettings.slave_thumb: thumbname = thumbnail(filename) - + f = open(thumbname, 'rb') conn.request("PUT", "/thumb", f, headers=headers) f.close() @@ -232,7 +232,7 @@ def render_slave(engine, netsettings, threads): f.close() if conn.getresponse().status == http.client.NO_CONTENT: continue - + elif job.type == netrender.model.JOB_PROCESS: conn.request("PUT", "/render", headers=headers) if conn.getresponse().status == http.client.NO_CONTENT: @@ -255,7 +255,7 @@ def render_slave(engine, netsettings, threads): break conn.close() - + if netsettings.slave_clear: clearSlave(NODE_PREFIX) diff --git a/release/scripts/io/netrender/ui.py b/release/scripts/io/netrender/ui.py index e8b9f2a6ed3..db402a21757 100644 --- a/release/scripts/io/netrender/ui.py +++ b/release/scripts/io/netrender/ui.py @@ -44,14 +44,14 @@ def init_file(): def init_data(netsettings): init_file() - + if netrender.init_data: netrender.init_data = False netsettings.active_slave_index = 0 while(len(netsettings.slaves) > 0): netsettings.slaves.remove(0) - + netsettings.active_blacklisted_slave_index = 0 while(len(netsettings.slaves_blacklist) > 0): netsettings.slaves_blacklist.remove(0) @@ -59,18 +59,18 @@ def init_data(netsettings): netsettings.active_job_index = 0 while(len(netsettings.jobs) > 0): netsettings.jobs.remove(0) - + def verify_address(netsettings): init_file() if netrender.init_address: netrender.init_address = False - + try: conn = clientConnection(netsettings.server_address, netsettings.server_port, scan = False) except: conn = None - + if conn: conn.close() else: @@ -97,7 +97,7 @@ class RENDER_PT_network_settings(RenderButtonsPanel): scene = context.scene netsettings = scene.network_render - + verify_address(netsettings) layout.prop(netsettings, "mode", expand=True) @@ -106,13 +106,13 @@ class RENDER_PT_network_settings(RenderButtonsPanel): layout.operator("render.netclientstart", icon='PLAY') layout.prop(netsettings, "path") - + split = layout.split(percentage=0.7) - + col = split.column() col.label(text="Server Adress:") col.prop(netsettings, "server_address", text="") - + col = split.column() col.label(text="Port:") col.prop(netsettings, "server_port", text="") @@ -145,7 +145,7 @@ class RENDER_PT_network_slave_settings(RenderButtonsPanel): layout.prop(rd, "threads_mode", expand=True) sub = layout.column() sub.enabled = rd.threads_mode == 'THREADS_FIXED' - sub.prop(rd, "threads") + sub.prop(rd, "threads") @rnaType class RENDER_PT_network_master_settings(RenderButtonsPanel): bl_label = "Master Settings" @@ -164,7 +164,7 @@ class RENDER_PT_network_master_settings(RenderButtonsPanel): layout.prop(netsettings, "master_broadcast") layout.prop(netsettings, "master_clear") - + @rnaType class RENDER_PT_network_job(RenderButtonsPanel): bl_label = "Job Settings" @@ -182,7 +182,7 @@ class RENDER_PT_network_job(RenderButtonsPanel): netsettings = scene.network_render verify_address(netsettings) - + if netsettings.server_address != "[default]": layout.operator("render.netclientanim", icon='RENDER_ANIMATION') layout.operator("render.netclientsend", icon='FILE_BLEND') @@ -190,17 +190,17 @@ class RENDER_PT_network_job(RenderButtonsPanel): row = layout.row() row.operator("screen.render", text="Get Image", icon='RENDER_STILL') row.operator("screen.render", text="Get Animation", icon='RENDER_ANIMATION').animation = True - + split = layout.split(percentage=0.3) - + col = split.column() col.label(text="Name:") col.label(text="Category:") - + col = split.column() col.prop(netsettings, "job_name", text="") col.prop(netsettings, "job_category", text="") - + row = layout.row() row.prop(netsettings, "priority") row.prop(netsettings, "chunks") diff --git a/release/scripts/io/netrender/utils.py b/release/scripts/io/netrender/utils.py index f6d88212441..c9c4a2931a7 100644 --- a/release/scripts/io/netrender/utils.py +++ b/release/scripts/io/netrender/utils.py @@ -104,7 +104,7 @@ def clientConnection(address, port, report = None, scan = True): # else: if not scan: return None - + address, port = clientScan() if address == "": return None @@ -174,28 +174,28 @@ def prefixPath(prefix_directory, file_path, prefix_path): return full_path def getFileInfo(filepath, infos): - process = subprocess.Popen([sys.argv[0], "-b", "-noaudio", filepath, "-P", __file__, "--"] + infos, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + process = subprocess.Popen([sys.argv[0], "-b", "-noaudio", filepath, "-P", __file__, "--"] + infos, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) stdout = bytes() while process.poll() == None: stdout += process.stdout.read(1024) # read leftovers if needed stdout += process.stdout.read() - + stdout = str(stdout, encoding="utf8") - + values = [eval(v[1:].strip()) for v in stdout.split("\n") if v.startswith("$")] - + return values - + def thumbnail(filename): root = os.path.splitext(filename)[0] imagename = os.path.split(filename)[1] thumbname = root + ".jpg" - + if os.path.exists(thumbname): return thumbname - + if bpy: sce = bpy.data.scenes[0] sce.render_data.file_format = "JPEG" @@ -203,10 +203,10 @@ def thumbnail(filename): bpy.ops.image.open(path = filename) img = bpy.data.images[imagename] img.save(thumbname, scene = sce) - + try: process = subprocess.Popen(["convert", thumbname, "-resize", "300x300", thumbname]) - process.wait() + process.wait() return thumbname except: pass |