Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
tools.find_run_binary Namespace Reference

Functions

 run_command (args)
 
 find_path_to_program (program)
 

Detailed Description

Module that finds and runs a binary by looking in the likely locations.

Function Documentation

◆ find_path_to_program()

tools.find_run_binary.find_path_to_program (   program)
Returns path to an existing program binary.

Args:
  program: Basename of the program to find (e.g., 'render_pictures').

Returns:
  Absolute path to the program binary, as a string.

Raises:
  Exception: unable to find the program binary.

Definition at line 36 of file find_run_binary.py.

36def find_path_to_program(program):
37 """Returns path to an existing program binary.
38
39 Args:
40 program: Basename of the program to find (e.g., 'render_pictures').
41
42 Returns:
43 Absolute path to the program binary, as a string.
44
45 Raises:
46 Exception: unable to find the program binary.
47 """
48 trunk_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
49 os.pardir))
50 possible_paths = [os.path.join(trunk_path, 'out', 'Release', program),
51 os.path.join(trunk_path, 'out', 'Debug', program),
52 os.path.join(trunk_path, 'out', 'Release',
53 program + '.exe'),
54 os.path.join(trunk_path, 'out', 'Debug',
55 program + '.exe')]
56 for try_path in possible_paths:
57 if os.path.isfile(try_path):
58 return try_path
59 raise Exception('cannot find %s in paths %s; maybe you need to '
60 'build %s?' % (program, possible_paths, program))
61

◆ run_command()

tools.find_run_binary.run_command (   args)
Runs a program from the command line and returns stdout.

Args:
  args: Command line to run, as a list of string parameters. args[0] is the
        binary to run.

Returns:
  stdout from the program, as a single string.

Raises:
  Exception: the program exited with a nonzero return code.

Definition at line 14 of file find_run_binary.py.

14def run_command(args):
15 """Runs a program from the command line and returns stdout.
16
17 Args:
18 args: Command line to run, as a list of string parameters. args[0] is the
19 binary to run.
20
21 Returns:
22 stdout from the program, as a single string.
23
24 Raises:
25 Exception: the program exited with a nonzero return code.
26 """
27 proc = subprocess.Popen(args,
28 stdout=subprocess.PIPE,
29 stderr=subprocess.PIPE)
30 (stdout, stderr) = proc.communicate()
31 if proc.returncode is not 0:
32 raise Exception('command "%s" failed: %s' % (args, stderr))
33 return stdout
34
35