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:
authorWillian Padovani Germano <wpgermano@gmail.com>2005-03-22 07:28:36 +0300
committerWillian Padovani Germano <wpgermano@gmail.com>2005-03-22 07:28:36 +0300
commita4b5ddb371e4854a7f33300baa38bea59b3961b9 (patch)
tree68d5a47a054da81930cbde8e7a07db2ebd70a12c /source/blender
parenta8a73e80970c3e6cfbc88050099bd6119287f94d (diff)
BPython:
-- Stephane Soppera (thanks) reported libc stat function fails for paths ending with "\" under win with free VC++ compiler toolkit 2003: removed final '/' (BLI_make_file_string changes the '/' to '\\\\' for win) slashes from relevant paths, that should take care of it . Note: here (linux, glibc, gcc 3.3.3) stat doesn't have this problem. Also checking if U.pythondir ends with a slash and, if so (as long as its length > 2 to), removing the slash, for the same reason. -- small cosmetic changes in BPY_menus.c for debug msgs and in header_scripts (added a separator in the Scripts win -> Scripts menu).
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/python/BPY_interface.c30
-rw-r--r--source/blender/python/BPY_menus.c33
-rw-r--r--source/blender/python/api2_2x/Blender.c4
-rw-r--r--source/blender/python/api2_2x/EXPP_interface.c10
-rw-r--r--source/blender/src/header_script.c2
5 files changed, 43 insertions, 36 deletions
diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c
index fa38aa8c4c1..261af51873e 100644
--- a/source/blender/python/BPY_interface.c
+++ b/source/blender/python/BPY_interface.c
@@ -306,18 +306,28 @@ that dir info is available.
****************************************************************************/
void BPY_post_start_python( void )
{
- PyObject *result, *dict;
char dirpath[FILE_MAXDIR];
char *sdir = NULL;
if(U.pythondir[0] != '\0' ) {
char modpath[FILE_MAXDIR];
+ int upyslen = strlen(U.pythondir);
+
+ /* check if user pydir ends with a slash and, if so, remove the slash
+ * (for eventual implementations of c library's stat function that might
+ * not like it) */
+ if (upyslen > 2) { /* avoids doing anything if dir == '//' */
+ char ending = U.pythondir[upyslen - 1];
+
+ if (ending == '/' || ending == '\\')
+ U.pythondir[upyslen - 1] = '\0';
+ }
BLI_strncpy(dirpath, U.pythondir, FILE_MAXDIR);
BLI_convertstringcode(dirpath, G.sce, 0);
syspath_append(dirpath); /* append to module search path */
- BLI_make_file_string("/", modpath, dirpath, "bpymodules/");
+ BLI_make_file_string("/", modpath, dirpath, "bpymodules");
if (BLI_exists(modpath)) syspath_append(modpath);
}
@@ -326,25 +336,13 @@ void BPY_post_start_python( void )
syspath_append(sdir);
- BLI_make_file_string("/", dirpath, sdir, "bpymodules/");
+ BLI_make_file_string("/", dirpath, sdir, "bpymodules");
if (BLI_exists(dirpath)) syspath_append(dirpath);
}
BPyMenu_Init( 0 ); /* get dynamic menus (registered scripts) data */
- dict = PyDict_New( );
-
- /* here we check if the user has (some of) the expected modules */
- if( dict ) {
- char *s = "import chunk, gzip, math, os, struct, string";
- result = PyRun_String( s, Py_eval_input, dict, dict );
- if( !result ) {
- PyErr_Clear( );
- /*XXX print msg about this, point to readme.html */
- } else
- Py_DECREF( result );
- Py_DECREF( dict );
- }
+ return;
}
/****************************************************************************
diff --git a/source/blender/python/BPY_menus.c b/source/blender/python/BPY_menus.c
index a35c7470841..40dd8543762 100644
--- a/source/blender/python/BPY_menus.c
+++ b/source/blender/python/BPY_menus.c
@@ -946,9 +946,18 @@ int BPyMenu_Init( int usedir )
for( i = 0; i < PYMENU_TOTAL; i++ )
BPyMenuTable[i] = NULL;
- if( U.pythondir[0] == '\0' ||
- strcmp(U.pythondir, "/") == 0 || strcmp(U.pythondir, "//") == 0)
- {
+ if( DEBUG )
+ fprintf(stdout, "\nRegistering scripts in Blender menus ...\n\n" );
+
+ if( U.pythondir[0] == '\0') {
+ upydir = NULL;
+ }
+ else if (strcmp(U.pythondir, "/") == 0 || strcmp(U.pythondir, "//") == 0) {
+ /* these are not accepted to prevent possible slight slowdowns on startup;
+ * they should not be used as user defined scripts dir, anyway, also from
+ * speed considerations, since they'd not be dedicated scripts dirs */
+ if (DEBUG) fprintf(stderr,
+ "BPyMenus: invalid user defined Python scripts dir: \"/\" or \"//\".\n");
upydir = NULL;
}
else {
@@ -968,7 +977,7 @@ int BPyMenu_Init( int usedir )
fprintf(stderr,
"\nDefault scripts dir: %s:\n%s\n", dirname, strerror(errno));
if( upydir )
- fprintf(stderr,
+ fprintf(stdout,
"Getting scripts menu data from user defined dir: %s.\n",
upythondir );
}
@@ -981,6 +990,7 @@ int BPyMenu_Init( int usedir )
if( stat_dir2 < 0 ) {
time_dir2 = 0;
+ upydir = NULL;
if( DEBUG )
fprintf(stderr, "\nUser defined scripts dir: %s:\n%s.\n",
upythondir, strerror( errno ) );
@@ -990,7 +1000,7 @@ int BPyMenu_Init( int usedir )
To have scripts in menus, please add them to the default scripts dir:\n\
%s\n\
and / or go to 'Info window -> File Paths tab' and set a valid path for\n\
-the user defined scripts dir.\n", dirname );
+the user defined Python scripts dir.\n", dirname );
return -1;
}
}
@@ -1005,9 +1015,6 @@ the user defined scripts dir.\n", dirname );
return -1;
}
- if( DEBUG )
- fprintf(stderr, "\nRegistering scripts in Blender menus ...\n\n" );
-
if (usedir) stat_file = -1;
else { /* if we're not forced to use the dir */
char *homedir = bpy_gethome(0);
@@ -1025,8 +1032,8 @@ the user defined scripts dir.\n", dirname );
{ /* file is newer */
stat_file = bpymenu_CreateFromFile( ); /* -1 if an error occurred */
if( !stat_file && DEBUG )
- fprintf(stderr,
- "Getting menu data for scripts from file: %s\n\n", fname );
+ fprintf(stdout,
+ "Getting menu data for scripts from file:\n%s\n\n", fname );
}
else stat_file = -1;
}
@@ -1035,11 +1042,11 @@ the user defined scripts dir.\n", dirname );
if( stat_file == -1 ) { /* use dirs */
if( DEBUG ) {
- fprintf(stderr,
+ fprintf(stdout,
"Getting menu data for scripts from dir(s):\ndefault: %s\n", dirname );
if( upydir )
- fprintf(stderr, "user defined: %s", upythondir );
- fprintf(stderr, "\n");
+ fprintf(stdout, "user defined: %s\n", upythondir );
+ fprintf(stdout, "\n");
}
if( stat_dir1 == 0 ) {
i = bpymenu_ParseDir( dirname, NULL, 0 );
diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c
index 017ede81b80..988e9ac67bd 100644
--- a/source/blender/python/api2_2x/Blender.c
+++ b/source/blender/python/api2_2x/Blender.c
@@ -228,7 +228,7 @@ static PyObject *Blender_Get( PyObject * self, PyObject * args )
char *sdir = bpy_gethome(1);
if (sdir) {
- BLI_make_file_string( "/", datadir, sdir, "bpydata/" );
+ BLI_make_file_string( "/", datadir, sdir, "bpydata" );
if( BLI_exists( datadir ) )
ret = PyString_FromString( datadir );
}
@@ -244,7 +244,7 @@ static PyObject *Blender_Get( PyObject * self, PyObject * args )
if (BLI_exists(upydir)) {
char udatadir[FILE_MAXDIR];
- BLI_make_file_string("/", udatadir, upydir, "bpydata/");
+ BLI_make_file_string("/", udatadir, upydir, "bpydata");
if (BLI_exists(udatadir))
ret = PyString_FromString(udatadir);
diff --git a/source/blender/python/api2_2x/EXPP_interface.c b/source/blender/python/api2_2x/EXPP_interface.c
index 0dd363146e7..4be155db944 100644
--- a/source/blender/python/api2_2x/EXPP_interface.c
+++ b/source/blender/python/api2_2x/EXPP_interface.c
@@ -81,12 +81,12 @@ char *bpy_gethome(int append_scriptsdir)
if( strstr( s, ".blender" ) )
PyOS_snprintf( homedir, FILE_MAXDIR, s );
else
- BLI_make_file_string( "/", homedir, s, ".blender/" );
+ BLI_make_file_string( "/", homedir, s, ".blender" );
/* if userhome/.blender/ exists, return it */
if( BLI_exists( homedir ) ) {
if (append_scriptsdir) {
- BLI_make_file_string("/", scriptsdir, homedir, "scripts/");
+ BLI_make_file_string("/", scriptsdir, homedir, "scripts");
if (BLI_exists (scriptsdir)) return scriptsdir;
}
else return homedir;
@@ -99,11 +99,11 @@ char *bpy_gethome(int append_scriptsdir)
i = s - bprogname + 1;
PyOS_snprintf( bprogdir, i, bprogname );
- BLI_make_file_string( "/", homedir, bprogdir, ".blender/" );
+ BLI_make_file_string( "/", homedir, bprogdir, ".blender" );
if (BLI_exists(homedir)) {
if (append_scriptsdir) {
- BLI_make_file_string("/", scriptsdir, homedir, "scripts/");
+ BLI_make_file_string("/", scriptsdir, homedir, "scripts");
if (BLI_exists(scriptsdir)) return scriptsdir;
}
else return homedir;
@@ -111,7 +111,7 @@ char *bpy_gethome(int append_scriptsdir)
/* last try for scripts dir: blender in cvs dir, scripts/ inside release/: */
if (append_scriptsdir) {
- BLI_make_file_string("/", scriptsdir, bprogdir, "release/scripts/");
+ BLI_make_file_string("/", scriptsdir, bprogdir, "release/scripts");
if (BLI_exists(scriptsdir)) return scriptsdir;
}
diff --git a/source/blender/src/header_script.c b/source/blender/src/header_script.c
index fc6a0b45545..f29c8f848d7 100644
--- a/source/blender/src/header_script.c
+++ b/source/blender/src/header_script.c
@@ -138,6 +138,8 @@ static uiBlock *script_scriptsmenu(void *arg_unused)
uiDefIconTextBlockBut(block, script_scripts_submenus, (void *)i, ICON_RIGHTARROW_THIN, BPyMenu_group_itoa(i), 0, yco-=20, menuwidth, 19, "");
}
+ uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
+
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Update Menus", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "Use when a scripts folder or its contents are modified");
if(curarea->headertype==HEADERTOP) {