Update of /cvsroot/monetdb/clients/src/python
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10319/src/python
Modified Files:
mclient.py.in
Log Message:
propagated changes of Friday Nov 30 2007 - Tuesday Dec 04 2007
from the Clients_1-20 branch to the development trunk
Index: mclient.py.in
===================================================================
RCS file: /cvsroot/monetdb/clients/src/python/mclient.py.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- mclient.py.in 11 Sep 2007 11:11:40 -0000 1.2
+++ mclient.py.in 4 Dec 2007 12:53:25 -0000 1.3
@@ -38,6 +38,7 @@
('language',None,'language','language','language (default: sql)'),
('database',None,'database','database','database (default: "")'),
('mapi_trace',None,'mapi_trace', None, 'mapi_trace'),
+ ('encoding',None,'encoding','encoding','character encoding'),
]
try:
@@ -46,13 +47,20 @@
# error parsing options
sys.exit(1)
+ encoding = opt.get("encoding", None)
+ if encoding is None:
+ import locale
+ encoding = locale.getlocale()[1]
+ if encoding is None:
+ encoding = locale.getdefaultlocale()[1]
+
s = server(opt.get("host", "localhost"),
int(opt.get("mapi_port", 50000)),
opt.get("user", "monetdb"),
opt.get("passwd", "monetdb"),
opt.get("language", "sql"),
opt.get("database", ""),
- opt.get("mapi_trace", None)!=None)
+ opt.get("mapi_trace", None) is not None)
print "#mclient (python) connected to %s:%d as %s" % \
(opt.get("host", "localhost"),
int(opt.get("mapi_port", 50000)),
@@ -63,10 +71,17 @@
sys.stdout.write(s.prompt.encode('utf-8'))
line = fi.readline()
+ prompt = s.prompt
+ if encoding != 'utf-8':
+ prompt = unicode(prompt, 'utf-8').encode(encoding, 'replace')
while line and line != "\q\n":
+ if encoding != 'utf-8':
+ line = unicode(line, encoding).encode('utf-8')
res = s.cmd(line)
+ if encoding != 'utf-8':
+ res = unicode(res, 'utf-8').encode(encoding, 'replace')
print res
- sys.stdout.write(s.prompt.encode('utf-8'))
+ sys.stdout.write(prompt)
line = fi.readline()
s.disconnect()
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins