예제 #1
0
 def load(cls, filename, options):
     """ Loads an effect from a given filename with the specified options.
     This lookups in the global effect cache, and checks if a similar effect
     (i.e. with the same hash) was already loaded, and in that case returns it.
     Otherwise a new effect with the given options is created. """
     effect_hash = cls._generate_hash(filename, options)
     if effect_hash in cls._GLOBAL_CACHE:
         return cls._GLOBAL_CACHE[effect_hash]
     effect = cls()
     effect.set_options(options)
     if not effect.do_load(filename):
         RPObject.global_error("Effect", "Could not load effect!")
         return None
     return effect
예제 #2
0
파일: effect.py 프로젝트: croxis/SpaceDrive
 def load(cls, filename, options):
     """ Loads an effect from a given filename with the specified options.
     This lookups in the global effect cache, and checks if a similar effect
     (i.e. with the same hash) was already loaded, and in that case returns it.
     Otherwise a new effect with the given options is created. """
     effect_hash = cls._generate_hash(filename, options)
     if effect_hash in cls._GLOBAL_CACHE:
         return cls._GLOBAL_CACHE[effect_hash]
     effect = cls()
     effect.set_options(options)
     if not effect.do_load(filename):
         RPObject.global_error("Effect", "Could not load effect!")
         return None
     return effect
예제 #3
0
def load_yaml_file(filename):
    """ This method is a wrapper arround yaml_load, and provides error checking """

    import time
    start = time.clock()

    try:
        with open(filename, "r") as handle:
            parsed_yaml = yaml_load(handle, Loader=SafeLoader)
    except IOError as msg:
        RPObject.global_error("YAMLLoader", "Could not find or open file:",
                              filename)
        RPObject.global_error("YAMLLoader", msg)
        raise Exception("Failed to load YAML file: File not found")
    except YAMLError as msg:
        RPObject.global_error("YAMLLoader", "Invalid yaml-syntax in file:",
                              filename)
        RPObject.global_error("YAMLLoader", msg)
        raise Exception("Failed to load YAML file: Invalid syntax")

    duration = (time.clock() - start) * 1000.0

    # Optionally print out profiling information
    # print("Took", round(duration, 2), "ms to load", filename)

    return parsed_yaml
    def update(self):
        """ Updates the error display, fetching all new messages from the notify
        stream """

        if not self._notify_stream:
            self._init_notify()

        while self._notify_stream.is_text_available():
            line = self._notify_stream.get_line().strip()
            if "warning" in line:
                RPObject.global_warn("Panda3D", line)
                # self.add_warning(line)
            elif "error" in line:
                RPObject.global_error("Panda3D", line)
                self.add_error(line)
            else:
                RPObject.global_debug("Panda3D", line)
    def update(self):
        """ Updates the error display, fetching all new messages from the notify
        stream """

        if not self._notify_stream:
            self._init_notify()

        while self._notify_stream.is_text_available():
            line = self._notify_stream.get_line().strip()
            if "warning" in line:
                RPObject.global_warn("Panda3D", line)
                # self.add_warning(line)
            elif "error" in line:
                RPObject.global_error("Panda3D", line)
                self.add_error(line)
            else:
                RPObject.global_debug("Panda3D", line)
예제 #6
0
def load_yaml_file(filepath):
    """ This method is a wrapper arround yaml_load, and provides error checking """

    # import time
    # start = time.process_time()

    try:
        vfs = VirtualFileSystem.get_global_ptr()
        if vfs.exists(filepath):  # load from VFS
            handle = io.BytesIO(vfs.read_file(filepath, False))
        else:  # load from zipped package
            if filepath.startswith('/$$rp/'):
                filepath = filepath.replace('/$$rp/', '')
            modpath = os.path.dirname(filepath).replace('/', '.')
            filename = os.path.basename(filepath)
            handle = io.BytesIO(pkgutil.get_data(modpath, filename))

        parsed_yaml = yaml_load(handle, Loader=SafeLoader)
        handle.close()
    except IOError as msg:
        RPObject.global_error("YAMLLoader", "Could not find or open file:",
                              filename)
        RPObject.global_error("YAMLLoader", msg)
        raise Exception("Failed to load YAML file: File not found")
    except YAMLError as msg:
        RPObject.global_error("YAMLLoader", "Invalid yaml-syntax in file:",
                              filename)
        RPObject.global_error("YAMLLoader", msg)
        raise Exception("Failed to load YAML file: Invalid syntax")

    # duration = (time.process_time() - start) * 1000.0

    # Optionally print out profiling information
    # print("Took", round(duration, 2), "ms to load", filename)

    return parsed_yaml
예제 #7
0
def load_yaml_file(filename):
    """ This method is a wrapper arround yaml_load, and provides error checking """

    import time
    start = time.clock()

    try:
        with open(filename, "r") as handle:
            parsed_yaml = yaml_load(handle, Loader=SafeLoader)
    except IOError as msg:
        RPObject.global_error("YAMLLoader", "Could not find or open file:", filename)
        RPObject.global_error("YAMLLoader", msg)
        raise Exception("Failed to load YAML file: File not found")
    except YAMLError as msg:
        RPObject.global_error("YAMLLoader", "Invalid yaml-syntax in file:", filename)
        RPObject.global_error("YAMLLoader", msg)
        raise Exception("Failed to load YAML file: Invalid syntax")

    duration = (time.clock() - start) * 1000.0

    # Optionally print out profiling information
    # print("Took", round(duration, 2), "ms to load", filename)

    return parsed_yaml
예제 #8
0
from __future__ import print_function
import sys
from os.path import dirname, realpath

from direct.stdpy.file import join, isfile
from rpcore.rpobject import RPObject

# Store a global flag, indicating whether the C++ modules were loaded or the python
# implemetation of them
NATIVE_CXX_LOADED = False

# Read the configuration from the flag-file
current_path = dirname(realpath(__file__))
cxx_flag_path = join(current_path, "use_cxx.flag")
if not isfile(cxx_flag_path):
    RPObject.global_error("CORE", "Could not find cxx flag, please run the setup.py!")
    sys.exit(1)
else:
    with open(join(current_path, "use_cxx.flag"), "r") as handle:
        NATIVE_CXX_LOADED = handle.read().strip() == "1"

# The native module should only be imported once, and that by the internal pipeline code
assert __package__ == "rpcore.native", "You have included the pipeline in the wrong way!"

# Classes which should get imported
classes_to_import = [
    "GPUCommand",
    "GPUCommandList",
    "ShadowManager",
    "InternalLightManager",
    "PSSMCameraRig",