def _lookup_or_prompt_for_signing_info(build):
	"""Obtain the required details for signing an APK, first by checking local_config.json
	and then asking the user for anything missing.
	"""

	required_info = {
		'keystore': {
			'type': 'string',
			'_filepicker': True,
			'description': 'The location of your release keystore',
			'title': 'Keystore',
		},
		'storepass': {
			'type': 'string',
			'_password': True,
			'description': 'The password for your release keystore',
			'title': 'Keystore password',
		},
		'keyalias': {
			'type': 'string',
			'description': 'The alias of your release key',
			'title': 'Key alias',
		},
		'keypass': {
			'type': 'string',
			'_password': True,
			'description': 'The password for your release key',
			'title': 'Key password'
		}
	}

	known_info = {}
	unknown_info = {}

	# figure out which info we have in local_config.json and which we need to ask for
	for prop_name in required_info.keys():
		local_config_value = build.tool_config.get('android.profile.%s' % prop_name)

		if local_config_value:
			known_info[prop_name] = local_config_value
		else:
			unknown_info[prop_name] = required_info[prop_name]

	# if there's anything we need to ask for, ask for it
	if unknown_info:
		event_id = lib.current_call().emit('question', schema={
			'title': 'Enter details for signing your app',
			'properties': unknown_info
		})

		response = lib.current_call().wait_for_response(event_id)
		if not response.get('data'):
			raise AndroidError("User aborted")

		# TODO: save info submitted by user
		known_info.update(response['data'])

	return known_info
示例#2
0
def _lookup_or_prompt_for_signing_info(build):
    """Obtain the required details for signing an APK, first by checking local_config.json
	and then asking the user for anything missing.
	"""

    required_info = {
        'keystore': {
            'type': 'string',
            '_filepicker': True,
            'description': 'The location of your release keystore',
            'title': 'Keystore',
        },
        'storepass': {
            'type': 'string',
            '_password': True,
            'description': 'The password for your release keystore',
            'title': 'Keystore password',
        },
        'keyalias': {
            'type': 'string',
            'description': 'The alias of your release key',
            'title': 'Key alias',
        },
        'keypass': {
            'type': 'string',
            '_password': True,
            'description': 'The password for your release key',
            'title': 'Key password'
        }
    }

    known_info = {}
    unknown_info = {}

    # figure out which info we have in local_config.json and which we need to ask for
    for prop_name in required_info.keys():
        local_config_value = build.tool_config.get('android.profile.%s' %
                                                   prop_name)

        if local_config_value:
            known_info[prop_name] = local_config_value
        else:
            unknown_info[prop_name] = required_info[prop_name]

    # if there's anything we need to ask for, ask for it
    if unknown_info:
        event_id = lib.current_call().emit(
            'question',
            schema={
                'description': 'Enter details for signing your app',
                'properties': unknown_info
            })

        response = lib.current_call().wait_for_response(event_id)
        # TODO: save info submitted by user
        known_info.update(response['data'])

    return known_info
示例#3
0
def _lookup_or_prompt_for_signing_info(build):
    """Obtain the required details for signing an APK, first by checking local_config.json
	and then asking the user for anything missing.
	"""

    required_info = {
        "keystore": {
            "type": "string",
            "_filepicker": True,
            "description": "The location of your release keystore",
            "title": "Keystore",
        },
        "storepass": {
            "type": "string",
            "_password": True,
            "description": "The password for your release keystore",
            "title": "Keystore password",
        },
        "keyalias": {"type": "string", "description": "The alias of your release key", "title": "Key alias"},
        "keypass": {
            "type": "string",
            "_password": True,
            "description": "The password for your release key",
            "title": "Key password",
        },
    }

    known_info = {}
    unknown_info = {}

    # figure out which info we have in local_config.json and which we need to ask for
    for prop_name in required_info.keys():
        local_config_value = build.tool_config.get("android.profile.%s" % prop_name)

        if local_config_value:
            known_info[prop_name] = local_config_value
        else:
            unknown_info[prop_name] = required_info[prop_name]

            # if there's anything we need to ask for, ask for it
    if unknown_info:
        event_id = lib.current_call().emit(
            "question", schema={"description": "Enter details for signing your app", "properties": unknown_info}
        )

        response = lib.current_call().wait_for_response(event_id)
        # TODO: save info submitted by user
        known_info.update(response["data"])

    return known_info
