コード例 #1
0
def do_on_fail_pass(start_message, cb):
    Print.status(start_message)
    try:
        cb()
    except Exception as e:
        pass
    Print.ok()
コード例 #2
0
ファイル: lib_raise_linker.py プロジェクト: workhorsy/raise
def ldconfig():
	# Setup the message
	Print.status("Running 'ldconfig'")

	# Skip ldconfig on Cygwin
	if Config.os_type in OSType.Cygwin:
		Print.ok()
		return

	# Find ldconfig
	prog = Find.program_paths('ldconfig')
	if not prog:
		Print.fail()
		Print.exit("Could not find 'ldconfig'.")

	# Run the process
	runner = findlib.ProcessRunner(prog[0])
	runner.run()
	runner.is_done
	runner.wait()

	# Success or failure
	if runner.is_failure:
		Print.fail(runner.stdall)
		Print.exit("Failed run 'ldconfig'.")
	elif runner.is_success or runner.is_warning:
		Print.ok()
コード例 #3
0
ファイル: lib_raise_fs.py プロジェクト: workhorsy/raise
def remove_dir(name, and_children = False):
	Print.status("Removing the dir '{0}'".format(name))
	success = False

	# Make sure we are not removing the current directory
	if name == os.getcwd():
		Print.fail()
		Print.exit("Can't remove the current directory '{0}'.".format(name))

	try:
		for entry in glob_names(name):
			if os.path.islink(entry):
				os.unlink(entry)
			elif os.path.isdir(entry):
				if and_children:
					shutil.rmtree(entry)
				else:
					os.rmdir(entry)
		success = True
	except OSError as e:
		if 'No such file or directory' in e:
			success = True

	if success:
		Print.ok()
	else:
		Print.fail()
		Print.exit("Failed to remove the dir '{0}'.".format(name))
コード例 #4
0
ファイル: lib_raise_find.py プロジェクト: workhorsy/raise
def require_programs(prog_names):
	for prog_name in prog_names:
		Print.status("Checking for program '{0}'".format(prog_name))
		if len(findlib.program_paths(prog_name)):
			Print.ok()
		else:
			Print.fail()
			Print.exit("Install the program '{0}' and try again.".format(prog_name))
コード例 #5
0
ファイル: lib_raise_find.py プロジェクト: workhorsy/raise
def require_environmental_variable(env_name, version_cb = None):
	Print.status("Checking for environmental variable '{0}'".format(env_name))

	if not os.environ.get(env_name):
		message = "The environmental variable '{0}' was not found. Set it and try again."
		Print.fail()
		Print.exit(message.format(env_name))
	else:
		Print.ok()
コード例 #6
0
ファイル: lib_raise_fs.py プロジェクト: workhorsy/raise
def remove_binaries(name):
	Print.status("Removing binaries '{0}'".format(name))

	extensions = ['.exe', '.o', '.obj', '.so', '.a', '.dll', '.lib', '.pyc',
				'.exe.mdb', '.dll.mdb', '.jar', '.class']

	for entry in os.listdir(os.getcwd()):
		if entry.startswith(name) and os.path.isfile(entry):
			extension = '.' + str.join('.', entry.lower().split('.')[1:])
			if extension in extensions or entry == name:
				os.remove(entry)

	Print.ok()
コード例 #7
0
ファイル: lib_raise_find.py プロジェクト: workhorsy/raise
def require_header_file(header_name, version_str = None):
	Print.status("Checking for header file '{0}'".format(header_name))

	# If the header is not installed, make them install it to continue
	if not findlib.get_header_file(header_name, version_str):
		ver = "(Any version)"
		if version_str:
			ver = version_str

		message = "Header file '{0} {1}' not installed. Install and try again."
		Print.fail()
		Print.exit(message.format(header_name, ver))
	else:
		Print.ok()
コード例 #8
0
ファイル: lib_raise_find.py プロジェクト: workhorsy/raise
def require_shared_library(lib_name, version_str = None):
	Print.status("Checking for shared library '{0}'".format(lib_name))

	# If the shared library is not installed, make them install it to continue
	if not findlib.get_shared_library(lib_name, version_str):
		# Get the version requirement lambda as a printable string
		ver = "(Any version)"
		if version_str:
			ver = version_str

		message = "Shared library '{0} {1}' not installed. Install and try again."
		Print.fail()
		Print.exit(message.format(lib_name, ver))
	else:
		Print.ok()
コード例 #9
0
ファイル: lib_raise_find.py プロジェクト: workhorsy/raise
def require_static_or_shared_library(lib_name, version_str = None):
	Print.status("Checking for static/shared library '{0}'".format(lib_name))

	shared_file = get_shared_library(lib_name, version_str)
	static_file = get_shared_library(lib_name, version_str)

	# Make them install the lib if neither was found
	if not shared_file and not static_file:
		# Get the version requirement lambda as a printable string
		ver = "(Any version)"
		if version_str:
			ver = version_str

		message = "Shared/Static library '{0} {1}' not installed. Install and try again."
		Print.fail()
		Print.exit(message.format(lib_name, ver))
	else:
		Print.ok()
コード例 #10
0
def run_print(command):
    Print.status("Running C++ program")

    native_command = to_native(command)
    runner = findlib.ProcessRunner(native_command)
    runner.run()
    runner.is_done
    runner.wait()

    if runner.is_success or runner.is_warning:
        Print.ok()
        sys.stdout.write(command + '\n')
        sys.stdout.write(runner.stdall)
    elif runner.is_failure:
        Print.fail()
        sys.stdout.write(command + '\n')
        sys.stdout.write(runner.stdall)
        Print.exit('Failed to run command.')
コード例 #11
0
    def wait(self):
        # Wait for the process to complete
        self._runner.wait()

        # Display the message
        if Event.is_concurrent:
            Print.status("   '{0}'".format(self._result))

        # Success or failure
        if self._runner.is_success:
            Print.ok()
            self._status = 'success'
        elif self._runner.is_warning:
            Print.warning(self._runner.stderr)
            self._status = 'success'
        else:
            Print.fail(self._runner.stdall)
            Print.exit("{0} failed. Try again.".format(self._task))
            self._status = 'failure'
コード例 #12
0
ファイル: lib_raise_fs.py プロジェクト: workhorsy/raise
def remove_file(name, ignore_failure = False):
	Print.status("Removing the file '{0}'".format(name))
	success = False

	try:
		for entry in glob_names(name):
			if os.path.islink(entry):
				os.unlink(entry)
			elif os.path.isfile(entry):
				os.remove(entry)
		success = True
	except Exception as e:
		if ignore_failure:
			success = True

	if success:
		Print.ok()
	else:
		Print.fail()
		Print.exit("Failed to remove the file '{0}'.".format(name))
コード例 #13
0
def do_on_fail_exit(start_message, fail_message, cb):
    Print.status(start_message)

    # Run it if it is a function
    if hasattr(cb, '__call__'):
        try:
            cb()
            Print.ok()
        except Exception as e:
            Print.fail()
            Print.exit(fail_message)
    # Or run it as a process if a string
    elif type(cb) == str:
        runner = findlib.ProcessRunner(cb)
        runner.run()
        runner.is_done
        runner.wait()
        if runner.is_success or runner.is_warning:
            Print.ok()
        elif runner.is_failure:
            Print.fail()
            Print.exit(fail_message)
コード例 #14
0
ファイル: lib_raise_find.py プロジェクト: workhorsy/raise
def _on_ok():
	Terminal.ok()