Example #1
0
def _node(build, *args, **kw):
    node = "node"
    if not utils.which(node):
        raise WebError("couldn't find {tool} on your PATH or in likely "
                       "locations - is it installed?".format(tool=node))

    kw['check_for_interrupt'] = True
    run_shell(node, *args, **kw)
Example #2
0
def _node(build, *args, **kw):
	node = "node"
	if not utils.which(node):
		raise WebError("couldn't find {tool} on your PATH or in likely "
				"locations - is it installed?".format(tool=node))

	kw['check_for_interrupt'] = True
	run_shell(node, *args, **kw)
Example #3
0
def _npm(build, *args, **kw):
	if sys.platform.startswith("win"):
		npm = "npm.cmd"
	else:
		npm = "npm"
	if not utils.which(npm):
		raise ServeError(NODEJS_HELP.format(tool=npm))

	kw['check_for_interrupt'] = True
	run_shell(npm, *args, **kw)
Example #4
0
def _update_path_for_node(build):
	'''change sys.path to include the directory which holds node and npm

	:param build: :class:`Build` instance
	'''
	path_chunks = os.environ["PATH"].split(os.pathsep)

	# configuration setting overrides all
	manual = build.tool_config.get('web.node_path')
	if manual is None:
		manual = build.tool_config.get('general.live.node_path')

	if manual is None:
		possible_locations = defaultdict(list)
		possible_locations.update({
			'darwin': ['/opt/local/bin', '/usr/local/bin'],
			'linux': ['/usr/bin', '/usr/local/bin', '/opt/local/bin'],
			'win': ['C:/Program Files (x86)/nodejs', 'C:/Program Files/nodejs']
		})
		for location in possible_locations[sys.platform]:
			if not location in path_chunks:	
				path_chunks.append(location)
	else:
		# override given
		if not isinstance(manual, list):
			manual = [manual]

		if sys.platform.startswith("win"):
			# Popen will fail if os.environ has unicodes in on windows
			# not sure what encoding environ values should be in
			manual = [m.encode('ascii', errors='replace') for m in manual]

		LOG.info('Adding node locations from local_config.json to PATH %r' % manual)
		for manual_path in manual:
			abs_manual_path = os.path.abspath(manual_path)
			if abs_manual_path not in path_chunks:
				path_chunks.insert(0, abs_manual_path)
	
	new_path = os.pathsep.join(path_chunks)
	LOG.debug('Setting PATH to %r' % new_path)
	os.environ["PATH"] = new_path

	# check if we have node
	if sys.platform.startswith("win"):
		node = "node.exe"
	else:
		node = "node"

	if not utils.which(node):
		raise ServeError(NODEJS_HELP.format(tool=node))

	return new_path
Example #5
0
def _npm(build, *args, **kw):
	if sys.platform.startswith("win"):
		npm = "npm.cmd"
	else:
		npm = "npm"
	if not utils.which(npm):
		raise WebError("""Couldn't find {tool} on your PATH or in likely locations - is it installed?

You can use the 'node_path' setting in your local configuration to set a custom install directory"""
.format(tool=npm))

	kw['check_for_interrupt'] = True
	run_shell(npm, *args, **kw)
Example #6
0
def _npm(build, *args, **kw):
    if sys.platform.startswith("win"):
        npm = "npm.cmd"
    else:
        npm = "npm"
    if not utils.which(npm):
        raise WebError(
            """Couldn't find {tool} on your PATH or in likely locations - is it installed?

You can use the 'node_path' setting in your local configuration to set a custom install directory"""
            .format(tool=npm))

    kw['check_for_interrupt'] = True
    run_shell(npm, *args, **kw)
