@@ -665,12 +665,7 @@ def startServer(tikaServerJar, java_path = TikaJava, java_args = TikaJavaArgs, s
665665 global TikaServerProcess
666666 # Patch for Windows support
667667 if Windows :
668- if sys .version .startswith ("2" ):
669- # Python 2.x
670- TikaServerProcess = Popen (cmd_string , stdout = logFile , stderr = STDOUT , shell = True )
671- elif sys .version .startswith ("3" ):
672- # Python 3.x
673- TikaServerProcess = Popen (cmd_string , stdout = logFile , stderr = STDOUT , shell = True , start_new_session = True )
668+ TikaServerProcess = Popen (cmd_string , stdout = logFile , stderr = STDOUT , shell = True , start_new_session = True )
674669 else :
675670 TikaServerProcess = Popen (cmd_string , stdout = logFile , stderr = STDOUT , shell = True , preexec_fn = os .setsid )
676671
@@ -706,17 +701,8 @@ def killServer():
706701 time .sleep (1 )
707702 # patch to support subprocess killing for windows
708703 if Windows :
709- if sys .version .startswith ("2" ):
710- # Python 2.x
711- PROCESS_TERMINATE = 1
712- handle = ctypes .windll .kernel32 .OpenProcess (PROCESS_TERMINATE , False , TikaServerProcess .pid )
713- ctypes .windll .kernel32 .TerminateProcess (handle , - 1 )
714- ctypes .windll .kernel32 .CloseHandle (handle )
715- time .sleep (1 )
716- elif sys .version .startswith ("3" ):
717- # Python 3.x
718- os .kill (TikaServerProcess .pid , signal .SIGTERM )
719- time .sleep (1 )
704+ os .kill (TikaServerProcess .pid , signal .SIGTERM )
705+ time .sleep (1 )
720706 else :
721707 try :
722708 os .killpg (os .getpgid (TikaServerProcess .pid ), signal .SIGTERM )
@@ -920,12 +906,7 @@ def main(argv=None):
920906 resp = main (sys .argv )
921907
922908 # Set encoding of the terminal to UTF-8
923- if sys .version .startswith ("2" ):
924- # Python 2.x
925- out = codecs .getwriter ("UTF-8" )(sys .stdout )
926- elif sys .version .startswith ("3" ):
927- # Python 3.x
928- out = codecs .getwriter ("UTF-8" )(sys .stdout .buffer )
909+ out = codecs .getwriter ("UTF-8" )(sys .stdout .buffer )
929910
930911 if type (resp ) == list :
931912 out .write ('\n ' .join ([r [1 ] for r in resp ]))
0 commit comments