Esempio n. 1
0
def _get_app_to_push_to(build, api_key):
    app = build.tool_config.get('web.profile.heroku_app_name')

    if app is not None:
        return app

    LOG.info('Querying heroku about registered apps...')
    apps = json.loads(_heroku_get(api_key, 'apps').content)
    app_names = [a['name'] for a in apps]

    create_new_heroku_app = True
    if app_names:
        message = (
            "You don't have a heroku app name specified in local_config.json."
            'You can choose either to:')

        chosen_n = lib.ask_multichoice(
            question_text=message,
            choices=[
                'Create a new heroku application',
                'Push to a currently registered heroku application'
            ])

        if chosen_n == 1:
            create_new_heroku_app = True
        else:
            create_new_heroku_app = False

    # either create a new heroku app, or choose an already existing app
    if create_new_heroku_app:
        LOG.info('Creating new heroku application')
        response = _heroku_post(api_key, 'apps', data='app[stack]=cedar')
        chosen_app = json.loads(response.content)['name']

    else:
        chosen_n = lib.ask_multichoice(
            question_text='Choose an existing heroku app to deploy to:',
            choices=app_names,
            radio=False)
        chosen_app = app_names[chosen_n - 1]

    lib.set_dotted_attributes(build,
                              {'web.profile.heroku_app_name': chosen_app})
    return chosen_app
Esempio n. 2
0
def _get_app_to_push_to(build, api_key):
	app = build.tool_config.get('web.profile.heroku_app_name')

	if app is not None:
		return app

	LOG.info('Querying heroku about registered apps...')
	apps = json.loads(_heroku_get(api_key, 'apps').content)
	app_names = [app['name'] for app in apps]

	create_new_heroku_app = True
	if app_names:
		message = (
			"You don't have a heroku app name specified in local_config.json."
			'You can choose either to:'
		)

		chosen_n = lib.ask_multichoice(question_text=message, choices=[
			'Create a new heroku application',
			'Push to a currently registered heroku application'
		])

		if chosen_n == 1:
			create_new_heroku_app = True
		else:
			create_new_heroku_app = False

	# either create a new heroku app, or choose an already existing app
	if create_new_heroku_app:
		LOG.info('Creating new heroku application')
		response = _heroku_post(api_key, 'apps', data='app[stack]=cedar')
		chosen_app = json.loads(response.content)['name']

	else:
		chosen_n = lib.ask_multichoice(question_text='Choose an existing heroku app to deploy to:', choices=app_names, radio=False)
		chosen_app = app_names[chosen_n - 1]

	lib.set_dotted_attributes(build, {
		'web.profile.heroku_app_name': chosen_app
	})
	return chosen_app
Esempio n. 3
0
def _prompt_user_to_attach_device(path_info):
	"""Ask user if they want to launch an AVD or attempt to find a device again."""
 
	choice = lib.ask_multichoice(question_text='No active Android device found, would you like to:', choices=[
		'Attempt to automatically launch the Android emulator',
		'Attempt to find the device again (choose this option after plugging in an Android device or launching the emulator)',
	])

	if choice != 1:
		return

	_create_avd_if_necessary(path_info)
	_launch_avd(path_info)
Esempio n. 4
0
def _ask_user_if_should_install_sdk():
	if sys.platform.startswith('win'):
		sdk_path = "C:\\android-sdk-windows"
	elif sys.platform.startswith('linux'):
		sdk_path = path.expanduser("~/.forge/android-sdk-linux")
	elif sys.platform.startswith('darwin'):
		sdk_path = "/Applications/android-sdk-macosx"
	# TODO: else ask user where to install to?

	choice = lib.ask_multichoice(question_text='No Android SDK found on your system, you can either:', choices=[
		'Attempt to download and install the SDK automatically to {sdk_path}'.format(sdk_path=sdk_path),
		'Specify the location of an already existing Android SDK installation'
	])

	return choice == 1
Esempio n. 5
0
def _prompt_user_to_attach_device(path_info):
    """Ask user if they want to launch an AVD or attempt to find a device again."""

    choice = lib.ask_multichoice(
        question_text='No active Android device found, would you like to:',
        choices=[
            'Attempt to automatically launch the Android emulator',
            'Attempt to find the device again (choose this option after plugging in an Android device or launching the emulator)',
        ])

    if choice != 1:
        return

    _create_avd_if_necessary(path_info)
    _launch_avd(path_info)
Esempio n. 6
0
def _ask_user_if_should_install_sdk():
    if sys.platform.startswith('win'):
        sdk_path = "C:\\android-sdk-windows"
    elif sys.platform.startswith('linux'):
        sdk_path = path.expanduser("~/.forge/android-sdk-linux")
    elif sys.platform.startswith('darwin'):
        sdk_path = "/Applications/android-sdk-macosx"
    # TODO: else ask user where to install to?

    choice = lib.ask_multichoice(
        question_text='No Android SDK found on your system, you can either:',
        choices=[
            'Attempt to download and install the SDK automatically to {sdk_path}'
            .format(sdk_path=sdk_path),
            'Specify the location of an already existing Android SDK installation'
        ])

    return choice == 1