|
a/src/mediaserver/cdplugins/uprcl/uprcl-app.py |
|
b/src/mediaserver/cdplugins/uprcl/uprcl-app.py |
|
... |
|
... |
21 |
import re
|
21 |
import re
|
22 |
import conftree
|
22 |
import conftree
|
23 |
import cmdtalkplugin
|
23 |
import cmdtalkplugin
|
24 |
import threading
|
24 |
import threading
|
25 |
import subprocess
|
25 |
import subprocess
|
|
|
26 |
import time
|
|
|
27 |
from timeit import default_timer as timer
|
26 |
|
28 |
|
27 |
import uprclfolders
|
29 |
import uprclfolders
|
28 |
import uprcltags
|
30 |
import uprcltags
|
29 |
import uprcluntagged
|
31 |
import uprcluntagged
|
30 |
import uprclsearch
|
32 |
import uprclsearch
|
31 |
import uprclhttp
|
33 |
import uprclhttp
|
|
|
34 |
import uprclindex
|
|
|
35 |
|
32 |
from uprclutils import uplog, g_myprefix,rcldirentry
|
36 |
from uprclutils import uplog, g_myprefix,rcldirentry
|
33 |
|
37 |
|
34 |
# The recoll documents
|
38 |
# The recoll documents
|
35 |
g_rcldocs = []
|
39 |
g_rcldocs = []
|
36 |
|
40 |
|
|
... |
|
... |
39 |
# Pipe message handler
|
43 |
# Pipe message handler
|
40 |
msgproc = cmdtalkplugin.Processor(dispatcher)
|
44 |
msgproc = cmdtalkplugin.Processor(dispatcher)
|
41 |
|
45 |
|
42 |
def _uprcl_init_worker():
|
46 |
def _uprcl_init_worker():
|
43 |
global httphp, pathprefix, rclconfdir, g_rcldocs
|
47 |
global httphp, pathprefix, rclconfdir, g_rcldocs
|
44 |
|
48 |
|
|
|
49 |
# pathprefix would typically be something like "/uprcl". It's used
|
|
|
50 |
# for dispatching URLs to the right plugin for processing. We
|
|
|
51 |
# strip it whenever we need a real file path
|
45 |
if "UPMPD_PATHPREFIX" not in os.environ:
|
52 |
if "UPMPD_PATHPREFIX" not in os.environ:
|
46 |
raise Exception("No UPMPD_PATHPREFIX in environment")
|
53 |
raise Exception("No UPMPD_PATHPREFIX in environment")
|
47 |
pathprefix = os.environ["UPMPD_PATHPREFIX"]
|
54 |
pathprefix = os.environ["UPMPD_PATHPREFIX"]
|
48 |
if "UPMPD_CONFIG" not in os.environ:
|
55 |
if "UPMPD_CONFIG" not in os.environ:
|
49 |
raise Exception("No UPMPD_CONFIG in environment")
|
56 |
raise Exception("No UPMPD_CONFIG in environment")
|
|
... |
|
... |
62 |
l = ptt.split(':')
|
69 |
l = ptt.split(':')
|
63 |
pathmap[l[0]] = l[1]
|
70 |
pathmap[l[0]] = l[1]
|
64 |
|
71 |
|
65 |
rclconfdir = upconfig.get("uprclconfdir")
|
72 |
rclconfdir = upconfig.get("uprclconfdir")
|
66 |
if rclconfdir is None:
|
73 |
if rclconfdir is None:
|
|
|
74 |
uplog("uprclconfdir not in config, using /var/cache/upmpdcli/uprcl")
|
|
|
75 |
rclconfdir = "/var/cache/upmpdcli/uprcl"
|
|
|
76 |
rcltopdirs = upconfig.get("uprclmediadirs")
|
|
|
77 |
if rcltopdirs is None:
|
67 |
raise Exception("uprclconfdir not in config")
|
78 |
raise Exception("uprclmediadirs not in config")
|
|
|
79 |
|
|
|
80 |
# Update or create index.
|
|
|
81 |
uplog("Creating updating index in %s for %s"%(rclconfdir, rcltopdirs))
|
|
|
82 |
start = timer()
|
|
|
83 |
uprclindex.runindexer(rclconfdir, rcltopdirs)
|
|
|
84 |
# Wait for indexer
|
|
|
85 |
while not uprclindex.indexerdone():
|
|
|
86 |
time.sleep(.5)
|
|
|
87 |
fin = timer()
|
|
|
88 |
uplog("Indexing took %.2f Seconds" % (fin - start))
|
68 |
|
89 |
|
69 |
g_rcldocs = uprclfolders.inittree(rclconfdir, httphp, pathprefix)
|
90 |
g_rcldocs = uprclfolders.inittree(rclconfdir, httphp, pathprefix)
|
70 |
uprcltags.recolltosql(g_rcldocs)
|
91 |
uprcltags.recolltosql(g_rcldocs)
|
71 |
uprcluntagged.recoll2untagged(g_rcldocs)
|
92 |
uprcluntagged.recoll2untagged(g_rcldocs)
|
72 |
|
93 |
|