@@ -25,6 +25,7 @@ import subprocess
2525import zipfile
2626import shutil
2727import io
28+ import os
2829
2930DEFAULT_VERSION = "1.9.0"
3031
@@ -85,15 +86,15 @@ def install(version: str):
8586 shutil .rmtree (install_dir )
8687 install_dir .mkdir ()
8788 ripunzip = shutil .which ("ripunzip" )
88- if platform .system () == "Windows" and windows_ripunzip .exists ():
89+ if ripunzip is None and platform .system () == "Windows" and windows_ripunzip .exists ():
8990 ripunzip = windows_ripunzip
9091 if ripunzip :
9192 print (f"downloading and extracting { url } using ripunzip" , file = sys .stderr )
9293 subprocess .run ([ripunzip , "unzip-uri" , url ], cwd = install_dir , check = True )
9394 return
9495 with io .BytesIO () as buffer :
96+ print (f"downloading { url } " , file = sys .stderr )
9597 with urllib .request .urlopen (url ) as response :
96- print (f"downloading { url } " , file = sys .stderr )
9798 while True :
9899 bytes = response .read ()
99100 if not bytes :
@@ -141,15 +142,12 @@ def main(opts, forwarded_opts):
141142 if not selected_version :
142143 selected_version = DEFAULT_VERSION
143144 version_file .write_text (selected_version )
144- if opts .version :
145- print (f"info: kotlinc-jvm { selected_version } (codeql dev wrapper)" , file = sys .stderr )
146- return
147- if opts .select and not forwarded_opts :
148- print (f"selected { selected_version } " , file = sys .stderr )
149- return
150145 if get_version (installed_version_file ) != selected_version :
151146 install (selected_version )
152147 installed_version_file .write_text (selected_version )
148+ if opts .version or (opts .select and not forwarded_opts ):
149+ print (f"info: kotlinc-jvm { selected_version } (codeql dev wrapper)" , file = sys .stderr )
150+ return
153151 forward (forwarded_opts )
154152
155153
@@ -159,3 +157,5 @@ if __name__ == "__main__":
159157 except Exception as e :
160158 print (f"{ e .__class__ .__name__ } : { e } " , file = sys .stderr )
161159 sys .exit (1 )
160+ except KeyboardInterrupt :
161+ sys .exit (1 )
0 commit comments