Esempio n. 1
0
File: mac.py Progetto: niu2x/gxm
    def mac_install_ant(self):
        """Check for and install Apache Ant.

    Raises:
      FileDownloadError: If the ant tar fails to download, or is incorrectly
          downloaded.
      ExtractionError: If the ant tar cannot be properly extracted.
    """
        if find_executable("ant"):
            logging.info("Apache Ant already installed.")
            return
        location = util.check_dir(self.ant_path, ANT_VERSION, "bin/ant")
        if location:
            self.ant_path = location
            logging.info("Apache Ant already installed.")
            return
        logging.info("Apache Ant not installed. Installing now.")
        location = os.path.join(common.BASE_DIR, "ant.tar.gz")
        location = util.download_file(ANT_URL, location, "Ant", ANT_HASH)
        if not location:
            raise common.FileDownloadError(
                "https://www.apache.org/dist/ant/"
                "binaries/", "Please rerun this script "
                "again afterwards.")
        if not util.extract_tarfile(location, "r:gz", self.ant_path, "Ant"):
            raise common.ExtractionError(location)
        logging.info("Apache Ant successfully installed.")
Esempio n. 2
0
File: mac.py Progetto: niu2x/gxm
    def mac_install_cwebp(self):
        """Check for and install cwebp.

    Assumes that if cwebp is already installed, then the user has correctly set
    their path variable such that the command "cwebp -h" will work.
    Raises:
      FileDownloadError: If the cwebp tar fails to download, or is incorrectly
          downloaded.
      ExtractionError: If the cwebp tar cannot be properly extracted.
    """
        if find_executable("cwebp"):
            logging.info("cwebp already installed.")
            return
        location = util.check_dir(self.cwebp_path, CWEBP_VERSION, "cwebp")
        if location:
            self.cwebp_path = location
            logging.info("cwebp found at " + self.cwebp_path)
            return
        logging.info("cwebp not installed. Downloading now.")
        location = os.path.join(common.BASE_DIR, "cwebp.tar.gz")
        location = util.download_file(CWEBP_URL, location, "cwebp", CWEBP_HASH)
        if not location:
            raise common.FileDownloadError(
                "https://developers.google.com/speed/webp/"
                "docs/precompiled", "Please rerun this "
                "script afterwards with the flag\n"
                "\t--cwebp=/path/to/cwebp")
        if not util.extract_tarfile(location, "r:gz", self.cwebp_path,
                                    "cwebp"):
            raise common.ExtractionError(location)
        logging.info("cwebp successfully installed.")
Esempio n. 3
0
  def windows_install_python(self):
    """Checks for and installs at least Python 2.7.8.

    Raises:
      FileDownloadError: If the Python installer fails to download, or is
          downloaded incorrectly.
      InstallInterruptError: If the user cancels the wait for installation of
          ImageMagick.
      InstallFailedError: If msiexec fails, or Python cannot be installed.
    """
    if find_executable("python"):
      if check_python_version():
        logging.info("Python already installed.")
        return
      else:
        logging.info("Python version not sufficient. Updating now.")
    else:
      logging.info("Python not installed. Downloading now.")
    url, file_hash = PYTHON_VERSIONS.get(self.version)
    url = PYTHON_BASE_URL + url
    location = os.path.join(common.BASE_DIR, "python.msi")
    location = util.download_file(url, location, "python", file_hash)
    if not location:
      raise common.FileDownloadError("https://www.python.org/downloads/release/"
                                     "python-278/", "Please rerun this script "
                                     "after completing manual installation.\n")
    logging.info("Opening Python installer. For convenience, please select the "
                 "'Add python.exe to Path' option.")
    try:
      subprocess.call("msiexec /i " + location, shell=True)
    except subprocess.CalledProcessError:
      raise common.InstallFailedError("Python", "https://www.python.org/"
                                      "downloads/release/python-278/", "Please "
                                      "rerun this script after installating "
                                      "Python manually.")
Esempio n. 4
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.")
Esempio n. 5
0
  def windows_install_cwebp(self):
    """Check for and install cwebp in given directory.

    Raises:
      FileDownloadError: If the cwebp zip fails to download, or is downloaded
          incorrectly.
    """
    if find_executable("cwebp"):
      if check_cwebp_version():
        logging.info("cwebp already installed.")
        return
      else:
        logging.info("cwebp version not sufficient. Updating now.")
    else:
      location = util.check_dir(self.cwebp_path,
                                CWEBP_VERSIONS.get(self.version)[0],
                                "\\bin\\cmake.exe")
      if location:
        logging.info("CMake already installed.")
        self.cmake_path = location
        return
    version, file_hash = CWEBP_VERSIONS.get(self.version)
    logging.info("cwebp not installed. Downloading now...")
    url = CWEBP_BASE_URL + version + ".zip"
    location = os.path.join(common.BASE_DIR, "cwebp.zip")
    location = util.download_file(url, location, "cwebp", file_hash)
    if not location:
      raise common.FileDownloadError("https://developers.google.com/speed/webp/"
                                     "docs/precompiled", "Please rerun this "
                                     "script afterwards with the flag\n\t"
                                     "--cmake=\\path\\to\\cmake")
    util.extract_zipfile(location, "r", self.cwebp_path, "cwebp")
    logging.info("cwebp successfully installed.")
