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 applications such as `Git <http://www.git-scm.com/>`_. 

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_git( 

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

16 """ 

17 Install `Git <http://www.git-scm.com/>`_. 

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 Git 

24 @param version specify a version (unused) 

25 @return temporary file 

26 """ 

27 if version is not None: 

28 raise ValueError("cannot specify a version") 

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

30 link = "http://www.git-scm.com/download/win" 

31 page = download_page(link) 

32 reg = re.compile("href=\\\"(.*?64-bit[.]((msi)|(exe)))\\\"") 

33 alls = reg.findall(page) 

34 if len(alls) == 0: 

35 raise Exception( 

36 "unable to find a link on a .msi file on page: " + link + "\n" + 

37 page) 

38 

39 url = alls[0][0] 

40 full = url.split("/")[-1] 

41 outfile = os.path.join(temp_folder, full) 

42 fLOG("[pymy] download ", url) 

43 local = download_file(url, outfile) 

44 if install: 

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

46 return local 

47 else: 

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