convert 8 bit strings to unicode before running the query
This commit is contained in:
parent
8dd3219237
commit
98bea3fbd9
2 changed files with 7 additions and 3 deletions
|
@ -105,6 +105,7 @@ class Scope (Unity.Scope):
|
||||||
|
|
||||||
self.last_connect_time = 0
|
self.last_connect_time = 0
|
||||||
self.timeout_id = None
|
self.timeout_id = None
|
||||||
|
language, self.localecharset = locale.getdefaultlocale()
|
||||||
|
|
||||||
def _connect_db(self):
|
def _connect_db(self):
|
||||||
#print "Connecting to db"
|
#print "Connecting to db"
|
||||||
|
@ -230,7 +231,7 @@ class Scope (Unity.Scope):
|
||||||
# Do the recoll thing
|
# Do the recoll thing
|
||||||
try:
|
try:
|
||||||
query = self.db.query()
|
query = self.db.query()
|
||||||
nres = query.execute(search_string)
|
nres = query.execute(search_string.decode(self.localecharset))
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
"""A python version of the command line query tool recollq (a bit simplified)
|
"""A python version of the command line query tool recollq (a bit simplified)
|
||||||
The input string is always interpreted as a query language string.
|
The input string is always interpreted as a query language string.
|
||||||
This could actually be useful for something after some customization
|
This could actually be useful for something after some customization
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import locale
|
||||||
from getopt import getopt
|
from getopt import getopt
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -93,6 +95,7 @@ def doquery(db, q):
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
Usage()
|
Usage()
|
||||||
|
|
||||||
|
language, localecharset = locale.getdefaultlocale()
|
||||||
confdir=""
|
confdir=""
|
||||||
extra_dbs = []
|
extra_dbs = []
|
||||||
# Snippet params
|
# Snippet params
|
||||||
|
@ -113,9 +116,9 @@ for opt,val in options:
|
||||||
if len(args) == 0:
|
if len(args) == 0:
|
||||||
print >> sys.stderr, "No query found in command line"
|
print >> sys.stderr, "No query found in command line"
|
||||||
Usage()
|
Usage()
|
||||||
q = ""
|
q = u''
|
||||||
for word in args:
|
for word in args:
|
||||||
q += word + " "
|
q += word.decode(localecharset) + u' '
|
||||||
|
|
||||||
print "QUERY: [", q, "]"
|
print "QUERY: [", q, "]"
|
||||||
db = recoll.connect(confdir=confdir,
|
db = recoll.connect(confdir=confdir,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue