125125 'TIKA_TRANSLATOR' ,
126126 "org.apache.tika.language.translate.Lingo24Translator" )
127127TikaClientOnly = os .getenv ('TIKA_CLIENT_ONLY' , False )
128-
129- TikaServerClasspath = os .getenv ('TIKA_SERVER_CLASSPATH' , "" )
128+ TikaServerClasspath = os .getenv ('TIKA_SERVER_CLASSPATH' , '' )
130129
131130Verbose = 0
132131EncodeUtf8 = 0
@@ -311,12 +310,15 @@ def getConfig(option, serverEndpoint=ServerEndpoint, verbose=Verbose, tikaServer
311310
312311
313312def callServer (verb , serverEndpoint , service , data , headers , verbose = Verbose , tikaServerJar = TikaServerJar ,
314- httpVerbs = {'get' : requests .get , 'put' : requests .put , 'post' : requests .post }, classpath = TikaServerClasspath ):
313+ httpVerbs = {'get' : requests .get , 'put' : requests .put , 'post' : requests .post },classpath = None ):
315314 """Call the Tika Server, do some error checking, and return the response."""
316315
317316 parsedUrl = urlparse (serverEndpoint )
318317 serverHost = parsedUrl .hostname
319318 port = parsedUrl .port
319+ if classpath is None :
320+ classpath = TikaServerClasspath
321+
320322 global TikaClientOnly
321323 if not TikaClientOnly :
322324 serverEndpoint = checkTikaServer (serverHost , port , tikaServerJar , classpath )
@@ -343,8 +345,10 @@ def callServer(verb, serverEndpoint, service, data, headers, verbose=Verbose, ti
343345 return (resp .status_code , resp .text )
344346
345347
346- def checkTikaServer (serverHost = ServerHost , port = Port , tikaServerJar = TikaServerJar , classpath = TikaServerClasspath ):
348+ def checkTikaServer (serverHost = ServerHost , port = Port , tikaServerJar = TikaServerJar ,classpath = None ):
347349 """Check that tika-server is running. If not, download JAR file and start it up."""
350+ if classpath is None :
351+ classpath = TikaServerClasspath
348352 urlp = urlparse (tikaServerJar )
349353 serverEndpoint = 'http://%s:%s' % (serverHost , port )
350354 jarPath = os .path .join (TikaJarPath , 'tika-server.jar' )
@@ -374,14 +378,17 @@ def checkJarSig(tikaServerJar, jarPath):
374378 return existingContents == m .hexdigest ()
375379
376380
377- def startServer (tikaServerJar , serverHost = ServerHost , port = Port , classpath = TikaServerClasspath ):
381+ def startServer (tikaServerJar , serverHost = ServerHost , port = Port , classpath = None ):
382+ if classpath is None :
383+ classpath = TikaServerClasspath
384+
378385 host = "localhost"
379386 if Windows :
380387 host = "0.0.0.0"
381388
382- if classpath :
389+ if classpath :
383390 classpath += ":" + tikaServerJar
384- else :
391+ else :
385392 classpath = tikaServerJar
386393
387394 cmd = 'java -cp %s org.apache.tika.server.TikaServerCli --port %i --host %s &' % (classpath , port , host )
0 commit comments