Beispiel #1
0
from oslash import Just
from coref.mod import nsValues, nsList
import time


def _timeStamp(ns):
    return time.time()


_lib = nsValues({'/bin/time': _timeStamp})
Beispiel #2
0
from oslash import Just
from coref.mod import nsValues, nsList
from coref.gevent import nsLoopSys, nsLoopUser

_lib = nsValues({
    '/bin/loop': nsLoopUser,
    '/sbin/loop': nsLoopSys,
})
Beispiel #3
0
from coref.mod import nsValues, nsList

_set = nsValues(
    {
        '/etc/library': [],
        '/config/user.library': [],
        '/etc/answer': 42,
        '/config/var.redefine': True,
        '/etc/daemonize': False,
        '/etc/flags/truename': False,
        '/sys/hylang.enabled': False,
        '/config/cfg.files': [],
        '/etc/author': 'Unknown',
        '/etc/author.email': '*****@*****.**',
    }
)

_mkdir = [
    '/bin',
    '/sbin',
    '/home',
    '/tmp',
    '/etc',
    '/config',
    '/sys',
    '/usr',
    '/usr/local',
    '/usr/local/bin',
    '/proc',
    '/dev',
    '/templates',
Beispiel #4
0
from oslash import Just
from coref.mod import nsValues, nsList
from coref.internal.monad.Namespace import C, f, F, V

_lib = nsValues({
    '/bin/F': F,
    '/bin/f': f,
    '/bin/C': C,
    '/bin/V': V,
})
Beispiel #5
0
                ["/sys/env/pidFile", nsGet(ns, "/sys/env/pidFile").value, "PID file"],
                ["/config/user.library", nsGet(ns, "/config/user.library").value, "Application library"],
                ["/etc/daemonize", nsGet(ns, "/etc/daemonize").value, "Become daemon ?"],
                ["/etc/flags/internalServer",nsGet(ns, "/etc/flags/internalServer", False).value,"Enable internal server"],
                ["/etc/version", str(nsGet(ns, "/etc/version").value), "Application version"],
                ["/etc/release", nsGet(ns, "/etc/release").value, "Application release"],
                ["/etc/author", nsGet(ns, "/etc/author").value, "Author of application"],
                ["/etc/author.email", nsGet(ns, "/etc/author.email").value, "Author's email"],
                ["/etc/coref/version", str(nsGet(ns, "/etc/coref/version").value), "core.F version"],
                ["/etc/coref/release", nsGet(ns, "/etc/coref/release").value, "core.F release"],
                ["/config/RPCCatchCalls", nsGet(ns, "/config/RPCCatchCalls").value, "Trace RPC"],
                ["/etc/answer", nsGet(ns, "/etc/answer").value, "THE ANSWER"],
            ]
    )
    print(tbl.draw())
    return True

_set = nsValues(
    {
        '/help/cmd/banner': """
This command displays the system banner and configuration.
"""
    }
)

_lib = nsValues(
    {
        '/usr/local/bin/banner': nsBanner
    }
)
Beispiel #6
0
    pid = nsDaemonLoadPid(ns)
    if pid is not None:
        me = psutil.Process(pid)
        me.terminate()
    nsDaemonRemovePid(ns)


_set = nsValues({
    '/help/cmd/loop':
    """
This command executes a user-only threads eventloop.
""",
    '/help/cmd/daemon':
    """
This command executes a user&system threads eventloop.
""",
    '/help/cmd/start':
    """
This command executes a user&system threads eventloop.
""",
    '/help/cmd/stop':
    """
This command stops the daemon if one is running.
"""
})