Example #7
0
	def run_idevice(self, build, device, provisioning_profile, certificate=None, certificate_path=None, certificate_password=None):
		possible_app_location = '{0}/ios/device-*/'.format(self.path_to_ios_build)
		LOG.debug('Looking for apps at {0}'.format(possible_app_location))
		possible_apps = glob(possible_app_location)
		if not possible_apps:
			raise IOSError("Couldn't find iOS app to run on a device")
		
		path_to_app = possible_apps[0]

		LOG.debug("Signing {app}".format(app=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")

		certificate = self._select_certificate(certificate)
		self.log_profile()
		
		if sys.platform.startswith('darwin'):
			with temp_file() as temp_file_path:
				self._create_entitlements_file(build, temp_file_path, plist_dict)
				
				self._sign_app(build=build,
					provisioning_profile=provisioning_profile,
					certificate=certificate,
					entitlements_file=temp_file_path,
				)
			
			fruitstrap = [ensure_lib_available(build, 'fruitstrap'), '-d', '-u', '-t', '10', '-b', path_to_app]
			if device and device.lower() != 'device':
				# pacific device given
				fruitstrap.append('-i')
				fruitstrap.append(device)
				LOG.info('Installing app on device {device}: is it connected?'.format(device=device))
			else:
				LOG.info('Installing app on device: is it connected?')

			def filter_and_combine(logline):
				return logline.rstrip()

			ensure_lib_available(build, 'lldb_framework.zip', extract=True)

			env = deepcopy(os.environ)
			env['PATH'] = os.path.dirname(ensure_lib_available(build, 'lldb'))+":"+env['PATH']

			run_shell(*fruitstrap, fail_silently=False, command_log_level=logging.INFO, filter=filter_and_combine, check_for_interrupt=True, env=env)
		elif sys.platform.startswith('win'):
			with temp_file() as ipa_path:
				self.create_ipa_from_app(
					build=build,
					provisioning_profile=provisioning_profile,
					output_path_for_ipa=ipa_path,
					certificate_path=certificate_path,
					certificate_password=certificate_password,
				)
				win_ios_install = [ensure_lib_available(build, 'win-ios-install.exe')]
				if device and device.lower() != 'device':
					# pacific device given
					win_ios_install.append(device)
					LOG.info('Installing app on device {device}: is it connected?'.format(device=device))
				else:
					LOG.info('Installing app on device: is it connected?')

				win_ios_install.append(ipa_path)
				win_ios_install.append(_generate_package_name(build))

				run_shell(*win_ios_install, fail_silently=False, command_log_level=logging.INFO, check_for_interrupt=True)
		else:
			if not which('ideviceinstaller'):
				raise Exception("Can't find ideviceinstaller - is it installed and on your PATH?")
			with temp_file() as ipa_path:
				self.create_ipa_from_app(
					build=build,
					provisioning_profile=provisioning_profile,
					output_path_for_ipa=ipa_path,
					certificate_path=certificate_path,
					certificate_password=certificate_password,
				)
				
				linux_ios_install = ['ideviceinstaller']
				
				if device and device.lower() != 'device':
					# pacific device given
					linux_ios_install.append('-U')
					linux_ios_install.append(device)
					LOG.info('Installing app on device {device}: is it connected?'.format(device=device))
				else:
					LOG.info('Installing app on device: is it connected?')
				
				linux_ios_install.append('-i')
				linux_ios_install.append(ipa_path)
				run_shell(*linux_ios_install, fail_silently=False,
					command_log_level=logging.INFO,
					check_for_interrupt=True)
				LOG.info('App installed, you will need to run the app on the device manually.')
	def run_iphone_device(self, build, device, provisioning_profile, certificate=None, certificate_path=None, certificate_password=None):

		path_to_app, app_folder_name = self._locate_device_app(build, "Couldn't find iOS app to run on a device")

		LOG.debug("Signing {app}".format(app=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(build, plist_dict, self.path_to_ios_build)
		self.provisioning_profile = plist_dict
		LOG.info("Plist OK")

		certificate = self._select_certificate(certificate)
		self.log_profile()
		
		if sys.platform.startswith('darwin'):
			with temp_file() as temp_file_path:
				self._create_entitlements_file(build, temp_file_path, plist_dict)
				
				self._sign_app(build=build,
					provisioning_profile=provisioning_profile,
					certificate=certificate,
					entitlements_file=temp_file_path,
					ident=_generate_package_name(build)
				)
			
			ios_deploy = [ensure_lib_available(build, 'ios-deploy'), '-d', '-u', '-t', '10', '-b', path_to_app]
			if device and device.lower() != 'device':
				# specific device given
				ios_deploy.append('-i')
				ios_deploy.append(device)
				LOG.info('Installing app on device {device}: is it connected?'.format(device=device))
			else:
				LOG.info('Installing app on device: is it connected?')

			def filter_and_combine(logline):
				return logline.rstrip()

			env = deepcopy(os.environ)

			run_shell(*ios_deploy, fail_silently=False, command_log_level=logging.INFO, filter=filter_and_combine, check_for_interrupt=True, env=env)
		elif sys.platform.startswith('win'):
			with temp_file() as ipa_path:
				self.create_ipa_from_app(
					build=build,
					provisioning_profile=provisioning_profile,
					output_path_for_ipa=ipa_path,
					certificate_path=certificate_path,
					certificate_password=certificate_password,
				)
				win_ios_install = [ensure_lib_available(build, 'win-ios-install.exe')]
				if device and device.lower() != 'device':
					# pacific device given
					win_ios_install.append(device)
					LOG.info('Installing app on device {device}: is it connected?'.format(device=device))
				else:
					LOG.info('Installing app on device: is it connected?')

				win_ios_install.append(ipa_path)
				win_ios_install.append(_generate_package_name(build))

				run_shell(*win_ios_install, fail_silently=False, command_log_level=logging.INFO, check_for_interrupt=True)
		else:
			if not which('ideviceinstaller'):
				raise Exception("Can't find ideviceinstaller - is it installed and on your PATH?")
			with temp_file() as ipa_path:
				self.create_ipa_from_app(
					build=build,
					provisioning_profile=provisioning_profile,
					output_path_for_ipa=ipa_path,
					certificate_path=certificate_path,
					certificate_password=certificate_password,
				)
				
				linux_ios_install = ['ideviceinstaller']
				
				if device and device.lower() != 'device':
					# pacific device given
					linux_ios_install.append('-U')
					linux_ios_install.append(device)
					LOG.info('Installing app on device {device}: is it connected?'.format(device=device))
				else:
					LOG.info('Installing app on device: is it connected?')
				
				linux_ios_install.append('-i')
				linux_ios_install.append(ipa_path)
				run_shell(*linux_ios_install, fail_silently=False,
					command_log_level=logging.INFO,
					check_for_interrupt=True)
				LOG.info('App installed, you will need to run the app on the device manually.')
Example #9
0
    def run_idevice(self,
                    build,
                    device,
                    provisioning_profile,
                    certificate=None,
                    certificate_path=None,
                    certificate_password=None):
        possible_app_location = '{0}/ios/device-*/'.format(
            self.path_to_ios_build)
        LOG.debug('Looking for apps at {0}'.format(possible_app_location))
        possible_apps = glob(possible_app_location)
        if not possible_apps:
            raise IOSError("Couldn't find iOS app to run on a device")

        path_to_app = possible_apps[0]

        LOG.debug("Signing {app}".format(app=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")

        certificate = self._select_certificate(certificate)
        self.log_profile()

        if sys.platform.startswith('darwin'):
            with temp_file() as temp_file_path:
                self._create_entitlements_file(build, temp_file_path,
                                               plist_dict)

                self._sign_app(build=build,
                               provisioning_profile=provisioning_profile,
                               certificate=certificate,
                               entitlements_file=temp_file_path,
                               ident=_generate_package_name(build))

            fruitstrap = [
                ensure_lib_available(build, 'fruitstrap'), '-d', '-u', '-t',
                '10', '-b', path_to_app
            ]
            if device and device.lower() != 'device':
                # pacific device given
                fruitstrap.append('-i')
                fruitstrap.append(device)
                LOG.info('Installing app on device {device}: is it connected?'.
                         format(device=device))
            else:
                LOG.info('Installing app on device: is it connected?')

            def filter_and_combine(logline):
                return logline.rstrip()

            ensure_lib_available(build, 'lldb_framework.zip', extract=True)

            env = deepcopy(os.environ)
            env['PATH'] = os.path.dirname(ensure_lib_available(
                build, 'lldb')) + ":" + env['PATH']

            run_shell(*fruitstrap,
                      fail_silently=False,
                      command_log_level=logging.INFO,
                      filter=filter_and_combine,
                      check_for_interrupt=True,
                      env=env)
        elif sys.platform.startswith('win'):
            with temp_file() as ipa_path:
                self.create_ipa_from_app(
                    build=build,
                    provisioning_profile=provisioning_profile,
                    output_path_for_ipa=ipa_path,
                    certificate_path=certificate_path,
                    certificate_password=certificate_password,
                )
                win_ios_install = [
                    ensure_lib_available(build, 'win-ios-install.exe')
                ]
                if device and device.lower() != 'device':
                    # pacific device given
                    win_ios_install.append(device)
                    LOG.info(
                        'Installing app on device {device}: is it connected?'.
                        format(device=device))
                else:
                    LOG.info('Installing app on device: is it connected?')

                win_ios_install.append(ipa_path)
                win_ios_install.append(_generate_package_name(build))

                run_shell(*win_ios_install,
                          fail_silently=False,
                          command_log_level=logging.INFO,
                          check_for_interrupt=True)
        else:
            if not which('ideviceinstaller'):
                raise Exception(
                    "Can't find ideviceinstaller - is it installed and on your PATH?"
                )
            with temp_file() as ipa_path:
                self.create_ipa_from_app(
                    build=build,
                    provisioning_profile=provisioning_profile,
                    output_path_for_ipa=ipa_path,
                    certificate_path=certificate_path,
                    certificate_password=certificate_password,
                )

                linux_ios_install = ['ideviceinstaller']

                if device and device.lower() != 'device':
                    # pacific device given
                    linux_ios_install.append('-U')
                    linux_ios_install.append(device)
                    LOG.info(
                        'Installing app on device {device}: is it connected?'.
                        format(device=device))
                else:
                    LOG.info('Installing app on device: is it connected?')

                linux_ios_install.append('-i')
                linux_ios_install.append(ipa_path)
                run_shell(*linux_ios_install,
                          fail_silently=False,
                          command_log_level=logging.INFO,
                          check_for_interrupt=True)
                LOG.info(
                    'App installed, you will need to run the app on the device manually.'
                )