[GRASS-SVN] r64423 - grass/trunk/display/d.mon

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Feb 3 05:20:48 PST 2015


Author: martinl
Date: 2015-02-03 05:20:47 -0800 (Tue, 03 Feb 2015)
New Revision: 64423

Modified:
   grass/trunk/display/d.mon/list.c
   grass/trunk/display/d.mon/start.c
Log:
d.mon: improve list menthod
       fix renderer when display command fails


Modified: grass/trunk/display/d.mon/list.c
===================================================================
--- grass/trunk/display/d.mon/list.c	2015-02-03 13:05:09 UTC (rev 64422)
+++ grass/trunk/display/d.mon/list.c	2015-02-03 13:20:47 UTC (rev 64423)
@@ -49,7 +49,7 @@
     
     while ((dp = readdir(dirp)) != NULL) {
         *list = G_realloc(*list, (*n + 1) * sizeof(char *));
-        if (!dp->d_name || dp->d_name[0] == '.')
+        if (!dp->d_name || dp->d_name[0] == '.' || dp->d_type != DT_DIR)
             continue;
         (*list)[*n] = dp->d_name;
         (*n)++;

Modified: grass/trunk/display/d.mon/start.c
===================================================================
--- grass/trunk/display/d.mon/start.c	2015-02-03 13:05:09 UTC (rev 64422)
+++ grass/trunk/display/d.mon/start.c	2015-02-03 13:20:47 UTC (rev 64423)
@@ -152,7 +152,8 @@
                "cmd, dcmd = gtask.cmdstring_to_tuple(sys.argv[1])\n"
                "if not cmd or cmd == 'd.mon':\n"
                "    sys.exit(0)\n\n"
-               "mode = 'w' if cmd == 'd.erase' else 'a'\n"
+               "mode = 'w' if cmd == 'd.erase' else 'a'\n\n"
+               "# update cmd file\n"
                "fd = open('%s', mode)\n"
                "if fd is None:\n"
                "    grass.fatal(\"Unable to open file '%s'\")\n"
@@ -162,6 +163,7 @@
                "else:\n"
                "    fd.write('')\n"
                "fd.close()\n\n"
+               "# read env file\n"
                "fd = open('%s', 'r')\n"
                "if fd is None:\n"
                "    grass.fatal(\"Unable to open file '%s'\")\n"
@@ -170,7 +172,11 @@
                "    k, v = l.rstrip('\\n').split('=')\n"
                "    os.environ[k] = v\n"
                "fd.close()\n\n"
-               "grass.run_command(cmd, **dcmd)\n"
+               "# run display command\n"
+               "try:\n"
+               "    grass.run_command(cmd, **dcmd)\n"
+               "except:\n"
+               "    pass\n\n"
                "sys.exit(0)\n",
                cmd_file, cmd_file, env_file, env_file);
     write(fd, pycode, strlen(pycode));



More information about the grass-commit mailing list