浏览代码

d.mon: improve list menthod
fix renderer when display command fails


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@64423 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 10 年之前
父节点
当前提交
3f895958a7
共有 2 个文件被更改,包括 9 次插入3 次删除
  1. 1 1
      display/d.mon/list.c
  2. 8 2
      display/d.mon/start.c

+ 1 - 1
display/d.mon/list.c

@@ -49,7 +49,7 @@ void list_mon(char ***list, int *n)
     
     
     while ((dp = readdir(dirp)) != NULL) {
     while ((dp = readdir(dirp)) != NULL) {
         *list = G_realloc(*list, (*n + 1) * sizeof(char *));
         *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;
             continue;
         (*list)[*n] = dp->d_name;
         (*list)[*n] = dp->d_name;
         (*n)++;
         (*n)++;

+ 8 - 2
display/d.mon/start.c

@@ -152,7 +152,8 @@ int start_mon(const char *name, const char *output, int select,
                "cmd, dcmd = gtask.cmdstring_to_tuple(sys.argv[1])\n"
                "cmd, dcmd = gtask.cmdstring_to_tuple(sys.argv[1])\n"
                "if not cmd or cmd == 'd.mon':\n"
                "if not cmd or cmd == 'd.mon':\n"
                "    sys.exit(0)\n\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"
                "fd = open('%s', mode)\n"
                "if fd is None:\n"
                "if fd is None:\n"
                "    grass.fatal(\"Unable to open file '%s'\")\n"
                "    grass.fatal(\"Unable to open file '%s'\")\n"
@@ -162,6 +163,7 @@ int start_mon(const char *name, const char *output, int select,
                "else:\n"
                "else:\n"
                "    fd.write('')\n"
                "    fd.write('')\n"
                "fd.close()\n\n"
                "fd.close()\n\n"
+               "# read env file\n"
                "fd = open('%s', 'r')\n"
                "fd = open('%s', 'r')\n"
                "if fd is None:\n"
                "if fd is None:\n"
                "    grass.fatal(\"Unable to open file '%s'\")\n"
                "    grass.fatal(\"Unable to open file '%s'\")\n"
@@ -170,7 +172,11 @@ int start_mon(const char *name, const char *output, int select,
                "    k, v = l.rstrip('\\n').split('=')\n"
                "    k, v = l.rstrip('\\n').split('=')\n"
                "    os.environ[k] = v\n"
                "    os.environ[k] = v\n"
                "fd.close()\n\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",
                "sys.exit(0)\n",
                cmd_file, cmd_file, env_file, env_file);
                cmd_file, cmd_file, env_file, env_file);
     write(fd, pycode, strlen(pycode));
     write(fd, pycode, strlen(pycode));