Opened 7 years ago
Last modified 6 years ago
#3338 new defect
UnicodeDecodeError when registering maps in a STRDS using a translated version of GRASS
| Reported by: | lrntct | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.2.4 |
| Component: | Temporal | Version: | 7.2.0 |
| Keywords: | translation UnicodeDecodeError | Cc: | |
| CPU: | x86-64 | Platform: | Linux |
Description
Using a Spanish locale, the following error appears when trying to register maps in a STRDS using the python interface:
Registrando mapas en conjunto de datos espacio temporales...
Actualizando conjunto de datos temporales...
Traceback (most recent call last):
File "Documentos/tarea_6_5_Roberta.py", line 131, in <module>
sys.exit(main())
File "Documentos/tarea_6_5_Roberta.py", line 79, in main
register_maps_in_strds(TITULO_STRDS, ID_STRDS, DESC_STRDS, list_nombre_fecha)
File "Documentos/tarea_6_5_Roberta.py", line 98, in register_maps_in_strds
tgis.register.register_map_object_list('raster', map_dts_lst, stds, delete_empty=True, unit=None)
File "/usr/lib/grass72/etc/python/grass/temporal/register.py", line 499, in register_map_object_list
file=filename, dbif=dbif)
File "/usr/lib/grass72/etc/python/grass/temporal/register.py", line 341, in register_maps_in_space_time_dataset
sp.update_from_registered_maps(dbif)
File "/usr/lib/grass72/etc/python/grass/temporal/abstract_space_time_dataset.py", line 2282, in update_from_registered_maps
" all registered maps of <%s>") % (self.get_id()))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 28: ordinal not in range(128)
Changing the system settings to English fix the issue.
Attachments (1)
Change History (6)
comment:1 by , 7 years ago
by , 7 years ago
| Attachment: | python_temporal_fix.diff added |
|---|
Remove gettext macros from debug messages
comment:2 by , 7 years ago
Attached a patch to remove undesired gettext macros from debug messages - a will guess: does it help?
comment:5 by , 6 years ago
| Milestone: | → 7.2.4 |
|---|
Note:
See TracTickets
for help on using tickets.

Below is a minimum working example. Try to run it with a Spanish locale, it will fail. In English, it will run OK.
import grass.temporal as tgis import grass.script as gscript import grass.pygrass.utils as gutils def create_map_list(): """Create a list with random raster maps""" map_list = [] for i in range(5): map_name = 'map_test{}'.format(i) map_id = '{}@{}'.format(map_name, gutils.getenv('MAPSET')) # create random raster map gscript.run_command('r.random.surface', output=map_name, overwrite=OVR) # populate list map_list.append((map_id, i)) return map_list def register_maps_in_stds(stds_id, map_list): """Create a STDS, create one RasterDataset for each map and register them in the temporal database """ # create stds stds = tgis.open_new_stds(stds_id, 'strds', 'relative', "test", "", "mean", overwrite=OVR) # populate MapDataset objects list map_dts_lst = [] for map_id, map_time in map_list: # create MapDataset map_dts = tgis.RasterDataset(map_id) # load spatial data from map map_dts.load() # set time map_dts.set_relative_time(map_time, None, 'seconds') # populate the list map_dts_lst.append(map_dts) # Register the maps tgis.register.register_map_object_list('raster', map_dts_lst, stds, delete_empty=True, unit='seconds') tgis.init() register_maps_in_stds('strds_test', create_map_list())