Ejemplo n.º 1
0
  def windows_install_imagemagick(self):
    """Check for and install ImageMagick.

    Raises:
      FileDownloadError: If the ImageMagick installer fails to download, or is
          downloaded incorrectly.
      InstallInterruptError: If the user cancels the wait for installation of
          ImageMagick.
    """
    if find_executable("convert"):
      logging.info("ImageMagick is already installed.")
      return
    logging.info("ImageMagick not installed. Downloading now...")
    url, file_hash = IMAGEMAGICK_VERSIONS.get(self.version)
    url = IMAGEMAGICK_BASE_URL + url
    location = os.path.join(common.BASE_DIR, "imagemagick.exe")
    location = util.download_file(url, location, "imagemagick", file_hash)
    if not location:
      raise common.FileDownloadError("http://www.imagemagick.org/script/binary-"
                                     "releases.php", "Please rerun this script "
                                     "after completing manual installation.\n")
    subprocess.call("start cmd /c " + location, shell=True)
    if not util.wait_for_installation("convert"):
      raise common.InstallInterruptError("ImageMagick")
    logging.info("ImageMagick successfully installed.")
Ejemplo n.º 2
0
Archivo: android.py Proyecto: niu2x/gxm
    def android_download_ndk(self, directory):
        """Checks OS version and downloads the appropriate Android NDK.

    Args:
      directory: String indication of location to unpack NDK
    Raises:
      FileDownloadError: NDK bin or exe fails to download
      InstallInterruptError: if the wait for the NDK
    """
        if self.system == common.LINUX:
            os_version = subprocess.check_output("uname -m", shell=True)
            if os_version.strip() == "x86_64":
                url, file_hash = NDK_VERSIONS.get(common.LINUX_64)
            else:
                url, file_hash = NDK_VERSIONS.get(common.LINUX_32)
        elif self.system == common.WINDOWS:
            os_version = platform.architecture()[0]
            if os_version == "64bit":
                url, file_hash = NDK_VERSIONS.get(common.WINDOWS_64)
            else:
                url, file_hash = NDK_VERSIONS.get(common.WINDOWS_32)
        else:  # self.system = common.MAC
            url, file_hash = NDK_VERSIONS.get(self.system)
        filetype = util.get_file_type(url)
        url = NDK_DOWNLOAD_PREFIX + url
        ndk_location = os.path.join(directory, "ndk." + filetype)
        ndk_location = util.download_file(url, ndk_location, "Android NDK",
                                          file_hash)
        if not ndk_location:
            raise common.FileDownloadError(
                "http://developer.android.com/ndk/"
                "downloads/index.html", "Please rerun "
                "this script afterwards with the flag\n"
                "\t--android_ndk=/path/to/android_ndk")

        if filetype == "bin":
            # Allow execution by all parties.
            os.chmod(ndk_location, 0755)
            current_dir = os.getcwd()
            os.chdir(common.BASE_DIR)
            os.system(ndk_location)
            os.chdir(current_dir)
            os.remove(ndk_location)
        elif filetype == "exe":
            os.chdir(self.ndk_path)
            subprocess.call("start cmd /c " + ndk_location, shell=True)
            # toolchain-licenses\COPYING is one of the last things to be extracted.
            if not util.wait_for_installation(
                    "COPYING", search=True, basedir=self.ndk_path):
                raise common.InstallInterruptError("Android NDK")
            os.chdir(current_dir)
        else:
            raise common.UnknownFileTypeError(
                filetype, "Please manually extract "
                "Android NDK and rerun this script "
                "afterwards with the flag\n\t"
                "--android_ndk=/path/to/android_ndk")
Ejemplo n.º 3
0
  def windows_check_compiler(self):
    """check for compatible version of Visual C++.

    If no compatible version is found, download the same one was the version
    of Visual Studio currently installed.

    Raises:
      InstallFailedError: If the user does not want to install Visual C++.
      WebbrowserFailedError: If the link to Visual C++ could not be opened in
          the user's default browser.
      InstallInterruptError: If the user cancels the wait for installation of
          Visual C++.
    """
    for line in self.programs.splitlines():
      if VS_COMPILER_PREFIX in line:
        for name in VS_COMPATIBLE_VERSIONS.iterkeys():
          if line.startswith(VS_COMPILER_PREFIX + name):
            logging.info("Visual C++ already installed.")
            return
    logging.warn("Could not find Visual C++ compiler.\nPlease open Visual "
                 "Studio installer now and repair installation, or continue "
                 "and download Visual C++.")
    if not raw_input("Continue? (y/n) ").lower().startswith("y"):
      raise common.InstallFailedError("Visual C++", "https://www.microsoft.com/"
                                      "en-us/download/details.aspx?id=48145",
                                      "If you would like to skip Visual Studio "
                                      "installation, please rerun this script "
                                      "with the flag\n\t--no_visual_studio")
    if self.version == common.WINDOWS_32:
      filename = "vcredist_x86.exe"
    else:
      filename = "vcredist_x64.exe"
    logging.info("Opening web browser. Please download\n\t" + filename + "\n"
                 "Once download is complete, double click the exe and follow "
                 "installation instructions.")
    url = VS_COMPILER_BASE_URL + VS_COMPILER_DOWNLOADS.get(self.vs_version)
    if not util.open_link(url, "Visual C++"):
      raise common.WebbrowserFailedError("Visual C++", url)
    if not util.wait_for_installation("cl.exe", search=True,
                                      basedir=self.program_files):
      raise common.InstallInterruptError("Visual C++", "If you would like to "
                                         "skip Visual Studio installation, "
                                         "please rerun this script with the "
                                         "flag\n\t--no_visual_studio")
    logging.info("Visual C++ installed.")
