Exemplo n.º 1
0
def lint_javascript(build):
	if build.forge_root is None:
		raise BASE_EXCEPTION("We don't know where the Forge tools are")

	log.info("Checking JavaScript files...")
	if sys.platform.startswith("linux"):
		if platform.architecture()[0] == '64bit':
			command = path.join(build.forge_root, "bin", "jsl-64")
		else:
			command = path.join(build.forge_root, "bin", "jsl")
	elif sys.platform.startswith("darwin"):
		command = path.join(build.forge_root, "bin", "jsl-mac")
	elif sys.platform.startswith("win"):
		command = path.join(build.forge_root, "bin", "jsl.exe")
	
	data = lib.PopenWithoutNewConsole(
		[
			command,
			"-conf",
			path.join(build.forge_root, "jsl.conf"),

			"-process",
			path.join(os.getcwd(), "src", "*.js"),

			"-nologo",
			"-nofilelisting",
			"-nosummary"
		],
		stdout=subprocess.PIPE
	).communicate()[0]
	map(log.warning, [line for line in data.split('\n') if line])
	log.info("JavaScript check complete")
Exemplo n.º 2
0
def _create_avd(path_info):
    args = [
        path_info.android,
        "create",
        "avd",
        "-n",
        "forge",
        "-t",
        "android-19",
        "--skin",
        "HVGA",
        "-p",
        path.join(path_info.sdk, 'forge-avd'),
        #"-a",
        "-c",
        "32M",
        "--force"
    ]
    proc = lib.PopenWithoutNewConsole(args,
                                      stdin=PIPE,
                                      stdout=PIPE,
                                      stderr=STDOUT)
    time.sleep(0.1)
    proc_std = proc.communicate(input='\n')[0]

    if proc.returncode != 0 or (proc_std and proc_std.startswith("Error")):
        raise ShellError(message="Error creating Android Virtual Device",
                         output=proc_std)
Exemplo n.º 3
0
        def _run_in_shell(queue):
            '''will be invoked in by a separate process, to actually run the
			detached command'''
            # setsid detaches us completely from the caller
            try:
                os.setsid()

                proc = lib.PopenWithoutNewConsole(args,
                                                  stdout=subprocess.PIPE,
                                                  stderr=subprocess.STDOUT)

                if not wait:
                    # assume success at this point if we're not waiting for process to finish
                    queue.put(0)

                for line in iter(proc.stdout.readline, ''):
                    queue.put(line)

                # signify success or error
                queue.put(proc.wait())

            except Exception as e:
                import traceback
                e._traceback = traceback.format_exc(e)
                queue.put(e)
Exemplo n.º 4
0
def _java_is_in_path():
    """Return True java exists on the path and can be invoked; False otherwise"""
    with open(os.devnull, 'w') as devnull:
        try:
            proc = lib.PopenWithoutNewConsole(['java', '-version'],
                                              stdout=devnull,
                                              stderr=devnull)
            proc.communicate()[0]
            return proc.returncode == 0
        except:
            return False
def run_hook(build, **kw):
    for file in sorted(os.listdir(os.path.join('hooks', kw['hook']))):
        if os.path.isfile(os.path.join('hooks', kw['hook'], file)):
            cwd = os.getcwd()
            os.chdir(kw['dir'])

            target = iter(build.enabled_platforms).next()

            # Get the extension
            ext = os.path.splitext(file)[-1][1:]

            proc = None
            if ext == "py":
                build.log.info('Running (Python) hook: ' + file)
                proc = lib.PopenWithoutNewConsole([
                    "python",
                    os.path.join(cwd, 'hooks', kw['hook'], file), target
                ])
            elif ext == "js":
                build.log.info('Running (node) hook: ' + file)
                proc = lib.PopenWithoutNewConsole([
                    "node",
                    os.path.join(cwd, 'hooks', kw['hook'], file), target
                ])
            elif ext == "bat" and sys.platform.startswith('win'):
                build.log.info('Running (Windows Batch file) hook: ' + file)
                proc = lib.PopenWithoutNewConsole(
                    [os.path.join(cwd, 'hooks', kw['hook'], file), target])
            elif ext == "sh" and not sys.platform.startswith('win'):
                build.log.info('Running (shell) hook: ' + file)
                proc = lib.PopenWithoutNewConsole(
                    [os.path.join(cwd, 'hooks', kw['hook'], file), target])

            if proc != None:
                proc.wait()

            os.chdir(cwd)

            if proc != None and proc.returncode != 0:
                raise ConfigurationError(
                    'Hook script exited with a non-zero return code.')
