Exemple #1
0
def run_chrome(build):
    chrome_commands = {
        'linux': 'google-chrome',
        'darwin':
        '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
        'win32': _windows_chrome_cmd()
    }

    chrome_cmd = None
    for platform, cmd in chrome_commands.items():
        if sys.platform.startswith(platform) and cmd:
            chrome_cmd = cmd
            break

    if not chrome_cmd:
        msg = """Currently it is not possible to launch a Chrome extension for your platform
with this interface. The required steps are:

	1) Go to chrome:extensions in the Chrome browser
	2) Make sure "developer mode" is on (top right corner)')
	3) Use "Load unpacked extension" and select the folder: {chrome_folder}
""".format(chrome_folder=_chrome_folder())
        LOG.info(msg)
        return

    with lib.temp_dir() as user_data_dir:
        LOG.info("Chome user data directory: {}".format(user_data_dir))
        development_dir = path.realpath(path.join("development", "chrome"))
        LOG.info("Extension will be loaded from: {}".format(development_dir))
        chrome = Popen([
            chrome_cmd, '--args',
            '--load-extension={}'.format(development_dir),
            '--user-data-dir={}'.format(user_data_dir),
            '--no-default-browser-check', '--no-first-run'
        ])
        try:
            chrome.wait()
        except KeyboardInterrupt:
            # Kill Chrome and wait until it's gone before erasing the temporary user data dir.
            chrome.terminate()
            chrome.wait()