Ejemplo n.º 4
0
  def windows_install_java(self):
    """Check for and install Java.

    Downloading the jdk installer can't be done through python, or equivalent
    bash commands due to some javascript on the download site. It instead has
    to be through the users default browser.

    Raises:
      WebbrowserFailedError: If the link to Java JDK could not be opened in
          the user's default browser.
      InstallInterruptError: If the user cancels the wait for installation of
          Java JDK.
    """
    if find_executable("java"):
      logging.info("Java already installed.")
      return
    # Since installing Java is annoying, we want to make doubly sure the user
    # doesn't have it already.
    location = util.find_file(PROGRAM_FILES, "java.exe")
    if not location and self.program_files == PROGRAM_FILES_X86:
      # In case the user has installed the 32 bit version on a 64 bit machine
      location = util.find_file(PROGRAM_FILES_X86, "java.exe")
    if location:
      logging.info("Java already installed at " + location + ".")
      self.java_path = os.path.dirname(location)
      return
    logging.warn("Java not installed. Please accept the terms and conditions, "
                 "and download:\n\t" + JAVA_VERSIONS.get(self.version) +
                 "\nOnce download is complete, double click the exe and follow "
                 "installation instructions.")
    # Java JDK can't be installed without the user accepting the terms and
    # conditions, which can only be done in their browser
    logging.warn("Java not installed. Opening browser...")
    if not util.open_link(JAVA_URL, "Java JDK"):
      raise common.WebbrowserFailedError("Java JDK", JAVA_URL)
    if not util.wait_for_installation("java.exe", search=True,
                                      basedir=PROGRAM_FILES):
      raise common.InstallInterruptError("Java JDK")
    logging.info("Java successfully installed.")
Ejemplo n.º 5
0
Archivo: mac.py Proyecto: niu2x/gxm
    def mac_install_xcode(self):
        """Check for and install Xcode and Xcode command line tools.

    Raises:
      InstallInterruptError: If the user cancels either the Xcode or Xcode
          Command Line Tools setup.
      PermissionsDeniedError: If sudo permissions are not granted for accepting
          the Xcode terms and conditions.
      CommandFailedError: Xcode is unable to install using its command line
          installer
    """
        if find_executable("xcodebuild"):
            logging.info("Xcode already installed.")
        else:
            logging.warn(
                "Please download and install Xcode from the Apple "
                "Developers website:\nhttps://itunes.apple.com/us/app/"
                "xcode/id497799835?ls=1&mt=12")
            if not util.wait_for_installation("xcodebuild -version"):
                raise common.InstallInterruptError("Xcode")
            # View and accept terms and conditions for Xcode
            logging.info(
                "Please accept the Xcode terms and conditions.\nSudo may "
                "prompt you for your password.")
            try:
                subprocess.call("sudo xcodebuild -license", shell=True)
            except subprocess.CalledProcessError:
                raise common.PermissionDeniedError(
                    "Xcode license", "Please enter your "
                    "password to accept the Xcode terms "
                    "and conditions")

        # Checks to see if xcode command line tools is installed
        if find_executable("xcode-select"):
            logging.info("Xcode command line tools already installed.")
            return
        else:
            logging.info("Xcode Command Line Tools not installed. "
                         "Installing Xcode Command Line Tools now.")
        method, info = XCODE_VERSIONS.get(self.os_version, (None, None))
        if method == "INSTRUCTION":
            logging.warn("Please download " + info + " from the Apple "
                         "Developers website:\thttps://developer.apple.com/"
                         "downloads/index.action\nFor more information, see "
                         "https://guide.macports.org/#installing.xcode")
        elif method == "LINK":
            logging.warn("Please download xcode from the Mac Apple Store:\n" +
                         info + "\nFor more information, see "
                         "https://guide.macports.org/#installing.xcode")
        elif method == "COMMAND":
            logging.warn("Please click 'Install' in the dialog box.")
            try:
                subprocess.call(info, shell=True)
            except subprocess.CalledProcessError:
                raise common.CommandFailedError(
                    info, "http://railsapps.github.io/"
                    "xcode-command-line-tools.html")
        # Wait for user to complete setup
        if not util.wait_for_installation("xcode-select -p"):
            raise common.InstallInterruptError("Xcode Command Line Tools")
        logging.info("Xcode successfully installed.")