示例#4
0
def run_shell(*args, **kw):
	check_for_interrupt = kw.get('check_for_interrupt', False)
	create_process_group = kw.get('create_process_group', False)
	fail_silently = kw.get('fail_silently', False)
	command_log_level = kw.get("command_log_level", logging.DEBUG)
	filter = kw.get("filter", False)

	state = RunnerState()
	state.done = False
	state.output = StringIO.StringIO()
	state.proc = None
	state.error = None

	def runner():
		try:
			preexec_fn = _required_preexec(create_process_group, os)
			state.proc = lib.PopenWithoutNewConsole(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=kw.get('env'), preexec_fn=preexec_fn)

			for line in iter(state.proc.stdout.readline, ''):
				if not filter or filter(line):
					state.output.write(line)
					LOG.log(command_log_level, line.rstrip('\r\n'))

			state.done = True
		except Exception as e:
			state.done = True
			state.error = e


	if check_for_interrupt:
		try:
			call = lib.current_call()
			runner_thread = threading.Thread(target=runner)
			runner_thread.daemon = True
			runner_thread.start()

			while not state.done:
				time.sleep(1)
				call.assert_not_interrupted()
		finally:
			# if interrupted, kill child process
			if state.proc and not state.done:
				lib.progressive_kill(state.proc.pid, kill_process_group=True)

	else:
		runner()

	if state.error:
		raise state.error

	if state.proc.wait() != 0:
		if fail_silently:
			LOG.debug('Failed to run %s, but was told to carry on anyway' % subprocess.list2cmdline(args))
		else:
			raise ShellError(
				message="Failed when running {command}".format(command=args[0]),
				output=state.output.getvalue()
			)

	return state.output.getvalue()
示例#5
0
def run_shell(*args, **kw):
    check_for_interrupt = kw.get('check_for_interrupt', False)
    fail_silently = kw.get('fail_silently', False)
    command_log_level = kw.get("command_log_level", logging.DEBUG)
    filter = kw.get("filter", False)

    state = RunnerState()
    state.done = False
    state.output = StringIO.StringIO()
    state.proc = None

    def runner():
        LOG.debug('Running: {cmd}'.format(cmd=subprocess.list2cmdline(args)))
        state.proc = lib.PopenWithoutNewConsole(args,
                                                stdout=subprocess.PIPE,
                                                stderr=subprocess.STDOUT,
                                                env=kw.get('env'))

        for line in iter(state.proc.stdout.readline, ''):
            if not filter or filter(line):
                state.output.write(line)
                LOG.log(command_log_level, line.rstrip('\r\n'))

        state.done = True

    if check_for_interrupt:
        try:
            call = lib.current_call()
            runner_thread = threading.Thread(target=runner)
            runner_thread.daemon = True
            runner_thread.start()

            while not state.done:
                time.sleep(1)
                call.assert_not_interrupted()
        finally:
            # if interrupted, kill child process
            if state.proc and not state.done:
                lib.progressive_kill(state.proc.pid)

    else:
        runner()

    if state.proc.wait() != 0:
        if fail_silently:
            LOG.debug('Failed to run %s, but was told to carry on anyway' %
                      subprocess.list2cmdline(args))
        else:
            raise ShellError(message="Failed when running {command}".format(
                command=args[0]),
                             output=state.output.getvalue())

    return state.output.getvalue()
