Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-05-30 18:05:58 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-05-30 18:05:58 +0400
commit1658a28a58ebd5fe58ab33875b10aaabb3458b79 (patch)
tree336b92b490fd408daaead6acb4508ead119ca676 /source/creator
parenta6689154047b4a838276170f48bd39372149af71 (diff)
- Python console argument '--python-console', option so you can start blender and drop into a python console, (useful for debugging some problems on a renderfarm over ssh)
- Also made it so sys.stdin isnt overwritten anymore, instead the interactive consoel overwrites while it executes and restores after. - removed hope folder from sphinx patch path
Diffstat (limited to 'source/creator')
-rw-r--r--source/creator/creator.c65
1 files changed, 43 insertions, 22 deletions
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 7a8d7d32d9b..2c48aa9a885 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -261,6 +261,7 @@ static int print_help(int argc, char **argv, void *data)
printf("\n");
BLI_argsPrintArgDoc(ba, "--python");
+ BLI_argsPrintArgDoc(ba, "--python-console");
#ifdef WIN32
BLI_argsPrintArgDoc(ba, "-R");
@@ -789,36 +790,40 @@ static int set_skip_frame(int argc, char **argv, void *data)
}
}
+/* macro for ugly context setup/reset */
+#ifndef DISABLE_PYTHON
+#define BPY_CTX_SETUP(_cmd) \
+{ \
+ wmWindowManager *wm= CTX_wm_manager(C); \
+ wmWindow *prevwin= CTX_wm_window(C); \
+ Scene *prevscene= CTX_data_scene(C); \
+ if(wm->windows.first) { \
+ CTX_wm_window_set(C, wm->windows.first); \
+ _cmd; \
+ CTX_wm_window_set(C, prevwin); \
+ } \
+ else { \
+ fprintf(stderr, "Python script \"%s\" running with missing context data.\n", argv[1]); \
+ _cmd; \
+ } \
+ CTX_data_scene_set(C, prevscene); \
+} \
+
+#endif /* DISABLE_PYTHON */
+
static int run_python(int argc, char **argv, void *data)
{
#ifndef DISABLE_PYTHON
bContext *C = data;
- /* Make the path absolute because its needed for relative linked blends to be found */
- char filename[FILE_MAXDIR + FILE_MAXFILE];
- BLI_strncpy(filename, argv[1], sizeof(filename));
- BLI_path_cwd(filename);
-
/* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */
if (argc > 1) {
- /* XXX, temp setting the WM is ugly, splash also does this :S */
- wmWindowManager *wm= CTX_wm_manager(C);
- wmWindow *prevwin= CTX_wm_window(C);
- Scene *prevscene= CTX_data_scene(C);
-
- if(wm->windows.first) {
- CTX_wm_window_set(C, wm->windows.first);
-
- BPY_run_python_script(C, filename, NULL, NULL); // use reports?
-
- CTX_wm_window_set(C, prevwin);
- }
- else {
- fprintf(stderr, "Python script \"%s\" running with missing context data.\n", argv[1]);
- BPY_run_python_script(C, filename, NULL, NULL); // use reports?
- }
+ /* Make the path absolute because its needed for relative linked blends to be found */
+ char filename[FILE_MAXDIR + FILE_MAXFILE];
+ BLI_strncpy(filename, argv[1], sizeof(filename));
+ BLI_path_cwd(filename);
- CTX_data_scene_set(C, prevscene);
+ BPY_CTX_SETUP( BPY_run_python_script(C, filename, NULL, NULL) )
return 1;
} else {
@@ -831,6 +836,21 @@ static int run_python(int argc, char **argv, void *data)
#endif /* DISABLE_PYTHON */
}
+static int run_python_console(int argc, char **argv, void *data)
+{
+#ifndef DISABLE_PYTHON
+ bContext *C = data;
+ const char *expr= "__import__('code').interact()";
+
+ BPY_CTX_SETUP( BPY_eval_string(C, expr) )
+
+ return 0;
+#else
+ printf("This blender was built without python support\n");
+ return 0;
+#endif /* DISABLE_PYTHON */
+}
+
static int load_file(int argc, char **argv, void *data)
{
bContext *C = data;
@@ -955,6 +975,7 @@ void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle)
BLI_argsAdd(ba, 4, "-e", "--frame-end", "<frame>\n\tSet end to frame <frame> (use before the -a argument)", set_end_frame, C);
BLI_argsAdd(ba, 4, "-j", "--frame-jump", "<frames>\n\tSet number of frames to step forward after each rendered frame", set_skip_frame, C);
BLI_argsAdd(ba, 4, "-P", "--python", "<filename>\n\tRun the given Python script (filename or Blender Text)", run_python, C);
+ BLI_argsAdd(ba, 4, NULL, "--python-console", "\n\tRun blender with an interactive console", run_python_console, C);
BLI_argsAdd(ba, 4, "-o", "--render-output", output_doc, set_output, C);
BLI_argsAdd(ba, 4, "-E", "--engine", "<engine>\n\tSpecify the render engine\n\tuse -E help to list available engines", set_engine, C);