Formatting according to PEP-8 using autopep8

I've added a `setup.cfg` file with `[pep8]` section to make it use the
120-char line length limit we have for all Blender/Python scripts.
This commit is contained in:
2018-08-14 12:14:54 +02:00
parent 05c01f2b21
commit 58644b911f
8 changed files with 84 additions and 42 deletions

View File

@@ -60,7 +60,7 @@ def benchmarkBlenderWatched(command):
else: else:
logger.DEBUG("Line from stdout: {}" . format(line)) logger.DEBUG("Line from stdout: {}" . format(line))
st.update(line) st.update(line)
if st.current_tiles != 0 or st.current_sample != None: if st.current_tiles != 0 or st.current_sample is not None:
elapsed_time = time.time() - start_time elapsed_time = time.time() - start_time
elapsed_time_str = util.humanReadableTimeDifference(elapsed_time) elapsed_time_str = util.humanReadableTimeDifference(elapsed_time)
progress.progress(int(st.getCurrentProgress()), progress.progress(int(st.getCurrentProgress()),
@@ -92,7 +92,7 @@ def benchmarkScene(ctx, scene):
tmpdir = tempfile.TemporaryDirectory(prefix="benchmark_") tmpdir = tempfile.TemporaryDirectory(prefix="benchmark_")
cfra = util.queryCurrentFrame(blendfile) cfra = util.queryCurrentFrame(blendfile)
command = constructBenchmarkCommand( command = constructBenchmarkCommand(
ctx, scene, blendfile, tmpdir.name, cfra) ctx, scene, blendfile, tmpdir.name, cfra)
logger.DEBUG("Command for rendering: {}" . format(command)) logger.DEBUG("Command for rendering: {}" . format(command))
progress.step('WARM_UP') progress.step('WARM_UP')
logger.INFO("> Warm-up round, making sure everything is ready " + logger.INFO("> Warm-up round, making sure everything is ready " +
@@ -104,7 +104,7 @@ def benchmarkScene(ctx, scene):
# Remove resutl of warmup round. # Remove resutl of warmup round.
if ctx.image_output_dir: if ctx.image_output_dir:
full_image_output = os.path.join(ctx.image_output_dir, scene) + \ full_image_output = os.path.join(ctx.image_output_dir, scene) + \
str(cfra) + ".png" str(cfra) + ".png"
if os.path.exists(full_image_output): if os.path.exists(full_image_output):
os.remove(full_image_output) os.remove(full_image_output)
# TODO(sergey): Consider doing several passes. # TODO(sergey): Consider doing several passes.

View File

@@ -23,47 +23,41 @@ class COLORS_ANSI:
VERBOSE = False VERBOSE = False
COLORS = COLORS_DUMMY COLORS = COLORS_DUMMY
class DefaultLoggerProvider: class DefaultLoggerProvider:
def HEADER(self, *args): def HEADER(self, *args):
print(COLORS.HEADER + COLORS.BOLD, end="") print(COLORS.HEADER + COLORS.BOLD, end="")
print(*args, end="") print(*args, end="")
print(COLORS.ENDC) print(COLORS.ENDC)
def WARNING(self, *args): def WARNING(self, *args):
print(COLORS.WARNING + COLORS.BOLD, end="") print(COLORS.WARNING + COLORS.BOLD, end="")
print(*args, end="") print(*args, end="")
print(COLORS.ENDC) print(COLORS.ENDC)
def ERROR(self, *args): def ERROR(self, *args):
print(COLORS.FAIL + COLORS.BOLD, end="") print(COLORS.FAIL + COLORS.BOLD, end="")
print(*args, end="") print(*args, end="")
print(COLORS.ENDC) print(COLORS.ENDC)
def OK(self, *args): def OK(self, *args):
print(COLORS.OKGREEN + COLORS.BOLD, end="") print(COLORS.OKGREEN + COLORS.BOLD, end="")
print(*args, end="") print(*args, end="")
print(COLORS.ENDC) print(COLORS.ENDC)
def BOLD(self, *args): def BOLD(self, *args):
print(COLORS.BOLD, end="") print(COLORS.BOLD, end="")
print(*args, end="") print(*args, end="")
print(COLORS.ENDC) print(COLORS.ENDC)
def INFO(self, *args): def INFO(self, *args):
print(*args) print(*args)
def DEBUG(self, *args): def DEBUG(self, *args):
# TODO(sergey): Add check that debug is enabled. # TODO(sergey): Add check that debug is enabled.
if False: if False:
print(*args) print(*args)
def FATAL(self, *args): def FATAL(self, *args):
import sys import sys
ERROR(*args) ERROR(*args)
@@ -72,6 +66,7 @@ class DefaultLoggerProvider:
LOGGER_PROVIDER = DefaultLoggerProvider() LOGGER_PROVIDER = DefaultLoggerProvider()
def HEADER(*args): def HEADER(*args):
LOGGER_PROVIDER.HEADER(*args) LOGGER_PROVIDER.HEADER(*args)

View File

@@ -3,11 +3,13 @@ import sys
from . import logger from . import logger
class DefaultProgressProvider: class DefaultProgressProvider:
""" """
Default progress provider implementation, which draws progress Default progress provider implementation, which draws progress
bar in the console, unless current logging is set to evrbose mode. bar in the console, unless current logging is set to evrbose mode.
""" """
def progress(self, count, total, prefix="", suffix=""): def progress(self, count, total, prefix="", suffix=""):
if logger.VERBOSE: if logger.VERBOSE:
return return
@@ -29,12 +31,12 @@ class DefaultProgressProvider:
sys.stdout.flush() sys.stdout.flush()
def clear(self): def clear(self):
if logger.VERBOSE: if logger.VERBOSE:
return return
size = shutil.get_terminal_size((80, 20)) size = shutil.get_terminal_size((80, 20))
sys.stdout.write(" " * size.columns + "\r") sys.stdout.write(" " * size.columns + "\r")
sys.stdout.flush() sys.stdout.flush()
def step(self, step_name): def step(self, step_name):
pass pass
@@ -76,12 +78,15 @@ def step(step_name):
def scene(scene_name): def scene(scene_name):
PROGRESS_PROVIDER.scene(scene_name) PROGRESS_PROVIDER.scene(scene_name)
def scene_stats(scene_name, stats): def scene_stats(scene_name, stats):
PROGRESS_PROVIDER.scene_stats(scene_name, stats) PROGRESS_PROVIDER.scene_stats(scene_name, stats)
def render_process(process): def render_process(process):
PROGRESS_PROVIDER.render_process(process) PROGRESS_PROVIDER.render_process(process)
def is_canceled(): def is_canceled():
return PROGRESS_PROVIDER.is_canceled() return PROGRESS_PROVIDER.is_canceled()

View File

@@ -89,16 +89,16 @@ class Stats:
# TODO(sergey): Check that all stats are available. # TODO(sergey): Check that all stats are available.
print("Total pipeline render time: {} ({} sec)" print("Total pipeline render time: {} ({} sec)"
. format(util.humanReadableTimeDifference( . format(util.humanReadableTimeDifference(
self.pipeline_render_time), self.pipeline_render_time),
self.pipeline_render_time)) self.pipeline_render_time))
print("Total Cycles render time: {} ({} sec)" print("Total Cycles render time: {} ({} sec)"
. format(util.humanReadableTimeDifference( . format(util.humanReadableTimeDifference(
self.total_render_time), self.total_render_time),
self.total_render_time)) self.total_render_time))
print("Pure Cycles render time (without sync): {} ({} sec)" print("Pure Cycles render time (without sync): {} ({} sec)"
. format(util.humanReadableTimeDifference( . format(util.humanReadableTimeDifference(
self.render_time_no_sync), self.render_time_no_sync),
self.render_time_no_sync)) self.render_time_no_sync))
print("Cycles memoty usage: {} ({} peak)" print("Cycles memoty usage: {} ({} peak)"
. format(self.device_memory_usage, . format(self.device_memory_usage,
self.device_peak_memory)) self.device_peak_memory))

View File

@@ -12,6 +12,7 @@ from .third_party import cpuinfo
from .third_party import cpu_cores from .third_party import cpu_cores
from .third_party.dateutil import parser from .third_party.dateutil import parser
def _getBlenderDeviceInfo(ctx): def _getBlenderDeviceInfo(ctx):
PREFIX = "Benchmark Devices: " PREFIX = "Benchmark Devices: "
command = [ctx.blender, command = [ctx.blender,

2
benchmark/setup.cfg Normal file
View File

@@ -0,0 +1,2 @@
[pep8]
max-line-length = 120

View File

@@ -53,6 +53,7 @@ WELCOME_TEXT = "Run the Quick Benchmark on the selected device to\n" \
BLURB_TEXT = "Share your results with the world!\n" \ BLURB_TEXT = "Share your results with the world!\n" \
"Manage the uploaded benchmark data on your Blender ID." "Manage the uploaded benchmark data on your Blender ID."
def reset_global_state(): def reset_global_state():
global global_result_platform global global_result_platform
global global_progress_status global global_progress_status
@@ -72,18 +73,21 @@ def reset_global_state():
################################################################################ ################################################################################
# Draw Utilities. # Draw Utilities.
font_id = 0 font_id = 0
def viewport_size(): def viewport_size():
import bgl import bgl
viewport = bgl.Buffer(bgl.GL_INT, 4) viewport = bgl.Buffer(bgl.GL_INT, 4)
bgl.glGetIntegerv(bgl.GL_VIEWPORT, viewport) bgl.glGetIntegerv(bgl.GL_VIEWPORT, viewport)
return viewport[2], viewport[3] return viewport[2], viewport[3]
def draw_text_center(text, x, y, shadow=False): def draw_text_center(text, x, y, shadow=False):
dim = blf.dimensions(font_id, text) dim = blf.dimensions(font_id, text)
cx = x - int(dim[0]/2) cx = x - int(dim[0] / 2)
cy = y - int(dim[1]/2) cy = y - int(dim[1] / 2)
if shadow: if shadow:
delta = 1 delta = 1
blf.color(font_id, 0.2, 0.2, 0.2, 1.0) blf.color(font_id, 0.2, 0.2, 0.2, 1.0)
@@ -93,6 +97,7 @@ def draw_text_center(text, x, y, shadow=False):
blf.position(font_id, cx, cy, 0) blf.position(font_id, cx, cy, 0)
blf.draw(font_id, text) blf.draw(font_id, text)
def draw_text_multiline(text, x, y, shadow=False): def draw_text_multiline(text, x, y, shadow=False):
ui_scale = bpy.context.user_preferences.system.ui_scale ui_scale = bpy.context.user_preferences.system.ui_scale
height = int(blf.dimensions(font_id, "Dummy Text")[1]) height = int(blf.dimensions(font_id, "Dummy Text")[1])
@@ -109,10 +114,12 @@ def draw_text_multiline(text, x, y, shadow=False):
blf.draw(font_id, line) blf.draw(font_id, line)
y -= height + space y -= height + space
def draw_rect(x, y, w, h, color): def draw_rect(x, y, w, h, color):
import gpu import gpu
gpu.draw.rect(x, y, x + w, y + h, color[0], color[1], color[2], color[3]) gpu.draw.rect(x, y, x + w, y + h, color[0], color[1], color[2], color[3])
def draw_image(filepath, x, y, w, h): def draw_image(filepath, x, y, w, h):
global images global images
if filepath not in images: if filepath not in images:
@@ -256,6 +263,7 @@ handle_draw = bpy.types.SpaceBenchmark.draw_handler_add(
################################################################################ ################################################################################
# Benchmark foundation integration. # Benchmark foundation integration.
class ProgressProviderSink: class ProgressProviderSink:
current_progress = 0.0 current_progress = 0.0
current_step = '' current_step = ''
@@ -300,7 +308,7 @@ class ProgressProviderSink:
global global_scene_status global global_scene_status
if stats: if stats:
global_scene_status[scene_name] = util.humanReadableTimeDifference( global_scene_status[scene_name] = util.humanReadableTimeDifference(
stats.total_render_time) stats.total_render_time)
else: else:
global_scene_status[scene_name] = "Crashed :(" global_scene_status[scene_name] = "Crashed :("
progress_lock.release() progress_lock.release()
@@ -341,18 +349,21 @@ class LoggerProviderSink:
################################################################################ ################################################################################
# Benchmark thread. # Benchmark thread.
def string_strip_trademark(name): def string_strip_trademark(name):
return name.replace("(R)", "").replace("(TM)", "") return name.replace("(R)", "").replace("(TM)", "")
def correct_device_name(name): def correct_device_name(name):
if (name.startswith("TITAN") or if (name.startswith("TITAN") or
name.startswith("Quadro") or name.startswith("Quadro") or
name.startswith("GeForce")): name.startswith("GeForce")):
return "Nvidia " + name; return "Nvidia " + name
if (name.startswith("Radeon")): if (name.startswith("Radeon")):
return "AMD " + name; return "AMD " + name
return name return name
def get_gpu_names(system_info): def get_gpu_names(system_info):
gpu_names = [] gpu_names = []
for device in system_info["devices"]: for device in system_info["devices"]:
@@ -361,21 +372,23 @@ def get_gpu_names(system_info):
gpu_names.append(correct_device_name(device["name"])) gpu_names.append(correct_device_name(device["name"]))
return gpu_names return gpu_names
def indent_gpu_names(gpu_names): def indent_gpu_names(gpu_names):
indented_names = [] indented_names = []
for name in gpu_names: for name in gpu_names:
indented_names.append("" + name) indented_names.append("" + name)
return indented_names return indented_names
def construct_platform_string(system_info): def construct_platform_string(system_info):
""" """
Construct human readable platform string to show in the interface. Construct human readable platform string to show in the interface.
""" """
result = "" result = ""
result += "OS: {} {}" . format(system_info["system"], result += "OS: {} {}" . format(system_info["system"],
system_info["bitness"]) system_info["bitness"])
result += "\nCPU: {}" . format( result += "\nCPU: {}" . format(
string_strip_trademark(system_info["cpu_brand"])) string_strip_trademark(system_info["cpu_brand"]))
gpu_names = get_gpu_names(system_info) gpu_names = get_gpu_names(system_info)
num_gpus = len(gpu_names) num_gpus = len(gpu_names)
if num_gpus: if num_gpus:
@@ -385,6 +398,7 @@ def construct_platform_string(system_info):
result += "\nGPUs:\n{}" . format("\n" . join(indent_gpu_names(gpu_names))) result += "\nGPUs:\n{}" . format("\n" . join(indent_gpu_names(gpu_names)))
return result return result
def convert_result_to_json_dict(ctx, results): def convert_result_to_json_dict(ctx, results):
# Convert custom classes to dictionaries for easier JSON dump. # Convert custom classes to dictionaries for easier JSON dump.
json_results = results json_results = results
@@ -400,7 +414,7 @@ def convert_result_to_json_dict(ctx, results):
else: else:
stat = {'result': 'CRASH'} stat = {'result': 'CRASH'}
json_results['scenes'].append({'name': scene, json_results['scenes'].append({'name': scene,
'stats': stat}) 'stats': stat})
return json_results return json_results
@@ -414,6 +428,7 @@ def system_info_get(ctx):
sys.executable = old_executable sys.executable = old_executable
return info return info
def modify_system_info(system_info): def modify_system_info(system_info):
compute_units = query_opencl_compute_units() compute_units = query_opencl_compute_units()
for device in system_info["devices"]: for device in system_info["devices"]:
@@ -427,6 +442,7 @@ def modify_system_info(system_info):
del compute_units[index] del compute_units[index]
return system_info return system_info
def modify_device_info(device_info): def modify_device_info(device_info):
compute_device = bpy.context.scene.compute_device compute_device = bpy.context.scene.compute_device
device_type, device_name, compute_units, device_index = compute_device.split(":") device_type, device_name, compute_units, device_index = compute_device.split(":")
@@ -439,6 +455,7 @@ def modify_device_info(device_info):
device_info["compute_devices"] = compute_devices device_info["compute_devices"] = compute_devices
return device_info return device_info
def benchmark_thread(ctx): def benchmark_thread(ctx):
global progress_lock, global_result_platform, global_progress_status global progress_lock, global_result_platform, global_progress_status
global global_cancel global global_cancel
@@ -499,6 +516,7 @@ def ui_scale_factor(x):
widget_height = 20 * ui_scale widget_height = 20 * ui_scale
return x * widget_height / int(widget_height) return x * widget_height / int(widget_height)
class BENCHMARK_PT_main(Panel): class BENCHMARK_PT_main(Panel):
bl_label = "Benchmark" bl_label = "Benchmark"
bl_options = {'HIDE_HEADER'} bl_options = {'HIDE_HEADER'}
@@ -616,6 +634,7 @@ def blender_benchmark_data_dir_get():
else: else:
raise Exception("Needs implementation") raise Exception("Needs implementation")
def blender_executable_get(): def blender_executable_get():
benchmark_data_dir = blender_benchmark_data_dir_get() benchmark_data_dir = blender_benchmark_data_dir_get()
system = platform.system() system = platform.system()
@@ -628,15 +647,18 @@ def blender_executable_get():
else: else:
raise Exception("Needs implementation") raise Exception("Needs implementation")
def scenes_dir_get(): def scenes_dir_get():
benchmark_data_dir = blender_benchmark_data_dir_get() benchmark_data_dir = blender_benchmark_data_dir_get()
return os.path.join(benchmark_data_dir, "scenes") return os.path.join(benchmark_data_dir, "scenes")
def configure_script_get(): def configure_script_get():
script_directory = os.path.dirname(os.path.realpath(__file__)) script_directory = os.path.dirname(os.path.realpath(__file__))
benchmark_script_directory = os.path.dirname(script_directory) benchmark_script_directory = os.path.dirname(script_directory)
return os.path.join(benchmark_script_directory, "configure.py") return os.path.join(benchmark_script_directory, "configure.py")
class BENCHMARK_OT_run_base(bpy.types.Operator): class BENCHMARK_OT_run_base(bpy.types.Operator):
run_type = 'QUICK' # or 'COMPLETE' run_type = 'QUICK' # or 'COMPLETE'
benchmark_context = None benchmark_context = None
@@ -680,7 +702,7 @@ class BENCHMARK_OT_run_base(bpy.types.Operator):
global_result_stats = "" global_result_stats = ""
for scene in global_scene_status: for scene in global_scene_status:
global_result_stats += "{}: {}\n" . format( global_result_stats += "{}: {}\n" . format(
scene, global_scene_status[scene]) scene, global_scene_status[scene])
progress_lock.release() progress_lock.release()
def done(self, context): def done(self, context):
@@ -708,11 +730,11 @@ class BENCHMARK_OT_run_base(bpy.types.Operator):
global_result_stats += "\n" global_result_stats += "\n"
if stat["result"] == "OK": if stat["result"] == "OK":
global_result_stats += "{}: {}" . format(name_stat['name'], global_result_stats += "{}: {}" . format(name_stat['name'],
util.humanReadableTimeDifference( util.humanReadableTimeDifference(
stat["total_render_time"])) stat["total_render_time"]))
else: else:
global_result_stats += "{}: {}" . format(name_stat['name'], global_result_stats += "{}: {}" . format(name_stat['name'],
stat["result"]) stat["result"])
else: else:
global_result_stats = "" global_result_stats = ""
# TOGO(sergey): Use some more nice picture for the final slide. # TOGO(sergey): Use some more nice picture for the final slide.
@@ -776,8 +798,8 @@ class BENCHMARK_OT_run_base(bpy.types.Operator):
# ctx.image_output_dir = "/tmp/" # ctx.image_output_dir = "/tmp/"
self.benchmark_context = ctx self.benchmark_context = ctx
# Create thread for the actual benchmark. # Create thread for the actual benchmark.
self.thread = Thread(target = benchmark_thread, self.thread = Thread(target=benchmark_thread,
args = (self.benchmark_context, )) args=(self.benchmark_context, ))
self.thread.start() self.thread.start()
# Create timer to query thread status # Create timer to query thread status
self.timer = wm.event_timer_add(0.1, context.window) self.timer = wm.event_timer_add(0.1, context.window)
@@ -807,6 +829,7 @@ class BENCHMARK_OT_run_base(bpy.types.Operator):
if self.thread: if self.thread:
self.thread.join() self.thread.join()
class BENCHMARK_OT_run_quick(BENCHMARK_OT_run_base): class BENCHMARK_OT_run_quick(BENCHMARK_OT_run_base):
"Run quick Blender benchmark" "Run quick Blender benchmark"
bl_label = "Run Benchmark" bl_label = "Run Benchmark"
@@ -814,6 +837,7 @@ class BENCHMARK_OT_run_quick(BENCHMARK_OT_run_base):
run_type = 'QUICK' run_type = 'QUICK'
class BENCHMARK_OT_run_complete(BENCHMARK_OT_run_base): class BENCHMARK_OT_run_complete(BENCHMARK_OT_run_base):
"Run complete Blender benchmark (might take 1.5 hours to finish and 4GiB of GPU memory)" "Run complete Blender benchmark (might take 1.5 hours to finish and 4GiB of GPU memory)"
bl_label = "Run Benchmark" bl_label = "Run Benchmark"
@@ -852,6 +876,7 @@ class BENCHMARK_OT_save(bpy.types.Operator):
def cancel(self, context): def cancel(self, context):
make_buttons_green() make_buttons_green()
class BENCHMARK_OT_share(bpy.types.Operator): class BENCHMARK_OT_share(bpy.types.Operator):
bl_idname = "benchmark.share" bl_idname = "benchmark.share"
bl_label = "Share Benchmark Result" bl_label = "Share Benchmark Result"
@@ -872,6 +897,7 @@ class BENCHMARK_OT_share(bpy.types.Operator):
global_results_submitted = True global_results_submitted = True
return {'FINISHED'} return {'FINISHED'}
class BENCHMARK_OT_opendata_link(bpy.types.Operator): class BENCHMARK_OT_opendata_link(bpy.types.Operator):
bl_idname = "benchmark.opendata_link" bl_idname = "benchmark.opendata_link"
bl_label = "opendata.blender.org" bl_label = "opendata.blender.org"
@@ -883,6 +909,7 @@ class BENCHMARK_OT_opendata_link(bpy.types.Operator):
################################################################################ ################################################################################
# Restart benchmark. # Restart benchmark.
class BENCHMARK_OT_restart(bpy.types.Operator): class BENCHMARK_OT_restart(bpy.types.Operator):
bl_idname = "benchmark.restart" bl_idname = "benchmark.restart"
bl_label = "Go to a home screen and choose another benchmark to run" bl_label = "Go to a home screen and choose another benchmark to run"
@@ -894,6 +921,7 @@ class BENCHMARK_OT_restart(bpy.types.Operator):
################################################################################ ################################################################################
# Configuration. # Configuration.
def cl_query_executable_get(): def cl_query_executable_get():
benchmark_data_dir = blender_benchmark_data_dir_get() benchmark_data_dir = blender_benchmark_data_dir_get()
system = platform.system() system = platform.system()
@@ -906,6 +934,7 @@ def cl_query_executable_get():
else: else:
raise Exception("Needs implementation") raise Exception("Needs implementation")
def query_opencl_compute_units(): def query_opencl_compute_units():
binary = cl_query_executable_get() binary = cl_query_executable_get()
output = subprocess.run([binary], stdout=subprocess.PIPE).stdout output = subprocess.run([binary], stdout=subprocess.PIPE).stdout
@@ -916,6 +945,7 @@ def query_opencl_compute_units():
compute_units.append((name.decode(), max_compute_units.decode())) compute_units.append((name.decode(), max_compute_units.decode()))
return compute_units return compute_units
def find_first_device_index(compute_units, device_name): def find_first_device_index(compute_units, device_name):
if not compute_units: if not compute_units:
return -1 return -1
@@ -924,6 +954,7 @@ def find_first_device_index(compute_units, device_name):
return index return index
return -1 return -1
def compute_device_list_get(self, context): def compute_device_list_get(self, context):
global global_cached_system_info global global_cached_system_info
global global_cached_compute_devices global global_cached_compute_devices
@@ -974,9 +1005,12 @@ def compute_device_list_get(self, context):
################################################################################ ################################################################################
# Tweak User Preferences # Tweak User Preferences
default_wcol_tool_inner = None default_wcol_tool_inner = None
default_wcol_tool_inner_sel = None default_wcol_tool_inner_sel = None
default_wcol_tool_outline = None default_wcol_tool_outline = None
def backup_buttons_colors(): def backup_buttons_colors():
global default_wcol_tool_inner global default_wcol_tool_inner
global default_wcol_tool_inner_sel global default_wcol_tool_inner_sel
@@ -987,6 +1021,7 @@ def backup_buttons_colors():
default_wcol_tool_inner_sel = theme.user_interface.wcol_tool.inner_sel[:] default_wcol_tool_inner_sel = theme.user_interface.wcol_tool.inner_sel[:]
default_wcol_tool_outline = theme.user_interface.wcol_tool.outline[:] default_wcol_tool_outline = theme.user_interface.wcol_tool.outline[:]
def make_buttons_green(): def make_buttons_green():
userpref = bpy.context.user_preferences userpref = bpy.context.user_preferences
theme = userpref.themes[0] theme = userpref.themes[0]
@@ -994,6 +1029,7 @@ def make_buttons_green():
theme.user_interface.wcol_tool.inner_sel = [0.308, 0.490, 0.029, 1.0] theme.user_interface.wcol_tool.inner_sel = [0.308, 0.490, 0.029, 1.0]
theme.user_interface.wcol_tool.outline = [0.408, 0.590, 0.129] theme.user_interface.wcol_tool.outline = [0.408, 0.590, 0.129]
def make_buttons_default(): def make_buttons_default():
userpref = bpy.context.user_preferences userpref = bpy.context.user_preferences
theme = userpref.themes[0] theme = userpref.themes[0]
@@ -1001,6 +1037,7 @@ def make_buttons_default():
theme.user_interface.wcol_tool.inner_sel = default_wcol_tool_inner_sel theme.user_interface.wcol_tool.inner_sel = default_wcol_tool_inner_sel
theme.user_interface.wcol_tool.outline = default_wcol_tool_outline theme.user_interface.wcol_tool.outline = default_wcol_tool_outline
userpref = bpy.context.user_preferences userpref = bpy.context.user_preferences
theme = userpref.themes[0] theme = userpref.themes[0]
userpref.view.use_quit_dialog = False userpref.view.use_quit_dialog = False

View File

@@ -28,11 +28,11 @@ if PY3:
if sys.platform.startswith('java'): if sys.platform.startswith('java'):
import platform import platform
os_name = platform.java_ver()[3][0] os_name = platform.java_ver()[3][0]
if os_name.startswith('Windows'): # "Windows XP", "Windows 7", etc. if os_name.startswith('Windows'): # "Windows XP", "Windows 7", etc.
system = 'win32' system = 'win32'
elif os_name.startswith('Mac'): # "Mac OS X", etc. elif os_name.startswith('Mac'): # "Mac OS X", etc.
system = 'darwin' system = 'darwin'
else: # "Linux", "SunOS", "FreeBSD", etc. else: # "Linux", "SunOS", "FreeBSD", etc.
# Setting this to "linux2" is not ideal, but only Windows or Mac # Setting this to "linux2" is not ideal, but only Windows or Mac
# are actually checked for and the rest of the module expects # are actually checked for and the rest of the module expects
# *sys.platform* style strings. # *sys.platform* style strings.
@@ -41,7 +41,6 @@ else:
system = sys.platform system = sys.platform
def user_data_dir(appname=None, appauthor=None, version=None, roaming=False): def user_data_dir(appname=None, appauthor=None, version=None, roaming=False):
r"""Return full path to the user-specific data dir for this application. r"""Return full path to the user-specific data dir for this application.
@@ -364,6 +363,7 @@ def user_log_dir(appname=None, appauthor=None, version=None, opinion=True):
class AppDirs(object): class AppDirs(object):
"""Convenience wrapper for getting application dirs.""" """Convenience wrapper for getting application dirs."""
def __init__(self, appname, appauthor=None, version=None, roaming=False, def __init__(self, appname, appauthor=None, version=None, roaming=False,
multipath=False): multipath=False):
self.appname = appname self.appname = appname
@@ -390,7 +390,7 @@ class AppDirs(object):
@property @property
def site_config_dir(self): def site_config_dir(self):
return site_config_dir(self.appname, self.appauthor, return site_config_dir(self.appname, self.appauthor,
version=self.version, multipath=self.multipath) version=self.version, multipath=self.multipath)
@property @property
def user_cache_dir(self): def user_cache_dir(self):
@@ -479,6 +479,7 @@ def _get_win_folder_with_ctypes(csidl_name):
return buf.value return buf.value
def _get_win_folder_with_jna(csidl_name): def _get_win_folder_with_jna(csidl_name):
import array import array
from com.sun import jna from com.sun import jna
@@ -505,6 +506,7 @@ def _get_win_folder_with_jna(csidl_name):
return dir return dir
if system == "win32": if system == "win32":
try: try:
import win32com.shell import win32com.shell