Esempio n. 6
0
  def windows_install_cmake(self):
    """Check for and install cmake.

    Raises:
      FileDownloadError: If the CMake zip fails to download, or is downloaded
          incorrectly.
    """
    if find_executable("cmake"):
      if check_cmake_version():
        logging.info("CMake already installed.")
        return
      else:
        logging.info("CMake version not sufficient. Updating now.")
    else:
      location = util.check_dir(self.cmake_path, CMAKE_VERSION,
                                os.path.join("bin", "cmake.exe"))
      if location:
        logging.info("CMake already installed.")
        self.cmake_path = location
        return
      else:
        logging.info("CMake not installed. Downloading now...")
    location = os.path.join(common.BASE_DIR, "cmake.zip")
    location = util.download_file(CMAKE_URL, location, "cmake", CMAKE_HASH)
    if not location:
      raise common.FileDownloadError("https://cmake.org/download/", "Please "
                                     "rerun this script afterwards with the "
                                     "flag\n\t--cmake=\\path\\to\\cmake")
    util.extract_zipfile(location, "r", self.cmake_path, "cmake")
    logging.info("cmake successfully installed.")
Esempio n. 7
0
  def windows_fix_directx(self):
    """Attempt to fix problems DirectX may be having with Visual Studio.

    DirectX comes pre-installed on Windows 7 and up, but having Visual C++ 2010
    or higher may give an "S1023" error due to it being newer than the latest
    version of DirectX, June 2010 DirectX SDK. This can be fixed by
    reinstalling DirectX once Visual C++ has been established.

    Raises:
      FileDownloadError: If the Visual Studio installer fails to download, or
          is downloaded incorrectly.
    """
    logging.info("Attempting to fix problems with DirectX...")
    try:
      subprocess.call("MsiExec.exe /passive /X{F0C3E5D1-1ADE-321E-8167-"
                      "68EF0DE699A5}", shell=True)
      subprocess.call("MsiExec.exe /passive /X{1D8E6291-B0D5-35EC-8441-"
                      "6616F567A0F7}", shell=True)
    except subprocess.CalledProcessError:
      logging.warning("MsiExec.exe failed. Could not resolve conflicts with "
                      "DirectX and Visual Studio.")
      return
    location = os.path.join(common.BASE_DIR, "directx.exe")
    location = util.download_file(DIRECTX_URL, location, "DirectX",
                                  DIRECTX_HASH)
    if not location:
      raise common.FileDownloadError("http://www.microsoft.com/en-us/download/"
                                     "details.aspx?id=6812", "Please rerun "
                                     "this script after completing manual "
                                     "installation.")
    subprocess.call("start cmd /c " + location, shell=True)
    logging.info("DirectX successfully reinstalled.")
Esempio n. 8
0
File: android.py Progetto: 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")
Esempio n. 9
0
File: mac.py Progetto: niu2x/gxm
    def mac_install_macports(self):
        """Check for and install MacPorts.

    Raises:
      FileDownloadError: If the MacPorts package fails to download, or is
          incorrectly downloaded.
      UnknownFileTypeError: If the type of the downloaded package does not match
          any of the supported types.
    """
        if os.path.isfile(MACPORTS_LOCATION):
            logging.info("MacPorts already installed.")
            return
        else:
            logging.info("MacPorts not installed. Downloading now.")
        url, file_hash = MACPORTS_VERSIONS.get(self.os_version)
        url = MACPORTS_DOWNLOAD_PREFIX + url
        suffix = util.get_file_type(url)
        location = os.path.join(common.BASE_DIR, "macports." + suffix)
        location = util.download_file(url, location, "macports", file_hash)
        if not location:
            raise common.FileDownloadError(
                "https://guide.macports.org/chunked/"
                "installing.macports.html", "Please rerun "
                "this script again afterwards.")
        logging.info(
            "Installing Mac Ports. Sudo may prompt you for your password.")
        if suffix == "pkg":
            try:
                subprocess.call("sudo installer -pkg " + location +
                                " -target /",
                                shell=True)
            except subprocess.CalledProcessError:
                raise common.PermissionDeniedError(
                    "installer", "Please enter your "
                    "password to install MacPorts")
        elif suffix == "dmg":
            subprocess.call("hdiutil attach " + location, shell=True)
        else:
            raise common.UnknownFileTypeError(
                suffix, "Please manually install "
                "MacPorts, or run this script again "
                "with the flag\n\t--no_macports")
        self.bash_profile_changed = True  # Mac ports installation will probably