_lib = nsValues({
    '/usr/local/bin/loop': nsLoop,
    '/usr/local/bin/daemon': nsDaemon,
    '/usr/local/bin/start': nsDaemon,
    '/usr/local/bin/stop': nsDaemonStop,
    '/bin/setproctitle': nsDaemonProcTitle,
Beispiel #7
0
from coref.mod import nsValues, nsList
from coref.version import *

_set = nsValues({
    '/etc/coref/version': VERSION,
    '/etc/coref/release': RELEASE,
    '/etc/coref/url': URL,
    '/etc/coref/author': AUTHOR,
    '/etc/coref/email': AUTHOR_EMAIL,
    '/etc/coref/license': LICENSE,
    '/etc/coref/license.txt': LICENSE_txt,
    '/etc/coref/README.md': READ_me,
    '/etc/version': '0.0',
    '/etc/release': '0.0.1',
})

_mkdir = [
    '/etc/coref',
]
Beispiel #8
0
from oslash import Just
from coref.mod import nsValues, nsList
from coref.help import nsHelp


def nsDisplayLicense(ns):
    nsHelp(ns, "/etc/coref/license.txt")
    return True


_set = nsValues({
    '/help/cmd/license':
    """
This command displays the license under which core.F is distributed.
"""
})

_lib = nsValues({'/usr/local/bin/license': nsDisplayLicense})
Beispiel #9
0
from oslash import Just
from coref.mod import nsValues, nsList
from coref.help import nsHelp


def nsStatus(ns):

    return True


_set = nsValues({
    '/help/cmd/status':
    """
Displaying status of running daemon process .
"""
})

_lib = nsValues({'/usr/local/bin/status': nsStatus})
Beispiel #10
0
from coref.arrghs import nsArgs
from coref.mod import nsValues, nsList

_set = nsValues({
    '/etc/args/default/conf': [],
    '/etc/args/default/bootstrap': [],
    '/etc/args/default/userlib': [],
    '/etc/args/default/conf': [],
    '/etc/args/default/listen': [],
    '/etc/args/default/rpc': [],
    '/etc/args/default/group': [],
    '/etc/argv': [],
    '/etc/rpc': {},
    '/etc/groups': [],
    '/etc/flags/console': True,
    '/etc/flags/log': False,
    '/etc/flags/stdout': True,
    '/etc/flags/daemonize': False,
    '/etc/flags/color': True,
    '/etc/flags/pid': False,
    '/etc/flags/direct': True,
    '/etc/flags/cookie': False,
})

_mkdir = [
    '/etc/args',
    '/etc/args/default',
    '/etc/flags',
    '/help',
    '/help/cmd',
]
Beispiel #11
0
from oslash import Just
from coref.mod import nsValues, nsList
from coref.init import nsInitRegister
from coref.app import nsAppStart, nsInitAppRegister

_lib = nsValues({
    '/bin/initRegister': nsInitRegister,
    '/bin/main': nsAppStart,
    '/bin/initAppRegister': nsInitAppRegister,
})
Beispiel #12
0
        ns.V('/sys/traceback/exists', True)


def nsClearException(ns):
    ns.V('/sys/traceback/exists', False)


_lib = {
    '/bin/registerException': nsRegisterException,
    '/bin/clearException': nsClearException
}

_set = nsValues({
    '/sys/traceback/exists':
    False,
    '/sys/traceback/tb':
    RingBuffer(capacity=_TB_CAP, dtype=_EXCEPTION),
    '/sys/traceback/ftrace':
    RingBuffer(capacity=_F_TRACE_CAP, dtype=_F_TRACE),
    '/etc/traceCapacity':
    _F_TRACE_CAP,
    '/etc/tracebackCapacity':
    _TB_CAP,
    '/config/exception':
    _EXCEPTION,
    '/config/ftrace':
    _F_TRACE,
})

_mkdir = ['/sys/traceback']
Beispiel #13
0
import os
from coref.mod import nsValues, nsList


def nsEnvVars():
    _res = {}
    for e in os.environ:
        _res[f"/sys/env/variables/{e}"] = os.environ[e]
    return _res


_set = nsValues(nsEnvVars())
Beispiel #14
0
_set = nsValues({
    '/sys/env/id':
    str(uuid.uuid4()),
    '/sys/env/platform/architecture':
    platform.architecture()[0],
    '/sys/env/platform/machine':
    platform.machine(),
    '/sys/env/platform/node':
    platform.node(),
    '/sys/env/platform/platform':
    platform.platform(),
    '/sys/env/platform/python':
    platform.python_version().split('.'),
    '/sys/env/platform/system':
    platform.system(),
    '/sys/env/platform/uname':
    platform.uname(),
    '/sys/env/uid':
    os.getuid(),
    '/sys/env/user':
    getpass.getuser(),
    '/sys/env/home':
    str(Path.home()),
    '/sys/env/cwd':
    os.getcwd(),
    '/sys/env/home.disk.size':
    home_total,
    '/sys/env/home.disk.used':
    home_used,
    '/sys/env/home.disk.free':
    home_free,
    '/sys/env/home.disk.free.percent': (home_free / home_total) * 100,
    '/sys/env/bootTimestamp':
    time.time(),
    '/sys/env/pid':
    os.getpid(),
})
Beispiel #15
0
from oslash import Just
from coref.mod import nsValues, nsList
from coref.help import nsHelp


def nsDisplayReadme(ns):
    nsHelp(ns, "/etc/coref/README.md")
    return True


_set = nsValues({
    '/help/cmd/about':
    """
This command displays general documentation about core.F .
"""
})

_lib = nsValues({'/usr/local/bin/about': nsDisplayReadme})
Beispiel #16
0
from coref.mod import nsValues, nsList
from coref.tcpserver import nsTcpCreate

_set = nsValues({
    '/etc/tcpBufSize': 512,
})

_lib = {'/bin/tcpServer': nsTcpCreate}

_mkdir = [
    '/dev/tcp',
    '/dev/tcp/server',
]
Beispiel #17
0
def _systemFSInit(ns):
    for c in nsGet(ns, "/config/cfg.path").value:
        nsCfgAppendFs(ns, c)
    return True


_lib = {
    '/bin/C': nsCfgLoad,
    '/bin/Cfg': nsCfgFSLoad,
    '/bin/FSCfg': nsCfgAppendFs,
    '/bin/yaml': nsCfgYamlLoad,
}

_set = nsValues({
    "/config/cfg.path": ['osfs://.', 'osfs://tests'],
    "/config/cfg.fs": {},
    "/config/cfg.files": [],
    "/config/cmd.path": "/usr/local/bin"
})

_init = {
    2: {
        'bund': {
            'start': _systemCfgInit,
        }
    },
    900: {
        'bund': {
            'start': _systemFSInit
        }
    }
}
Beispiel #18
0
_set = nsValues({
    '/help/cmd/default':
    """
# THE HELP
This is a default HELP page for the core.F application command-line.

## BASICS OF core.F CLI interface

core.F CLI interface consists of two parts: Setting the global flags and
calling for the pre-configured *commands*. You do have a help, available to you
within context when you will specify __--help__ after the command.

### Setting of the global flags

You can set global flag by __+flagname__ to set a global flag to a __True__
or __-flagname__ to set it to the __False__

| __+/-daemonize__ | Daemonize process or keep it running in foreground |
| __+/-color__     | Turn the terminal colors on or off                 |
| __+/-console__   | Turn on or off output to the application console   |
| __+/-log__       | Enable or disable writing the log file             |

### Calling preconfigured commands

Each pre-configured command is defined by the function(s) located in the
directory, which is pre-set in */config/cmd.path* variable in your namespace. The default
is */usr/local/bin* Pre-configured commands are called in order that yo specify them
in command line. In this example:

```
command A B C
```

command __A__ will be called before command __B__ and command __B__ will be called before
command __C__. General cormat of the commands are:

*command* (zero or more command options), where the command option is defiend as
__--commandoption__ *option value*.


Keep exploring ! __73__ !
Rendered at: $time.asctime($time.localtime($time.time()))
        """,
})