Exemplo n.º 6
0
    def target():
        try:
            runner['process'] = lib.PopenWithoutNewConsole(cmd,
                                                           stdout=PIPE,
                                                           stderr=STDOUT)
        except OSError as e:
            if e.errno == errno.ENOENT:
                # XXX: prompt to update the platform tools, then retry?
                raise AndroidError(
                    NO_ADB_TEMPLATE.format(adb_location=path_info.adb))
            raise

        runner['std_out'] = runner['process'].communicate()[0]
Exemplo n.º 7
0
def _download_sdk_for_mac(temp_d):
    archive_path = path.join(temp_d, "sdk.zip")
    lib.download_with_progress_bar('Downloading Android SDK',
                                   _android_sdk_url(), archive_path)

    LOG.info('Download complete, extracting SDK')
    zip_process = lib.PopenWithoutNewConsole(
        ["unzip", archive_path, '-d', "/Applications"],
        stdout=PIPE,
        stderr=STDOUT)
    output = zip_process.communicate()[0]
    LOG.debug("unzip output")
    LOG.debug(output)

    return "/Applications/android-sdk-macosx/"
Exemplo n.º 8
0
def _download_sdk_for_linux(temp_d):
    archive_path = path.join(temp_d, "sdk.zip")
    lib.download_with_progress_bar('Downloading Android SDK',
                                   _android_sdk_url(), archive_path)

    LOG.info('Download complete, extracting SDK')
    if not path.isdir(path.expanduser("~/.forge")):
        os.mkdir(path.expanduser("~/.forge"))

    zip_process = lib.PopenWithoutNewConsole(
        ["unzip", archive_path, '-d',
         path.expanduser("~/.forge")],
        stdout=PIPE,
        stderr=STDOUT)
    output = zip_process.communicate()[0]
    LOG.debug("unzip output")
    LOG.debug(output)

    return path.expanduser("~/.forge/android-sdk-linux/")
Exemplo n.º 9
0
def build_wp(build, new_working_dir):
    original_dir = os.getcwd()
    build_cmd = [
        'c:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe',
        'Forge.sln', '/t:Forge', '/p:Configuration=Release'
    ]
    LOG.info('Changing dir to do Visual Studio build: %s, was in %s' %
             (new_working_dir, original_dir))
    try:
        os.chdir(new_working_dir)
        msbuild = lib.PopenWithoutNewConsole(build_cmd,
                                             stdout=PIPE,
                                             stderr=STDOUT)
        out = msbuild.communicate()[0]
        if msbuild.returncode != 0:
            build.log.error('Visual Studio build error: %s' % out)
            raise Exception('Visual Studio build error')
        else:
            build.log.debug('Visual Studio build output: %s' % out)
    finally:
        os.chdir(original_dir)
Exemplo n.º 10
0
def _update_sdk(path_info):
    LOG.info('Updating SDK and downloading required Android platform '
             '(about 90MB, may take some time)')

    APPROX_UPPER_BOUND_ON_ANDROID_OUTPUT = 60
    android_process = lib.PopenWithoutNewConsole(
        [
            path_info.android, "update", "sdk", "--no-ui", "--filter",
            "platform-tool,tool,android-8"
        ],
        stdout=PIPE,
        stderr=STDOUT,
    )

    with ProgressBar('Installing Android SDK Components') as bar:
        finished = []

        def kill_adb_occasionally():
            """When updating the android sdk, occasionally ADB will have a lock on
			some files causing the update to fail. Killing it here helps the update succeed.
			"""
            while not finished:
                time.sleep(5)
                try:
                    # XXX: still time from check to use issue, but close enough
                    if not finished:
                        _kill_adb()
                except Exception:
                    pass

        adb_killing_thread = threading.Thread(target=kill_adb_occasionally)
        adb_killing_thread.daemon = True
        adb_killing_thread.start()

        for i, line in enumerate(iter(android_process.stdout.readline, '')):
            bar.progress(float(i) / APPROX_UPPER_BOUND_ON_ANDROID_OUTPUT)

        finished.append(True)