Ejemplo n.º 1
0
    def __init__(self, name=None, **kwds):
        # chain up
        super().__init__(name=name, **kwds)

        # set up my nickname
        nickname = self.pyre_namespace or name

        # if i have one
        if nickname:
            # register it with the journal
            journal.application(name=nickname)

            # build my channels
            self.debug = journal.debug(nickname)
            self.firewall = journal.firewall(nickname)
            self.info = journal.info(nickname).activate()
            self.warning = journal.warning(nickname).activate()
            self.error = journal.error(nickname).activate()
            # if i am in debugging mode
            if self.DEBUG:
                # activate the debug channel
                self.debug.active = True

        # sniff around for my environment
        self.pyre_home, self.pyre_prefix, self.pyre_defaults = self.pyre_explore(
        )
        # instantiate my layout
        self.layout = self.pyre_loadLayout()
        # mount my folders
        self.pfs = self.pyre_mountPrivateFilespace()
        # go through my requirements and build my dependency map
        # self.dependencies = self.pyre_resolveDependencies()

        # all done
        return
Ejemplo n.º 2
0
def test():
    # support
    import journal
    import pyre

    # make a group
    class Group(pyre.h5.group):
        """
        A group of datasets in some HDF5 file
        """
        # something simple
        id = pyre.h5.int()
        id.doc = "a simple dataset"

        # something a bit more complicated
        pols = pyre.h5.list()
        pols.doc = "a dataset that's a container"

    # verify that my table of identifiers is accessible
    identifiers = Group.pyre_identifiers
    # and of the correct size
    assert len(identifiers) == 2
    # check the contents
    assert identifiers["id"].typename == "int"
    assert identifiers["pols"].typename == "list"

    # configure the journal
    journal.application("pyre.h5.group")
    # make a channel
    channel = journal.debug("pyre.h5.group")

    # sign on
    channel.line(f"group: {Group.__name__}")

    # identifier section
    channel.line(f"  identifiers:")
    # go through the contents of the identifier map
    for name, identifier in Group.pyre_identifiers.items():
        # represent
        channel.line(f"    {name}: {identifier}")
        # the doc string
        channel.line(f"      doc: {identifier.doc}")
        # show me the default value
        channel.line(f"      default: {identifier.default}")

    # flush
    channel.log()

    # all done
    return
Ejemplo n.º 3
0
def test():
    """
    Set the application name
    """
    # get the library
    import journal

    # make up a name
    name = "app"
    # register it
    journal.application(name)

    # get the chronicler's notes
    notes = journal.chronicler.notes
    # verify that the key is registered and has the correct value
    assert notes["application"] == name

    # all done
    return
Ejemplo n.º 4
0
    def __init__(self, name=None, **kwds):
        # chain up
        super().__init__(name=name, **kwds)

        # get the executive
        executive = self.pyre_executive
        # set up my nickname
        nickname = self.pyre_namespace or name

        # get the dashboard
        dashboard = executive.dashboard
        # check whether there is already an app registered with the dashboard
        if dashboard.pyre_application is not None:
            # make a channel
            channel = journal.warning(f"{nickname}")
            # complain
            channel.line(f"while registering {self}:")
            channel.line(
                f"another app, {dashboard.pyre_application}, is already registered"
            )
            channel.log()
        # in any case, attach me to the dashboard
        dashboard.pyre_application = self

        # if i have one
        if nickname:
            # register it with the journal
            journal.application(name=nickname)

            # build my channels
            self.debug = journal.debug(nickname)
            self.firewall = journal.firewall(nickname)
            self.info = journal.info(nickname).activate()
            self.warning = journal.warning(nickname).activate()
            self.error = journal.error(nickname).activate()
            # if i am in debugging mode
            if self.DEBUG:
                # activate the debug channel
                self.debug.active = True

        # sniff around for my environment
        self.pyre_home, self.pyre_prefix, self.pyre_config = self.pyre_explore(
        )
        # instantiate my layout
        self.layout = self.pyre_loadLayout()
        # mount my folders
        self.pfs = self.pyre_mountPrivateFilespace()

        # if i have a name
        if name is not None:
            # build a locator
            loc = pyre.tracking.simple(
                f"while initializing application '{nickname}'")
            # load my configuration files
            self.pyre_loadConfiguration(locator=loc)

        # go through my requirements and build my dependency map
        # self.dependencies = self.pyre_resolveDependencies()

        # all done
        return