Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1""" 

2@file 

3@brief Various functions to install some application such as `scala-sbt <http://www.scala-sbt.org/download.html>`_. 

4""" 

5from __future__ import print_function 

6import sys 

7import re 

8import os 

9 

10from ..installhelper.install_cmd_helper import run_cmd 

11from .install_custom import download_page, download_file 

12 

13 

14def install_scala_sbt( 

15 temp_folder=".", fLOG=print, install=True, force_download=False, version=None): 

16 """ 

17 Install `scala-sbt <http://www.scala-sbt.org/download.html>`_. 

18 It does not do it a second time if it is already installed. 

19 

20 @param temp_folder where to download the setup 

21 @param fLOG logging function 

22 @param install install (otherwise only download) 

23 @param force_download force the downloading of pandoc 

24 @param version version to install (unused) 

25 @return temporary file 

26 """ 

27 if version is not None: 

28 raise ValueError("cannot specify a version") 

29 #bb = IsPandocInstalled() 

30 bb = False 

31 if bb and not force_download: 

32 return True 

33 

34 link = "http://www.scala-sbt.org/download.html" 

35 page = download_page(link) 

36 if sys.platform.startswith("win"): 

37 reg = re.compile("href=\\\"(https://.*?msi)\\\"") 

38 alls = reg.findall(page) 

39 if len(alls) == 0: 

40 raise Exception( 

41 "unable to find a link on a .msi file on page: " + 

42 page) 

43 

44 file = alls[0] 

45 filel = file 

46 full = filel 

47 version = file.split("/")[-2] 

48 fLOG("[pymy] scala-sbt, version ", version) 

49 outfile = os.path.join(temp_folder, full.split("/")[-1]) 

50 if not outfile.endswith(".msi"): 

51 outfile += ".msi" 

52 fLOG("[pymy] download ", full) 

53 local = download_file(full, outfile) 

54 if install and not bb: 

55 run_cmd("msiexec /i " + local, fLOG=fLOG, wait=True) 

56 return local 

57 else: 

58 raise NotImplementedError("not available on platform " + sys.platform)