Switch to unified view

a/src/mediaserver/cdplugins/uprcl/uprcl-app.py b/src/mediaserver/cdplugins/uprcl/uprcl-app.py
...
...
16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
17
18
import sys
18
import sys
19
import os
19
import os
20
import json
20
import json
21
import posixpath
22
import re
21
import re
23
import conftree
22
import conftree
24
import cmdtalkplugin
23
import cmdtalkplugin
25
import urllib
26
import threading
24
import threading
27
import subprocess
25
import subprocess
28
26
29
import uprclfolders
27
import uprclfolders
30
import uprcltags
28
import uprcltags
31
import uprcluntagged
29
import uprcluntagged
32
import uprclsearch
30
import uprclsearch
33
import uprclhttp
31
import uprclhttp
34
from uprclutils import *
32
from uprclutils import uplog, g_myprefix
35
36
from recoll import recoll
37
from recoll import rclconfig
38
39
# This must be consistent with what contentdirectory.cxx does
40
g_myprefix = '0$uprcl$'
41
33
42
# The recoll documents
34
# The recoll documents
43
g_rcldocs = []
35
g_rcldocs = []
44
36
45
# Func name to method mapper
37
# Func name to method mapper
46
dispatcher = cmdtalkplugin.Dispatch()
38
dispatcher = cmdtalkplugin.Dispatch()
47
# Pipe message handler
39
# Pipe message handler
48
msgproc = cmdtalkplugin.Processor(dispatcher)
40
msgproc = cmdtalkplugin.Processor(dispatcher)
49
41
50
def uprcl_init():
42
def uprcl_init():
51
    global httphp, pathprefix, pathmap, rclconfdir, g_rcldocs
43
    global httphp, pathprefix, rclconfdir, g_rcldocs
52
    
44
    
53
    if "UPMPD_PATHPREFIX" not in os.environ:
45
    if "UPMPD_PATHPREFIX" not in os.environ:
54
        raise Exception("No UPMPD_PATHPREFIX in environment")
46
        raise Exception("No UPMPD_PATHPREFIX in environment")
55
    pathprefix = os.environ["UPMPD_PATHPREFIX"]
47
    pathprefix = os.environ["UPMPD_PATHPREFIX"]
56
    if "UPMPD_CONFIG" not in os.environ:
48
    if "UPMPD_CONFIG" not in os.environ:
...
...
68
    pathmap = {}
60
    pathmap = {}
69
    for ptt in lpth:
61
    for ptt in lpth:
70
        l = ptt.split(':')
62
        l = ptt.split(':')
71
        pathmap[l[0]] = l[1]
63
        pathmap[l[0]] = l[1]
72
64
73
    global rclconfdir
74
    rclconfdir = upconfig.get("uprclconfdir")
65
    rclconfdir = upconfig.get("uprclconfdir")
75
    if rclconfdir is None:
66
    if rclconfdir is None:
76
        raise Exception("uprclconfdir not in config")
67
        raise Exception("uprclconfdir not in config")
77
68
78
    g_rcldocs = uprclfolders.inittree(rclconfdir, httphp, pathprefix)
69
    g_rcldocs = uprclfolders.inittree(rclconfdir, httphp, pathprefix)
...
...
202
                                 httphp, pathprefix)
193
                                 httphp, pathprefix)
203
    
194
    
204
    encoded = json.dumps(entries)
195
    encoded = json.dumps(entries)
205
    return {"entries" : encoded}
196
    return {"entries" : encoded}
206
197
198
207
uprcl_init()
199
uprcl_init()
208
200
209
msgproc.log("Uprcl running")
201
msgproc.log("Uprcl running")
210
msgproc.mainloop()
202
msgproc.mainloop()