Esempio n. 10
0
File: android.py Progetto: niu2x/gxm
    def android_download_sdk(self, directory):
        """Download Android SDK and unpack into specified directory.

    Args:
      directory: String indication of location to unpack SDK to
    Raises:
      FileDownloadError: SDK tar or zip fails to download
      UnknownFileTypeError: If the file downloaded is neither a tar or a zip,
          and cannot be extracted.
    """
        url, file_hash = SDK_VERSIONS.get(self.system)
        suffix = util.get_file_type(url)
        sdk_location = os.path.join(directory, "sdk." + suffix)
        sdk_location = util.download_file(url, sdk_location, "Android SDK",
                                          file_hash)
        if not sdk_location:
            raise common.FileDownloadError(
                "http://developer.android.com/sdk/index."
                "html#", "Please rerun this script "
                "afterwards with the flag\n"
                "\t--android_sdk=/path/to/android_sdk")
        if suffix == "tgz":
            util.extract_tarfile(sdk_location, "r", directory, "Android SDK")
        elif suffix == "zip":
            util.extract_zipfile(sdk_location, "r", directory, "Android SDK")
        else:
            raise common.UnknownFileTypeError(
                suffix, "Please manually extract "
                "Android SDK and rerun this script "
                "afterwards with the flag\n"
                "\t--android_sdk=/path/to/android_sdk")
        if self.system == common.MAC:
            # Sometimes, permissions aren't set correctly on tools/android on OSX.
            # Change permissions to allow execution by user
            android = os.path.join(directory, SDK_NAMES.get(self.system),
                                   "tools", "android")
            curr_permissions = os.stat(android)
            os.chmod(android, curr_permissions.st_mode | stat.S_IXUSR)
        # Update self.sdk_path to now include the SDK name
        self.sdk_path = os.path.join(self.sdk_path, SDK_NAMES.get(self.system))
Esempio n. 11
0
  def windows_setup_visual_studio(self):
    """Check for compatible versions of Visual Studio and Visual C++.

    If no compatible version of Visual Studio is detected, download default
    version. If a compatible version is detected, check if a compatible
    version of the C++ compiler has been installed.

    Raises:
      FileDownloadError: If the Visual Studio installer fails to download, or
          is downloaded incorrectly.
    """
    for line in self.programs.splitlines():
      if VS_NAME_PREFIX in line:
        for name in get_all_vs():
          if line.strip() == name:
            self.vs_version = VS_COMPATIBLE_VERSIONS.get(name.split(" ")[-1])
            logging.info("Visual Studio already installed.")
            self.windows_check_compiler()
            return
    logging.info("Visual Studio not installed. Installing " + VS_DEFAULT_NAME +
                 " now...")
    location = os.path.join(common.BASE_DIR, "vs_community.exe")
    location = util.download_file(VS_DEFAULT_URL, location,
                                  "Visual Studio Installer", VS_DEFAULT_HASH)
    if not location:
      raise common.FileDownloadError("https://www.visualstudio.com/en-us/"
                                     "downloads/download-visual-studio-vs.aspx",
                                     "Please rerun this script after "
                                     "completing manual installation.")
    logging.info("Now lauching Visual Stusio Installer.\n*** Please ensure you "
                 "select \"Visual C++\" ***\nYour computer will "
                 "likely need to be restarted. If so, click 'Restart Now' when "
                 "prompted and rerun this script after reboot.\nIf no restart "
                 "is required, click 'Finish' and rerun script.")
    subprocess.call("cmd /k " + location, shell=True)
    # cmd /k will stop the script, but just in case, exit
    sys.exit()
Esempio n. 12
0
File: mac.py Progetto: niu2x/gxm
    def mac_install_cmake(self):
        """Check for and install cmake.

    Assumes that if cmake is already installed, then the user has correctly set
    their path variable such that the command "cmake --version" will work.

    Raises:
      FileDownloadError: If the cmake tar fails to download, or is incorrectly
          downloaded.
      ExtractionError: If the cmake tar cannot be properly extracted.
    """
        if find_executable("cmake"):
            logging.info("CMake already installed.")
            return
        cmake_version = util.get_file_name(
            CMAKE_VERSIONS.get(self.version)[0], False)
        location = util.check_dir(self.cmake_path, cmake_version, "bin/cmake")
        if location:
            self.cmake_path = location
            logging.info("CMake found at " + self.cmake_path)
            return

        logging.info("CMake not installed. Downloading now.")
        url, file_hash = CMAKE_VERSIONS.get(self.os_version, (None, None))
        url = urlparse.urljoin(CMAKE_DOWNLOAD_PREFIX, url)
        location = os.path.join(common.BASE_DIR, "cmake.tar.gz")
        location = util.download_file(url, location, "cmake", file_hash)
        if not location:
            raise common.FileDownloadError(
                "https://cmake.org/download/", "Please "
                "rerun this script afterwards with the "
                "flag\n\t--cmake=/path/to/cmake")
        if not util.extract_tarfile(location, "r:gz", self.cmake_path,
                                    "cmake"):
            raise common.ExtractionError(location)
        logging.info("CMake successfully installed.")