~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to scripts/d.out.file/d.out.file.py

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
############################################################################
 
4
#
 
5
# MODULE: d.out.file
 
6
# AUTHOR(S): Anna Petrasova <kratochanna gmail.com>
 
7
# PURPOSE:      Script for exporting content of monitor to graphic file
 
8
# COPYRIGHT: (C) 2014 by the GRASS Development Team
 
9
#
 
10
#               This program is free software under the GNU General
 
11
#               Public License (>=v2). Read the file COPYING that
 
12
#               comes with GRASS for details.
 
13
#
 
14
#############################################################################
 
15
 
 
16
#%module
 
17
#% description: Saves the contents of the active display monitor to a graphics file.
 
18
#% keyword: display
 
19
#% keyword: export
 
20
#%end
 
21
#%option G_OPT_F_OUTPUT
 
22
#% description: Name for output file
 
23
#% required: yes
 
24
#%end
 
25
#%option
 
26
#% key: format
 
27
#% description: Graphics file format
 
28
#% required: yes
 
29
#% options: png,jpg,bmp,gif,tif
 
30
#% answer: png
 
31
#%end
 
32
#%option
 
33
#% key: size
 
34
#% type: integer
 
35
#% key_desc: width,height
 
36
#% description: Width and height of output image
 
37
#% guisection: Images
 
38
#% required : no
 
39
#%end
 
40
 
 
41
from grass.script import core as gcore
 
42
 
 
43
 
 
44
def main():
 
45
    options, flags = gcore.parser()
 
46
    gisenv = gcore.gisenv()
 
47
    if 'MONITOR' in gisenv:
 
48
        cmd_file = gisenv['MONITOR_{monitor}_CMDFILE'.format(monitor=gisenv['MONITOR'].upper())]
 
49
        dout_cmd = 'd.out.file'
 
50
        for param, val in options.iteritems():
 
51
            if val:
 
52
                dout_cmd += " {param}={val}".format(param=param, val=val)
 
53
        with open(cmd_file, "a") as file_:
 
54
            file_.write(dout_cmd)
 
55
    else:
 
56
        gcore.fatal(_("No graphics device selected. Use d.mon to select graphics device."))
 
57
 
 
58
 
 
59
if __name__ == "__main__":
 
60
    main()