@@ -211,6 +211,11 @@ def downloadCLI():
211
211
os .remove (getCliLocation ())
212
212
except :
213
213
log (traceback .format_exc ())
214
+ if isCliLinked ():
215
+ try :
216
+ os .remove (getSymlinkLocation ())
217
+ except :
218
+ log (traceback .format_exc ())
214
219
215
220
log ('Extracting wakatime-cli...' )
216
221
with contextlib .closing (ZipFile (zip_file )) as zf :
@@ -248,6 +253,13 @@ def getCliLocation():
248
253
return WAKATIME_CLI_LOCATION
249
254
250
255
256
+ def getSymlinkLocation ():
257
+ binary = 'wakatime-cli{ext}' .format (
258
+ ext = '.exe' if is_win else '' ,
259
+ )
260
+ return os .path .join (getResourcesFolder (), binary )
261
+
262
+
251
263
def architecture ():
252
264
arch = platform .machine () or platform .processor ()
253
265
if arch == 'armv7l' :
@@ -263,8 +275,12 @@ def isCliInstalled():
263
275
return os .path .exists (getCliLocation ())
264
276
265
277
278
+ def isCliLinked ():
279
+ return os .path .exists (getSymlinkLocation ())
280
+
281
+
266
282
def isCliLatest ():
267
- if not isCliInstalled ():
283
+ if not isCliInstalled () or not isCliLinked () :
268
284
return False
269
285
270
286
args = [getCliLocation (), '--version' ]
@@ -532,13 +548,29 @@ def createSymlink():
532
548
533
549
try :
534
550
os .symlink (getCliLocation (), link )
551
+ if not isCliLinked ():
552
+ raise Exception ('Link not created.' )
535
553
except :
554
+ log (traceback .format_exc ())
555
+ log ('Unable to create symlink, will copy instead.' )
536
556
try :
537
557
shutil .copy2 (getCliLocation (), link )
558
+ if not isCliLinked ():
559
+ raise Exception ('File not copied.' )
538
560
if not is_win :
539
561
os .chmod (link , 509 ) # 755
540
562
except :
541
563
log (traceback .format_exc ())
564
+ log ('Unable to use copy2, will use copyfile.' )
565
+ try :
566
+ shutil .copyfile (getCliLocation (), link )
567
+ if not isCliLinked ():
568
+ raise Exception ('File not copied.' )
569
+ if not is_win :
570
+ os .chmod (link , 509 ) # 755
571
+ except :
572
+ log (traceback .format_exc ())
573
+ log ('Unable to install wakatime-cli.' )
542
574
543
575
544
576
class SSLCertVerificationDisabled (object ):
0 commit comments