[GRASS-SVN] r58224 - grass/trunk/lib/init
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Nov 15 07:13:52 PST 2013
Author: glynn
Date: 2013-11-15 07:13:51 -0800 (Fri, 15 Nov 2013)
New Revision: 58224
Modified:
grass/trunk/lib/init/grass.py
Log:
Revert r58200 for grass.py
Modified: grass/trunk/lib/init/grass.py
===================================================================
--- grass/trunk/lib/init/grass.py 2013-11-14 20:58:04 UTC (rev 58223)
+++ grass/trunk/lib/init/grass.py 2013-11-15 15:13:51 UTC (rev 58224)
@@ -33,8 +33,6 @@
import re
import platform
import tempfile
-import codecs
-import locale
# Variables substituted during build process
if 'GISBASE' in os.environ:
@@ -137,24 +135,15 @@
sys.stderr.flush()
-def openfile(path, mode='r'):
- enc = locale.getdefaultlocale()[1]
- if enc:
- f = codecs.open(path, encoding=enc, mode=mode)
- else:
- f = open(path, mode)
-
- return f
-
def readfile(path):
- f = openfile(path, 'r')
+ f = open(path, 'r')
s = f.read()
f.close()
return s
def writefile(path, s):
- f = openfile(path, 'w')
+ f = open(path, 'w')
f.write(s)
f.close()
@@ -249,7 +238,6 @@
tmp = os.getenv('TMP')
if not tmp:
tmp = tempfile.gettempdir()
-
if tmp:
tmpdir = os.path.join(tmp, "grass7-%(user)s-%(lock)s" % {'user': user,
'lock': gis_lock})
@@ -277,11 +265,7 @@
global gisrc, gisrcrc
# Set the session grassrc file
gisrc = os.path.join(tmpdir, "gisrc")
- enc = locale.getdefaultlocale()[1]
- if enc:
- os.environ['GISRC'] = gisrc.encode(enc)
- else:
- os.environ['GISRC'] = gisrc
+ os.environ['GISRC'] = gisrc
# remove invalid GISRC file to avoid disturbing error messages:
try:
@@ -300,7 +284,7 @@
def read_gisrc():
kv = {}
try:
- f = openfile(gisrc, 'r')
+ f = open(gisrc, 'r')
except IOError:
return kv
@@ -314,7 +298,7 @@
def read_env_file(path):
kv = {}
- f = openfile(path, 'r')
+ f = open(path, 'r')
for line in f:
k, v = line.split(':', 1)
kv[k.strip()] = v.strip()
@@ -323,7 +307,7 @@
def write_gisrc(kv):
- f = openfile(gisrc, 'w')
+ f = open(gisrc, 'w')
for k, v in kv.iteritems():
f.write("%s: %s\n" % (k, v))
f.close()
@@ -835,10 +819,6 @@
# Check for concurrent use
lockfile = os.path.join(location, ".gislock")
- enc = locale.getdefaultlocale()[1]
- if enc:
- lockfile = lockfile.encode(enc)
-
ret = call([gfile("etc", "lock"), lockfile, "%d" % os.getpid()])
if ret == 0:
msg = None
@@ -1009,7 +989,7 @@
try_remove(cshrc)
try_remove(tcshrc)
- f = openfile(cshrc, 'w')
+ f = open(cshrc, 'w')
f.write("set home = %s\n" % userhome)
f.write("set history = 3000 savehist = 3000 noclobber ignoreeof\n")
f.write("set histfile = %s\n" % os.path.join(os.getenv('HOME'),
@@ -1066,7 +1046,7 @@
bashrc = os.path.join(home, ".bashrc")
try_remove(bashrc)
- f = openfile(bashrc, 'w')
+ f = open(bashrc, 'w')
f.write("test -r ~/.alias && . ~/.alias\n")
if os.getenv('ISISROOT'):
f.write("PS1='ISIS-GRASS %s (%s):\w > '\n" % (grass_version, location_name))
@@ -1135,7 +1115,7 @@
def print_params():
plat = gfile(gisbase, 'include', 'Make', 'Platform.make')
- fileplat = openfile(plat, 'r')
+ fileplat = open(plat)
linesplat = fileplat.readlines()
fileplat.close()
@@ -1151,7 +1131,7 @@
sys.stdout.write("%s\n" % val[0].split('=')[1].strip())
elif arg == 'build':
build = os.path.join(gisbase,'include','grass','confparms.h')
- filebuild = openfile(build, 'r')
+ filebuild = open(build)
val = filebuild.readline()
filebuild.close()
sys.stdout.write("%s\n" % val.strip().strip('"').strip())
@@ -1160,7 +1140,7 @@
sys.stdout.write("%s\n" % val[0].split('=')[1].strip())
elif arg == 'revision':
rev = os.path.join(gisbase,'include','grass','gis.h')
- filerev = openfile(rev, 'r')
+ filerev = open(rev)
linesrev = filerev.readlines()
val = grep('#define GIS_H_VERSION', linesrev)
filerev.close()
@@ -1189,10 +1169,6 @@
pass
if not user:
user = "user_%d" % os.getuid()
-
- enc = locale.getdefaultlocale()[1]
- if enc:
- user = user.decode(enc)
def parse_cmdline():
More information about the grass-commit
mailing list