Exemplo n.º 1
0
def main():
  log_filename = "keyrotator" + time.strftime("-%Y-%m-%d-%H%M") + ".log"
  logging.basicConfig(filename=log_filename, level=logging.INFO)
  logging.getLogger("").addHandler(logging.StreamHandler())
  logging.info("Logging established in %s.", log_filename)

  dispatch(__doc__, version=__version__)
Exemplo n.º 2
0
    commands.py hello  [--name=<TXT>] [-q | -d]
    commands.py -h
    commands.py -v

Options:
    -h, --help       display this message and exit
    -v, --version    display version
    -n, --name=TXT   greeting name [default: You]
    -q, --quiet      set log level to WARNING [default: INFO]
    -d, --debug      set log level to DEBUG [default: INFO]
"""
import logging

from docopt import docopt
from docopt_dispatch import dispatch

from utils import set_logging_config
from settings import VERSION


@dispatch.on('hello')
def do_hello(name=None, **kwargs):
    print("Hello, {}!". format(name))


if __name__ == '__main__':
    kwargs = docopt(__doc__)
    set_logging_config(kwargs)
    logging.debug(kwargs)
    dispatch(__doc__, version=VERSION)
Exemplo n.º 3
0
    for x in new_list:
        associate(x, microservice)


@dispatch.on('--master-association')
def master_asso(**kwargs):
    client = Guacamole(addr, login, passwd)
    conns = connections()
    usrs = users()
    for x in conns:
        if x != "ROOT":
            for u in usrs:
                associate(u, x)


def find(key, dictionary):
    for k, v in dictionary.items():
        if k == key:
            yield v
        elif isinstance(v, dict):
            for result in find(key, v):
                yield result
        elif isinstance(v, list):
            for d in v:
                for result in find(key, d):
                    yield result


if __name__ == '__main__':
    dispatch(__doc__, version='Avocado 0.2.0')
Exemplo n.º 4
0
    Create a new file (allow for naming it later)

textbase version
    Report the version of textbase

textbase browse
    Browse the available files

textbase find
    Search through available files for particular keywords
"""
from docopt_dispatch import dispatch
import os
import pdb
import textbase as tb


@dispatch.on('version')
def tb_version(**kw):
    """
    Report the version of textbase
    """
    if kw['d']:
        pdb.set_trace()
    print("textbase {} (TEXTBASE_ROOT='{}')"
          .format(tb.version(), os.getenv("TEXTBASE_ROOT")))


if __name__ == "__main__":
    dispatch(__doc__)
Exemplo n.º 5
0
# -----------------------------------------------------------------------------
def hhmm(secs):
    """
    Format a number of seconds in hours and minutes
    """
    hr = int(secs // 3600)
    mn = int((secs % 3600) / 60)
    return "{:02d}:{:02d}".format(hr, mn)


# -----------------------------------------------------------------------------
def dhhmmss(secs):
    """
    Format a number of seconds in hours and minutes
    """
    r = secs
    v = []
    for div in [24 * 3600, 3600, 60]:
        v.append(r // div)
        r = r % div
    v.append(r)
    return "{}d{:02d}:{:02d}:{:02d}".format(*tuple(v))


# -----------------------------------------------------------------------------
if __name__ == "__main__":
    dispatch(__doc__)  # pragma: no cover
"""
==TAGGABLE==
"""
Exemplo n.º 6
0
def main(args=None):                                    # pragma: no coverage
    """
    Command line entry point
    """
    dispatch(__doc__)
Exemplo n.º 7
0
def main():
    """
    Command line entry point
    """
    dispatch(__doc__)
Exemplo n.º 8
0
def main(args=None):
    """
    Let's get it started in here!
    """
    dispatch(__doc__)
Exemplo n.º 9
0
def main():
    """
    Main entry point
    """
    dispatch(__doc__)
Exemplo n.º 10
0
Arquivo: ccp.py Projeto: bongtrop/ccp
def main():
    dispatch(__doc__)
Exemplo n.º 11
0
def main(args=None):
    """
    Where the action starts
    """
    dispatch(__doc__)