Exemple #2
0
    def create_ipa_from_app(self,
                            build,
                            provisioning_profile,
                            output_path_for_ipa,
                            certificate_to_sign_with=None,
                            relative_path_to_itunes_artwork=None,
                            certificate_path=None,
                            certificate_password=None,
                            output_path_for_manifest=None):
        """Create an ipa from an app, with an embedded provisioning profile provided by the user, and
		signed with a certificate provided by the user.

		:param build: instance of build
		:param provisioning_profile: Absolute path to the provisioning profile to embed in the ipa
		:param output_path_for_ipa: Path to save the created IPA
		:param certificate_to_sign_with: (Optional) The name of the certificate to sign the ipa with
		:param relative_path_to_itunes_artwork: (Optional) A path to a 512x512 png picture for the App view in iTunes.
			This should be relative to the location of the user assets.
		"""

        LOG.info('Starting package process for iOS')

        directory = path.dirname(output_path_for_ipa)
        if not path.isdir(directory):
            os.makedirs(directory)

        app_folder_name = self._locate_ios_app(
            error_message="Couldn't find iOS app in order to sign it")
        path_to_app = path.abspath(
            path.join(self.path_to_ios_build, 'ios', app_folder_name))

        LOG.info('Going to package: %s' % path_to_app)

        plist_str = self._grab_plist_from_binary_mess(build,
                                                      provisioning_profile)
        plist_dict = self._parse_plist(plist_str)
        self.check_plist_dict(plist_dict, self.path_to_ios_build)
        self.provisioning_profile = plist_dict
        LOG.info("Plist OK")

        # use distribution cert automatically if PP is distribution
        certificate_to_sign_with = self._select_certificate(
            certificate_to_sign_with)

        self.log_profile()

        seed_id = self._extract_seed_id()

        LOG.debug("Extracted seed ID: {0}".format(seed_id))

        with lib.temp_dir() as temp_dir:
            LOG.debug('Making Payload directory')
            os.mkdir(path.join(temp_dir, 'Payload'))

            path_to_payload = path.abspath(path.join(temp_dir, 'Payload'))
            path_to_payload_app = path.abspath(
                path.join(path_to_payload, app_folder_name))

            if relative_path_to_itunes_artwork is not None:
                path_to_itunes_artwork = path.join(
                    path_to_payload_app, 'assets', 'src',
                    relative_path_to_itunes_artwork)
            else:
                path_to_itunes_artwork = None

            with temp_file() as temp_file_path:
                self._create_entitlements_file(build, temp_file_path)
                self._sign_app(
                    build=build,
                    provisioning_profile=provisioning_profile,
                    certificate=certificate_to_sign_with,
                    entitlements_file=temp_file_path,
                    certificate_path=certificate_path,
                    certificate_password=certificate_password,
                )

            shutil.copytree(
                path_to_app,
                path.join(path_to_payload, path.basename(path_to_app)))

            if path_to_itunes_artwork:
                shutil.copy2(path_to_itunes_artwork,
                             path.join(temp_dir, 'iTunesArtwork'))

            with ZipFile(output_path_for_ipa, 'w') as out_ipa:
                for root, dirs, files in os.walk(temp_dir):
                    for file in files:
                        LOG.debug('adding to IPA: {file}'.format(
                            file=path.join(root, file), ))
                        out_ipa.write(path.join(root, file),
                                      path.join(root[len(temp_dir):], file))

        LOG.info("created IPA: {output}".format(output=output_path_for_ipa))

        if output_path_for_manifest and self.plist_supports_wireless_distribution(
                plist_dict):
            LOG.info(
                "Provisioning profile supports wireless distributions, creating manifest: %s"
                % output_path_for_manifest)
            # Based on https://help.apple.com/iosdeployment-apps/#app43ad78b3
            manifest = {
                "items": [{
                    "assets": [{
                        "kind": "software-package",
                        "url": "http://www.example.com/app.ipa"
                    }, {
                        "kind": "display-image",
                        "needs-shine": True,
                        "url": "http://www.example.com/image.57x57.png",
                    }, {
                        "kind":
                        "full-size-image",
                        "needs-shine":
                        True,
                        "url":
                        "http://www.example.com/image.512x512.jpg",
                    }],
                    "metadata": {
                        "bundle-identifier": _generate_package_name(build),
                        "bundle-version": build.config['version'],
                        "kind": "software",
                        "title": build.config['name']
                    }
                }]
            }
            plistlib.writePlist(manifest, output_path_for_manifest)

        return output_path_for_ipa
    def create_ipa_from_app(self,
                            build,
                            provisioning_profile,
                            output_path_for_ipa,
                            certificate_to_sign_with=None,
                            relative_path_to_itunes_artwork=None,
                            certificate_path=None,
                            certificate_password=None):
        """Create an ipa from an app, with an embedded provisioning profile provided by the user, and
		signed with a certificate provided by the user.

		:param build: instance of build
		:param provisioning_profile: Absolute path to the provisioning profile to embed in the ipa
		:param output_path_for_ipa: Path to save the created IPA
		:param certificate_to_sign_with: (Optional) The name of the certificate to sign the ipa with
		:param relative_path_to_itunes_artwork: (Optional) A path to a 512x512 png picture for the App view in iTunes.
			This should be relative to the location of the user assets.
		"""

        LOG.info('Starting package process for iOS')

        if certificate_to_sign_with is None:
            certificate_to_sign_with = 'iPhone Developer'

        directory = path.dirname(output_path_for_ipa)
        if not path.isdir(directory):
            os.makedirs(directory)

        app_folder_name = self._locate_ios_app(
            error_message="Couldn't find iOS app in order to sign it")
        path_to_app = path.abspath(
            path.join(self.path_to_ios_build, 'ios', app_folder_name))

        LOG.info('Going to package: %s' % path_to_app)

        plist_str = self._grab_plist_from_binary_mess(provisioning_profile)
        plist_dict = self._parse_plist(plist_str)
        self.check_plist_dict(plist_dict, self.path_to_ios_build)
        LOG.info("Plist OK")

        self.log_profile(plist_dict)

        seed_id = self._extract_seed_id(plist_dict)

        LOG.debug("Extracted seed ID: {0}".format(seed_id))

        with lib.temp_dir() as temp_dir:
            LOG.debug('Making Payload directory')
            os.mkdir(path.join(temp_dir, 'Payload'))

            path_to_payload = path.abspath(path.join(temp_dir, 'Payload'))
            path_to_payload_app = path.abspath(
                path.join(path_to_payload, app_folder_name))

            if relative_path_to_itunes_artwork is not None:
                path_to_itunes_artwork = path.join(
                    path_to_payload_app, 'assets', 'src',
                    relative_path_to_itunes_artwork)
            else:
                path_to_itunes_artwork = None

            with temp_file() as temp_file_path:
                self._create_entitlements_file(build, plist_dict,
                                               temp_file_path)
                self._sign_app(
                    build=build,
                    provisioning_profile=provisioning_profile,
                    certificate=certificate_to_sign_with,
                    entitlements_file=temp_file_path,
                    certificate_path=certificate_path,
                    certificate_password=certificate_password,
                )

            shutil.copytree(
                path_to_app,
                path.join(path_to_payload, path.basename(path_to_app)))

            if path_to_itunes_artwork:
                shutil.copy2(path_to_itunes_artwork,
                             path.join(temp_dir, 'iTunesArtwork'))

            with ZipFile(output_path_for_ipa, 'w') as out_ipa:
                for root, dirs, files in os.walk(temp_dir):
                    for file in files:
                        out_ipa.write(path.join(root, file),
                                      path.join(root[len(temp_dir):], file))

        LOG.info("created IPA: {output}".format(output=output_path_for_ipa))
        return output_path_for_ipa