diff --git a/gui/wxpython/core/gcmd.py b/gui/wxpython/core/gcmd.py index 871f19d0c5a..57ca2109059 100644 --- a/gui/wxpython/core/gcmd.py +++ b/gui/wxpython/core/gcmd.py @@ -162,9 +162,6 @@ class Popen(subprocess.Popen): def __init__(self, args, **kwargs): if is_mswindows: - # encoding not needed for Python3 - # args = list(map(EncodeString, args)) - # The Windows shell (cmd.exe) requires some special characters to # be escaped by preceding them with 3 carets (^^^). cmd.exe /? # mentions and &()[]{}^=;!'+,`~. A quick test revealed that diff --git a/gui/wxpython/core/render.py b/gui/wxpython/core/render.py index 0f02ef342f5..092dd4c19de 100644 --- a/gui/wxpython/core/render.py +++ b/gui/wxpython/core/render.py @@ -40,7 +40,7 @@ from core import utils from core.ws import RenderWMSMgr -from core.gcmd import GException, GError, RunCommand, EncodeString +from core.gcmd import GException, GError, RunCommand from core.debug import Debug from core.settings import UserSettings from core.gthread import gThread @@ -1297,8 +1297,7 @@ def AddLayer(self, ltype, command, name=None, renderMgr = layer.GetRenderMgr() Debug.msg( 1, "Map.AddLayer(): ltype={0}, command={1}".format( - ltype, EncodeString(layer.GetCmd( - string=True)))) + ltype, layer.GetCmd(string=True))) if renderMgr: if layer.type == 'wms': renderMgr.dataFetched.connect(self.renderMgr.ReportProgress) @@ -1360,7 +1359,7 @@ def DeleteLayer(self, layer, overlay=False): def SetLayers(self, layers): self.layers = layers - Debug.msg(5, "Map.SetLayers(): layers={0}".format([EncodeString(layer.GetCmd(string=True)) for layer in layers])) + Debug.msg(5, "Map.SetLayers(): layers={0}".format([layer.GetCmd(string=True) for layer in layers])) def ChangeLayer(self, layer, render=False, **kargs): """Change map layer properties @@ -1510,9 +1509,7 @@ def AddOverlay(self, id, ltype, command, renderMgr = overlay.GetRenderMgr() Debug.msg( - 1, "Map.AddOverlay(): cmd={0}".format(EncodeString( - overlay.GetCmd( - string=True)))) + 1, "Map.AddOverlay(): cmd={0}".format(overlay.GetCmd(string=True))) if renderMgr: renderMgr.updateProgress.connect(self.renderMgr.ReportProgress) renderMgr.renderingFailed.connect(self.renderMgr.RenderingFailed) diff --git a/gui/wxpython/gcp/manager.py b/gui/wxpython/gcp/manager.py index 685f244f1a2..f3465ef308a 100644 --- a/gui/wxpython/gcp/manager.py +++ b/gui/wxpython/gcp/manager.py @@ -54,7 +54,7 @@ from core.render import Map from gui_core.gselect import Select, LocationSelect, MapsetSelect from gui_core.dialogs import GroupDialog -from core.gcmd import RunCommand, GMessage, GError, GWarning, EncodeString +from core.gcmd import RunCommand, GMessage, GError, GWarning from core.settings import UserSettings from gcp.mapdisplay import MapFrame from core.giface import Notification @@ -296,7 +296,7 @@ def SetSrcEnv(self, location, mapset): self.gisrc_dict['LOCATION_NAME'] = location self.gisrc_dict['MAPSET'] = mapset - self.source_gisrc = EncodeString(utils.GetTempfile()) + self.source_gisrc = utils.GetTempfile() try: f = open(self.source_gisrc, mode='w') diff --git a/gui/wxpython/gmodeler/dialogs.py b/gui/wxpython/gmodeler/dialogs.py index c6fa732ed26..dccd105b0f3 100644 --- a/gui/wxpython/gmodeler/dialogs.py +++ b/gui/wxpython/gmodeler/dialogs.py @@ -33,7 +33,7 @@ from core import globalvar from core import utils from gui_core.widgets import SearchModuleWidget, SimpleValidator -from core.gcmd import GError, EncodeString +from core.gcmd import GError from gui_core.dialogs import SimpleDialog, MapLayersDialogForModeler from gui_core.prompt import GPromptSTC from gui_core.gselect import Select, ElementSelect @@ -274,10 +274,7 @@ def _getCmd(self): if len(line) == 0: cmd = list() else: - try: - cmd = utils.split(str(line)) - except UnicodeError: - cmd = utils.split(EncodeString((line))) + cmd = utils.split(str(line)) return cmd def GetCmd(self): diff --git a/gui/wxpython/gmodeler/model.py b/gui/wxpython/gmodeler/model.py index 41385281f09..4e7340f4c7b 100644 --- a/gui/wxpython/gmodeler/model.py +++ b/gui/wxpython/gmodeler/model.py @@ -46,7 +46,7 @@ from core import globalvar from core import utils -from core.gcmd import GMessage, GException, GError, RunCommand, EncodeString, GWarning, GetDefaultEncoding +from core.gcmd import GMessage, GException, GError, RunCommand, GWarning, GetDefaultEncoding from core.settings import UserSettings from gui_core.forms import GUI, CmdPanel from gui_core.widgets import GNotebook @@ -2249,22 +2249,19 @@ def _properties(self): '%s%s\n' % (' ' * self.indent, - EncodeString( - self.properties['name']))) + self.properties['name'])) if self.properties['description']: self.fd.write( '%s%s\n' % (' ' * self.indent, - EncodeString( - self.properties['description']))) + self.properties['description'])) if self.properties['author']: self.fd.write( '%s%s\n' % (' ' * self.indent, - EncodeString( - self.properties['author']))) + self.properties['author'])) if 'overwrite' in self.properties and \ self.properties['overwrite']: @@ -2283,15 +2280,15 @@ def _variables(self): for name, values in six.iteritems(self.variables): self.fd.write( '%s\n' % - (' ' * self.indent, EncodeString(name), values['type'])) + (' ' * self.indent, name, values['type'])) self.indent += 4 if 'value' in values: self.fd.write('%s%s\n' % - (' ' * self.indent, EncodeString(values['value']))) + (' ' * self.indent, values['value'])) if 'description' in values: self.fd.write( '%s%s\n' % - (' ' * self.indent, EncodeString(values['description']))) + (' ' * self.indent, values['description'])) self.indent -= 4 self.fd.write('%s\n' % (' ' * self.indent)) self.indent -= 4 @@ -2313,21 +2310,19 @@ def _action(self, action): """Write actions""" self.fd.write( '%s\n' % - (' ' * - self.indent, + (' ' * self.indent, action.GetId(), - EncodeString( - action.GetLabel()), - action.GetX(), - action.GetY(), - action.GetWidth(), - action.GetHeight())) + action.GetLabel(), + action.GetX(), + action.GetY(), + action.GetWidth(), + action.GetHeight())) self.indent += 4 comment = action.GetComment() if comment: self.fd.write( '%s%s\n' % - (' ' * self.indent, EncodeString(comment))) + (' ' * self.indent, comment)) self.fd.write('%s\n' % (' ' * self.indent, action.GetLog(string=False)[0])) self.indent += 4 @@ -2503,8 +2498,7 @@ def _comment(self, comment): comment.GetY(), comment.GetWidth(), comment.GetHeight(), - EncodeString( - comment.GetLabel()))) + comment.GetLabel())) class WritePythonFile: @@ -2556,10 +2550,9 @@ def _writePython(self): # #{header_end} """.format(header_begin='#' * 77, - module_name=EncodeString(properties['name']), - author=EncodeString(properties['author']), - purpose=EncodeString( - '\n# '.join(properties['description'].splitlines())), + module_name=properties['name'], + author=properties['author'], + purpose='\n# '.join(properties['description'].splitlines()), date=time.asctime(), header_end='#' * 77)) @@ -2569,8 +2562,7 @@ def _writePython(self): #%module #% description: {description} #%end -""".format(description=EncodeString( - ' '.join(properties['description'].splitlines())))) +""".format(description=' '.join(properties['description'].splitlines()))) modelItems = self.model.GetItems() for item in modelItems: diff --git a/gui/wxpython/gui_core/goutput.py b/gui/wxpython/gui_core/goutput.py index 72a9a5dc373..a144bd13f4e 100644 --- a/gui/wxpython/gui_core/goutput.py +++ b/gui/wxpython/gui_core/goutput.py @@ -432,7 +432,7 @@ def OnOutputSave(self, event): try: output = open(path, "w") - output.write(EncodeString(text)) + output.write(text) except IOError as e: GError( _("Unable to write file '%(path)s'.\n\nDetails: %(error)s") % { diff --git a/gui/wxpython/gui_core/pyedit.py b/gui/wxpython/gui_core/pyedit.py index daa41ecbcbd..e2ac420aac2 100644 --- a/gui/wxpython/gui_core/pyedit.py +++ b/gui/wxpython/gui_core/pyedit.py @@ -29,7 +29,7 @@ from grass.script.setup import set_gui_path set_gui_path() -from core.gcmd import EncodeString, GError +from core.gcmd import GError from gui_core.pystc import PyStc from core import globalvar from core.menutree import MenuTreeModelBuilder @@ -89,9 +89,9 @@ def module_template(): # #%s """ % ('#' * 72, - EncodeString(properties['name']), - EncodeString(properties['author']), - EncodeString('\n# '.join(properties['description'].splitlines())), + properties['name'], + properties['author'], + '\n# '.join(properties['description'].splitlines()), time.asctime(), '#' * 72)) @@ -101,7 +101,7 @@ def module_template(): #%%module #%% description: %s #%%end -""" % (EncodeString(' '.join(properties['description'].splitlines())))) +""" % (' '.join(properties['description'].splitlines()))) # import modules output.write( diff --git a/gui/wxpython/image2target/ii2t_manager.py b/gui/wxpython/image2target/ii2t_manager.py index 8c120c0e501..ae081ad3554 100644 --- a/gui/wxpython/image2target/ii2t_manager.py +++ b/gui/wxpython/image2target/ii2t_manager.py @@ -57,7 +57,7 @@ from core.render import Map from gui_core.gselect import Select, LocationSelect, MapsetSelect from gui_core.dialogs import GroupDialog -from core.gcmd import RunCommand, GMessage, GError, GWarning, EncodeString +from core.gcmd import RunCommand, GMessage, GError, GWarning from core.settings import UserSettings from gcp.mapdisplay import MapFrame from core.giface import Notification @@ -323,7 +323,7 @@ def SetSrcEnv(self, location, mapset): self.gisrc_dict['LOCATION_NAME'] = location self.gisrc_dict['MAPSET'] = mapset - self.source_gisrc = EncodeString(utils.GetTempfile()) + self.source_gisrc = utils.GetTempfile() try: f = open(self.source_gisrc, mode='w') diff --git a/gui/wxpython/lmgr/frame.py b/gui/wxpython/lmgr/frame.py index c4ed9c269a7..0a40c68c171 100644 --- a/gui/wxpython/lmgr/frame.py +++ b/gui/wxpython/lmgr/frame.py @@ -44,7 +44,7 @@ from grass.script import core as grass from grass.script.utils import decode -from core.gcmd import RunCommand, GError, GMessage, EncodeString +from core.gcmd import RunCommand, GError, GMessage from core.settings import UserSettings, GetDisplayVectSettings from core.utils import SetAddOnPath, GetLayerNameFromCmd, command2ltype from gui_core.preferences import MapsetAccess, PreferencesDialog @@ -976,15 +976,6 @@ def OnRunScript(self, event): if not filename: return False - try: - filename_encoded = EncodeString(filename) - except UnicodeEncodeError: - GError( - parent=self, message=_( - "Due to the limitations of your operating system, " - "the script path cannot contain certain non-ascii characters. " - "Please rename the script or move it to a different location.")) - return if not os.path.exists(filename): GError(parent=self, @@ -1020,7 +1011,7 @@ def OnRunScript(self, event): addonPath = os.getenv('GRASS_ADDON_PATH', []) if addonPath: addonPath = addonPath.split(os.pathsep) - dirName = os.path.dirname(filename_encoded) + dirName = os.path.dirname(filename) if dirName not in addonPath: addonPath.append(dirName) dlg = wx.MessageDialog( diff --git a/gui/wxpython/nviz/wxnviz.py b/gui/wxpython/nviz/wxnviz.py index 5c1c0774cd0..e71c04eac36 100644 --- a/gui/wxpython/nviz/wxnviz.py +++ b/gui/wxpython/nviz/wxnviz.py @@ -59,7 +59,7 @@ from core.debug import Debug from core.utils import autoCropImageFromFile -from core.gcmd import EncodeString, DecodeString +from core.gcmd import DecodeString from core.globalvar import wxPythonPhoenix from gui_core.wrap import Rect import grass.script as grass @@ -1847,7 +1847,6 @@ def SaveToFile(self, filename, width=20, height=20, itype='ppm'): """ widthOrig = self.width heightOrig = self.height - filename = EncodeString(filename) self.ResizeWindow(width, height) GS_clear(Nviz_get_bgcolor(self.data)) diff --git a/gui/wxpython/photo2image/ip2i_manager.py b/gui/wxpython/photo2image/ip2i_manager.py index 24ea3ff5dfb..4c7fe1c8299 100644 --- a/gui/wxpython/photo2image/ip2i_manager.py +++ b/gui/wxpython/photo2image/ip2i_manager.py @@ -49,7 +49,7 @@ from core.render import Map from gui_core.gselect import Select, LocationSelect, MapsetSelect from gui_core.dialogs import GroupDialog -from core.gcmd import RunCommand, GMessage, GError, GWarning, EncodeString +from core.gcmd import RunCommand, GMessage, GError, GWarning from core.settings import UserSettings from photo2image.ip2i_mapdisplay import MapFrame from core.giface import Notification @@ -235,7 +235,7 @@ def SetSrcEnv(self, location, mapset): self.gisrc_dict['LOCATION_NAME'] = location self.gisrc_dict['MAPSET'] = mapset - self.source_gisrc = EncodeString(utils.GetTempfile()) + self.source_gisrc = utils.GetTempfile() try: f = open(self.source_gisrc, mode='w')