giface.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. """!
  2. @package core.giface
  3. @brief GRASS interface for standalone application (without layer manager)
  4. Classes:
  5. - giface::StandaloneGrassInterface
  6. (C) 2012 by the GRASS Development Team
  7. This program is free software under the GNU General Public License
  8. (>=v2). Read the file COPYING that comes with GRASS for details.
  9. @author Anna Kratochvilova <kratochanna gmail.com>
  10. @author Vaclav Petras <wenzeslaus gmail.com>
  11. """
  12. from core.gcmd import RunCommand
  13. from core.utils import CmdToTuple
  14. import grass.script as grass
  15. class StandaloneGrassInterface():
  16. def RunCmd(self, command,
  17. onDone = None, onPrepare = None, userData = None, **kwargs):
  18. if onPrepare:
  19. onPrepare(userData)
  20. cmdTuple = CmdToTuple(command)
  21. returncode = RunCommand(cmdTuple[0], **cmdTuple[1])
  22. if onDone:
  23. onDone(cmd = command, returncode = returncode)
  24. def Help(self, entry):
  25. RunCommand('g.manual', quiet = True, entry = entry)
  26. def WriteLog(self, text, wrap = None,
  27. switchPage = False, priority = 1):
  28. grass.message(text)
  29. def WriteCmdLog(self, line, pid = None, switchPage = True):
  30. grass.message(line)
  31. def WriteWarning(self, line):
  32. grass.warning(line)
  33. def WriteError(self, line):
  34. grass.error(line)
  35. def GetLayerTree(self):
  36. return None
  37. def GetMapDisplay(self):
  38. """!Get current map display.
  39. """
  40. return None
  41. def GetAllMapDisplays(self):
  42. """!Get list of all map displays.
  43. """
  44. return []