this repo has no description
at fixPythonPipStalling 65 lines 1.9 kB view raw
1#!/usr/bin/python2.7 2# This file is part of Darling. 3# 4# Copyright (C) 2020 Lubos Dolezel 5# 6# Darling is free software: you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation, either version 3 of the License, or 9# (at your option) any later version. 10# 11# Darling is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with Darling. If not, see <http://www.gnu.org/licenses/>. 18 19import urllib2 20import json 21import tempfile 22import os 23import subprocess 24 25print("You are about to download and install Apple Command Line Tools covered by the following license:") 26print("https://www.apple.com/legal/sla/docs/xcode.pdf\n") 27 28while True: 29 resp = raw_input("Do you agree with the terms of the license? (y/n) ") 30 31 if resp == "y": 32 break 33 elif resp == "n": 34 exit(1) 35 36packagesResp = urllib2.urlopen("https://swdistcache.darlinghq.org/api/v1/products/by-tag?tag=DTCommandLineTools") 37packages = json.loads(packagesResp.read()) 38 39tempdir = tempfile.mkdtemp() 40 41print("Downloading packages...") 42 43for package in packages[0]['packages']: 44 fname = os.path.basename(package['url']) 45 print("Downloading " + fname + "...") 46 47 f = urllib2.urlopen(package['url']) 48 49 fullpath = tempdir + "/" + fname 50 with open(fullpath, "wb") as localfile: 51 for chunk in iter(lambda: f.read(16*1024), ''): 52 localfile.write(chunk) 53 54 print("Installing...") 55 exitCode = subprocess.call(["sudo", "installer", "-pkg", fullpath, "-target", "/"]) 56 57 if exitCode != 0: 58 print("Installation failed with exit code " + str(exitCode)) 59 exit(1) 60 61 os.remove(fullpath) 62 63os.rmdir(tempdir) 64 65print("Installation complete!")