From 2005f7c6c0ee47b85bbcf5999225e86117290a65 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 00:49:00 +0000 Subject: style cleanup: also some typos --- source/creator/creator.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source/creator') diff --git a/source/creator/creator.c b/source/creator/creator.c index 3260f0c3976..fcfec947d9f 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -499,8 +499,7 @@ static void blender_crash_handler_backtrace(FILE *fp) symbolinfo->MaxNameLen = MAXSYMBOL - 1; symbolinfo->SizeOfStruct = sizeof(SYMBOL_INFO); - for( i = 0; i < nframes; i++ ) - { + for (i = 0; i < nframes; i++) { SymFromAddr(process, ( DWORD64 )( stack[ i ] ), 0, symbolinfo); fprintf(fp, "%u: %s - 0x%0X\n", nframes - i - 1, symbolinfo->Name, symbolinfo->Address); -- cgit v1.2.3 From 20139348785dcd23ebe00db25f5e5726a23c685f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 03:01:50 +0000 Subject: Command line argument '--python' wasn't working as documented since a long time, It wasnt checking for text-blocks. Rather then be ambiguous, add --python-text argument for executing text-blocks. --- source/creator/creator.c | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) (limited to 'source/creator') diff --git a/source/creator/creator.c b/source/creator/creator.c index fcfec947d9f..7ab5d9ff2bd 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -88,6 +88,7 @@ #include "BKE_depsgraph.h" /* for DAG_on_visible_update */ #include "BKE_font.h" #include "BKE_global.h" +#include "BKE_library.h" #include "BKE_main.h" #include "BKE_material.h" #include "BKE_packedFile.h" @@ -302,6 +303,7 @@ static int print_help(int UNUSED(argc), const char **UNUSED(argv), void *data) printf("\n"); BLI_argsPrintArgDoc(ba, "--python"); + BLI_argsPrintArgDoc(ba, "--python-text"); BLI_argsPrintArgDoc(ba, "--python-console"); BLI_argsPrintArgDoc(ba, "--addons"); @@ -1089,11 +1091,11 @@ static int set_skip_frame(int argc, const char **argv, void *data) _cmd; \ } \ CTX_data_scene_set(C, prevscene); \ - } \ + } (void)0 \ #endif /* WITH_PYTHON */ -static int run_python(int argc, const char **argv, void *data) +static int run_python_file(int argc, const char **argv, void *data) { #ifdef WITH_PYTHON bContext *C = data; @@ -1105,12 +1107,42 @@ static int run_python(int argc, const char **argv, void *data) BLI_strncpy(filename, argv[1], sizeof(filename)); BLI_path_cwd(filename); - BPY_CTX_SETUP(BPY_filepath_exec(C, filename, NULL)) + BPY_CTX_SETUP(BPY_filepath_exec(C, filename, NULL)); return 1; } else { - printf("\nError: you must specify a Python script after '-P / --python'.\n"); + printf("\nError: you must specify a filepath after '%s'.\n", argv[0]); + return 0; + } +#else + (void)argc; (void)argv; (void)data; /* unused */ + printf("This blender was built without python support\n"); + return 0; +#endif /* WITH_PYTHON */ +} + +static int run_python_text(int argc, const char **argv, void *data) +{ +#ifdef WITH_PYTHON + bContext *C = data; + + /* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */ + if (argc > 1) { + /* Make the path absolute because its needed for relative linked blends to be found */ + struct Text *text = (struct Text *)BKE_libblock_find_name(ID_TXT, argv[1]); + + if (text) { + BPY_CTX_SETUP(BPY_text_exec(C, text, NULL, false)); + return 1; + } + else { + printf("\nError: text block not found %s.\n", argv[1]); + return 1; + } + } + else { + printf("\nError: you must specify a text block after '%s'.\n", argv[0]); return 0; } #else @@ -1125,7 +1157,7 @@ static int run_python_console(int UNUSED(argc), const char **argv, void *data) #ifdef WITH_PYTHON bContext *C = data; - BPY_CTX_SETUP(BPY_string_exec(C, "__import__('code').interact()")) + BPY_CTX_SETUP(BPY_string_exec(C, "__import__('code').interact()")); return 0; #else @@ -1353,7 +1385,8 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) BLI_argsAdd(ba, 4, "-s", "--frame-start", "\n\tSet start to frame (use before the -a argument)", set_start_frame, C); BLI_argsAdd(ba, 4, "-e", "--frame-end", "\n\tSet end to frame (use before the -a argument)", set_end_frame, C); BLI_argsAdd(ba, 4, "-j", "--frame-jump", "\n\tSet number of frames to step forward after each rendered frame", set_skip_frame, C); - BLI_argsAdd(ba, 4, "-P", "--python", "\n\tRun the given Python script (filename or Blender Text)", run_python, C); + BLI_argsAdd(ba, 4, "-P", "--python", "\n\tRun the given Python script file", run_python_file, C); + BLI_argsAdd(ba, 4, NULL, "--python-text", "\n\tRun the given Python script text block", run_python_text, C); BLI_argsAdd(ba, 4, NULL, "--python-console", "\n\tRun blender with an interactive console", run_python_console, C); BLI_argsAdd(ba, 4, NULL, "--addons", "\n\tComma separated list of addons (no spaces)", set_addons, C); -- cgit v1.2.3 From 648f925017788560b7d05fab3f5f2e4e3c39c8e6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Feb 2013 05:02:20 +0000 Subject: misc changes - update man page for new additions since last release. - note that --start-console argument is windows only. - correct own assertion in own recent commit. --- source/creator/creator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/creator') diff --git a/source/creator/creator.c b/source/creator/creator.c index 7ab5d9ff2bd..4b74e225ec4 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -1366,7 +1366,7 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) BLI_argsAdd(ba, 2, "-p", "--window-geometry", " \n\tOpen with lower left corner at , and width and height as , ", prefsize, NULL); BLI_argsAdd(ba, 2, "-w", "--window-border", "\n\tForce opening with borders (default)", with_borders, NULL); BLI_argsAdd(ba, 2, "-W", "--window-borderless", "\n\tForce opening without borders", without_borders, NULL); - BLI_argsAdd(ba, 2, "-con", "--start-console", "\n\tStart with the console window open (ignored if -b is set)", start_with_console, NULL); + BLI_argsAdd(ba, 2, "-con", "--start-console", "\n\tStart with the console window open (ignored if -b is set), (Windows only)", start_with_console, NULL); BLI_argsAdd(ba, 2, "-R", NULL, "\n\tRegister .blend extension, then exit (Windows only)", register_extension, NULL); BLI_argsAdd(ba, 2, "-r", NULL, "\n\tSilently register .blend extension, then exit (Windows only)", register_extension, ba); BLI_argsAdd(ba, 2, NULL, "--no-native-pixels", "\n\tDo not use native pixel size, for high resolution displays (MacBook 'Retina')", native_pixels, ba); -- cgit v1.2.3