[GRASS-dev] [GRASS-SVN] r60679 - grass/trunk/lib/python/script

Anna Petrášová kratochanna at gmail.com
Wed Jul 2 08:37:34 PDT 2014


On Wed, Jul 2, 2014 at 11:19 AM, Anna Petrášová <kratochanna at gmail.com>
wrote:

>
>
>
> On Wed, Jul 2, 2014 at 10:59 AM, Vaclav Petras <wenzeslaus at gmail.com>
> wrote:
>
>>
>> On Wed, Jul 2, 2014 at 10:39 AM, Martin Landa <landa.martin at gmail.com>
>> wrote:
>>
>>> The reason is empty XML wxGUI menu file (menudata.xml) produced by
>>> building system, see [2].
>>>
>>> Traceback (most recent call last):
>>>   File "core/toolboxes.py", line 759, in <module>
>>>     sys.exit(main())
>>>   File "core/toolboxes.py", line 745, in main
>>>     userDefined=False)
>>>   File "core/toolboxes.py", line 204, in createTree
>>>     moduleItems=moduleItems)
>>>   File "core/toolboxes.py", line 241, in toolboxes2menudata
>>>     _expandRuntimeModules(root)
>>>   File "core/toolboxes.py", line 514, in _expandRuntimeModules
>>>     desc, keywords = _loadMetadata(name)
>>>   File "core/toolboxes.py", line 540, in _loadMetadata
>>>     task = gtask.parse_interface(module)
>>>   File
>>> "c:\osgeo4w\usr\src\grass_trunk\dist.i686-pc-mingw32\etc\python\grass\script\task.py",
>>> line 501, in parse_interface
>>>     tree = etree.fromstring(get_interface_description(name))
>>>   File
>>> "c:\osgeo4w\usr\src\grass_trunk\dist.i686-pc-mingw32\etc\python\grass\script\task.py",
>>> line 465, in get_interface_description
>>>     stderr = PIPE)
>>>   File
>>> "c:\osgeo4w\usr\src\grass_trunk\dist.i686-pc-mingw32\etc\python\grass\script\core.py",
>>> line 58, in __init__
>>>     name, ext = os.path.splitext(cmd)
>>>   File "c:/OSGeo4W/apps/Python27\lib\ntpath.py", line 190, in splitext
>>>     return genericpath._splitext(p, sep, altsep, extsep)
>>>   File "c:/OSGeo4W/apps/Python27\lib\genericpath.py", line 91, in
>>> _splitext
>>>     sepIndex = p.rfind(sep)
>>> AttributeError: 'NoneType' object has no attribute 'rfind'
>>> make[4]: *** [xml/menudata.xml] Error 1
>>>
>>
>> It's because it can't find v.in.gps. I suggest to add to the patch
> something like this:
>
> +    def __init__(self, args, **kwargs):
> +        if ( sys.platform == 'win32'
> +             and isinstance(args, list)
> +             and not kwargs.get('shell', False)
> +             and kwargs.get('executable') is None ):
> +            cmd = shutil_which(args[0])
>               if cmd is None:
>                   raise OSError
> +            args = [cmd] + args[1:]
> +            name, ext = os.path.splitext(cmd)
> +            if ext.lower() not in self._builtin_exts:
> +                kwargs['shell'] = True
> +                args = [self._escape_for_shell(arg) for arg in args]
> +        subprocess.Popen.__init__(self, args, **kwargs)
>

Otherwise the patch seems to work, I can run:
grass.run_command('r.support', map='mymap', title="|@#~$%^&*()><") in GUI
python console which was not possible before. r.info then gives correct
result.

Running this command in gui console works but r.info gives incorrect result:
r.support map=scanned title="|@#$%^&*()"
and r.info gives ^^^|@#$%^^^^^^^&*()

but gui command line functionality was not affected by this patch, it uses
different popen class, this is related to r60634 and following.


>
>
>
>>  It seems that shutil_which returned None at line (from the patch):
>>
>> cmd = shutil_which(args[0])
>>
>> _______________________________________________
>> grass-dev mailing list
>> grass-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/grass-dev
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20140702/33d71309/attachment-0001.html>


More information about the grass-dev mailing list