-def error(message):
- sys.stderr.write(message + '\n')
- sys.exit(1)
-
-
-def find_exe(candidates, path):
- for prog in candidates:
- for directory in path:
- full_path = os.path.join(directory, prog)
- if os.access(full_path, os.X_OK):
- return full_path
-
- return None
-
-
-def find_exe_or_terminate(candidates, path):
- exe = find_exe(candidates, path)
- if exe == None:
- error("Unable to find executable from '%s'" % string.join(candidates))
-
- return exe
-
-
-def run_command(cmd):
- handle = os.popen(cmd, 'r')
- cmd_stdout = handle.read()
- cmd_status = handle.close()
-
- return cmd_status, cmd_stdout
-
-
-def make_texcolor(hexcolor):
- # Test that the input string contains 6 hexadecimal chars.
- if not hexcolor_re.match(hexcolor):
- error("Cannot convert color '%s'" % hexcolor)
-
- red = float(string.atoi(hexcolor[0:2], 16)) / 255.0
- green = float(string.atoi(hexcolor[2:4], 16)) / 255.0
- blue = float(string.atoi(hexcolor[4:6], 16)) / 255.0
-
- return "rgb %f %f %f" % (red, green, blue)
-
-