p.mon.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/usr/bin/env python
  2. ############################################################################
  3. #
  4. # MODULE: p.mon
  5. # AUTHOR(S): Jachym Cepicky, Michael Barton, Martin Landa, Markus Neteler,
  6. # Hamish Bowman
  7. # Converted to Python by Huidae Cho
  8. # PURPOSE: To establish and control use of a graphics display monitor.
  9. # COPYRIGHT: (C) 2009 by The GRASS Development Team
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; either version 2 of the License, or
  14. # (at your option) any later version.
  15. #
  16. # This program is distributed in the hope that it will be useful,
  17. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. # GNU General Public License for more details.
  20. #
  21. ############################################################################
  22. #%Module
  23. #% description: To establish and control use of a graphics display monitor.
  24. #% keywords: display
  25. #%End
  26. ##%Flag
  27. ##% key: l
  28. ##% description: List all monitors
  29. ##%End
  30. ##%Flag
  31. ##% key: L
  32. ##% description: List all monitors (with current status)
  33. ##%End
  34. ##%Flag
  35. ##% key: p
  36. ##% description: Print name of currently selected monitor
  37. ##%End
  38. ##%Flag
  39. ##% key: r
  40. ##% description: Release currently selected monitor
  41. ##%End
  42. ##%Flag
  43. ##% key: s
  44. ##% description: Do not automatically select when starting
  45. ##%End
  46. #%Option
  47. #% key: start
  48. #% type: string
  49. #% required: no
  50. #% multiple: no
  51. #% description: Name of graphics monitor to start (p0-p9)
  52. #%End
  53. ##%Option
  54. ##% key: stop
  55. ##% type: string
  56. ##% required: no
  57. ##% multiple: no
  58. ##% description: Name of graphics monitor to stop
  59. ##%End
  60. ##%Option
  61. ##% key: select
  62. ##% type: string
  63. ##% required: no
  64. ##% multiple: no
  65. ##% description: Name of graphics monitor to select
  66. ##%End
  67. ##%Option
  68. ##% key: unlock
  69. ##% type: string
  70. ##% required: no
  71. ##% multiple: no
  72. ##% description: Name of graphics monitor to unlock
  73. ##%End
  74. import os
  75. import grass.script as grass
  76. def main():
  77. start = options["start"]
  78. # select = options["select"]
  79. # stop = options["stop"]
  80. # unlock = options["unlock"]
  81. # create the command file
  82. command_file = grass.tempfile()
  83. os.system("g.gisenv set=GRASS_PYCMDFILE=%s" % command_file)
  84. if start != "":
  85. os.spawnlp(os.P_NOWAIT, os.environ["GRASS_PYTHON"], os.environ["GRASS_PYTHON"], "%s/etc/wxpython/gui_modules/mapdisp.py" % os.environ["GISBASE"], start, command_file)
  86. return
  87. # if stop != "" or select != "" or unlock != "":
  88. # grass.message(_("Not implemented yet"), "w")
  89. if __name__ == "__main__":
  90. options, flags = grass.parser()
  91. main()