示例#1
0
def main():
    mon = grass.gisenv().get('MONITOR', None)
    if not mon:
        grass.fatal(
            _("No graphics device selected. Use d.mon to select graphics device."
              ))

    monCmd = grass.parse_command('d.mon', flags='g').get('cmd', None)
    if not monCmd or not os.path.isfile(monCmd):
        grass.fatal(_("Unable to open file '%s'") % monCmd)

    try:
        fd = open(monCmd, 'r')
        cmdList = fd.readlines()

        grass.run_command('d.erase')

        for cmd in cmdList:
            grass.call(split(cmd))
    except IOError as e:
        grass.fatal(_("Unable to open file '%s' for reading. Details: %s") % \
                        (monCmd, e))

    fd.close()

    # restore cmd file
    try:
        fd = open(monCmd, "w")
        fd.writelines(cmdList)
    except IOError as e:
        grass.fatal(_("Unable to open file '%s' for writing. Details: %s") % \
                        (monCmd, e))

    return 0
示例#2
0
def main():
    mon = grass.gisenv().get('MONITOR', None)
    if not mon:
        grass.fatal(_("No graphics device selected. Use d.mon to select graphics device."))

    monCmd = grass.parse_command('d.mon', flags='g').get('cmd', None)
    if not monCmd or not os.path.isfile(monCmd):
        grass.fatal(_("Unable to open file '%s'") % monCmd)

    try:
        fd = open(monCmd, 'r')
        cmdList = fd.readlines()

        grass.run_command('d.erase')

        for cmd in cmdList:
            grass.call(split(cmd))
    except IOError as e:
        grass.fatal(_("Unable to open file '%s' for reading. Details: %s") %
                    (monCmd, e))

    fd.close()

    # restore cmd file
    try:
        fd = open(monCmd, "w")
        fd.writelines(cmdList)
    except IOError as e:
        grass.fatal(_("Unable to open file '%s' for writing. Details: %s") %
                    (monCmd, e))

    return 0
示例#3
0
def main():
    mon = grass.gisenv().get("MONITOR", None)
    if not mon:
        grass.fatal(
            _("No graphics device selected. Use d.mon to select graphics device."
              ))

    monCmd = grass.parse_command("d.mon", flags="g").get("cmd", None)
    if not monCmd or not os.path.isfile(monCmd):
        grass.fatal(_("Unable to open file '%s'") % monCmd)

    try:
        fd = open(monCmd, "r")
        cmdList = fd.readlines()

        grass.run_command("d.erase")

        for cmd in cmdList:
            if cmd.startswith("#"):
                continue
            grass.call(split(cmd))
    except IOError as e:
        grass.fatal(
            _("Unable to open file '%s' for reading. Details: %s") %
            (monCmd, e))

    fd.close()

    # restore cmd file
    try:
        fd = open(monCmd, "w")
        fd.writelines(cmdList)
    except IOError as e:
        grass.fatal(
            _("Unable to open file '%s' for writing. Details: %s") %
            (monCmd, e))

    return 0