示例#6
0
def _request_heroku_credentials():
	"""Prompts the user for heroku username and password and returns them"""
	call = lib.current_call()
	question_schema = {
		'title': 'Enter your heroku login details',
		'properties': {
			'username': {
				'type': 'string',
				'title': 'Username',
				'description': 'Your heroku username',
				'_order': 1,
			},

			'password': {
				'type': 'string',
				'title': 'Password',
				'description': 'Your heroku password',
				'_password': True,
				'_order': 0,
			}
		}
	}

	while True:
		event_id = call.emit('question', schema=question_schema)
		response = call.wait_for_response(event_id)
		response_data = response.get('data')

		if response_data is None:
			raise WebError("User aborted")

		heroku_username = response_data.get('username')
		heroku_password = response_data.get('password')

		if not heroku_username:
			LOG.warning("Username required")
			continue

		if not heroku_password:
			LOG.warning("Password required")
			continue

		return heroku_username, heroku_password
示例#7
0
def _request_heroku_credentials():
	"""Prompts the user for heroku username and password and returns them"""
	call = lib.current_call()
	question_schema = {
		'title': 'Enter your heroku login details',
		'properties': {
			'username': {
				'type': 'string',
				'title': 'Username',
				'description': 'Your heroku username',
				'_order': 1,
			},

			'password': {
				'type': 'string',
				'title': 'Password',
				'description': 'Your heroku password',
				'_password': True,
				'_order': 0,
			}
		}
	}

	while True:
		event_id = call.emit('question', schema=question_schema)
		response = call.wait_for_response(event_id)
		response_data = response.get('data')

		if response_data is None:
			raise WebError("User aborted")

		heroku_username = response_data.get('username')
		heroku_password = response_data.get('password')

		if not heroku_username:
			LOG.warning("Username required")
			continue

		if not heroku_password:
			LOG.warning("Password required")
			continue

		return heroku_username, heroku_password
示例#8
0
    def wait_for_success(self):
        """Wait for every process to succeed.
		
		If one process fails, shuts all the other processes down.
		If an interrupt is received from the tools, shuts all processes down.
		"""
        call = lib.current_call()

        try:
            while self._running_processes != {}:
                try:
                    finished_pid = self._notifications.get(timeout=1)
                    finished_proc = self._running_processes[finished_pid]
                    finished_proc.assert_success()
                    del self._running_processes[finished_pid]

                except Queue.Empty:
                    call.assert_not_interrupted()

        finally:
            self._shutdown_running_processes()
	def wait_for_success(self):
		"""Wait for every process to succeed.
		
		If one process fails, shuts all the other processes down.
		If an interrupt is received from the tools, shuts all processes down.
		"""
		call = lib.current_call()

		try:
			while self._running_processes != {}:
				try:
					finished_pid = self._notifications.get(timeout=1)
					finished_proc = self._running_processes[finished_pid]
					finished_proc.assert_success()
					del self._running_processes[finished_pid]

				except Queue.Empty:
					call.assert_not_interrupted()

		finally:
			self._shutdown_running_processes()
示例#10
0
def _request_heroku_credentials():
    """Prompts the user for heroku username and password and returns them"""
    call = lib.current_call()
    question_schema = {
        "title": "Enter your heroku login details",
        "properties": {
            "username": {"type": "string", "title": "Username", "description": "Your heroku username", "_order": 1},
            "password": {
                "type": "string",
                "title": "Password",
                "description": "Your heroku password",
                "_password": True,
                "_order": 0,
            },
        },
    }

    while True:
        event_id = call.emit("question", schema=question_schema)
        response = call.wait_for_response(event_id)
        response_data = response.get("data")

        if response_data is None:
            raise WebError("User aborted")

        heroku_username = response_data.get("username")
        heroku_password = response_data.get("password")

        if not heroku_username:
            LOG.warning("Username required")
            continue

        if not heroku_password:
            LOG.warning("Password required")
            continue

        return heroku_username, heroku_password