Example #1
0
import os
from datetime import datetime
from cement import Controller, ex
from cement.utils import fs
from cement.utils.version import get_version_banner
from ..core.version import get_version
from ..core import exc

VERSION_BANNER = """
Lazily Backup Files and Directories %s
%s
""" % (get_version(), get_version_banner())


class Base(Controller):
    class Meta:
        label = 'base'

        # text displayed at the top of --help output
        description = 'Lazily Backup Files and Directories'

        # text displayed at the bottom of --help output
        epilog = 'Usage: dotbak /path/to/file'

        # controller level arguments. ex: 'dotbak --version'
        arguments = [
            ### add a version banner
            (['-v', '--version'], {
                'action': 'version',
                'version': VERSION_BANNER
            }),
Example #2
0
from cement.utils.version import get_version_banner
from datetime import datetime
from pathlib import Path
from urllib.parse import urlparse

from xrdsst.core.definitions import ROOT_DIR
from xrdsst.core.conf_keys import validate_conf_keys, ConfKeysSecurityServer, ConfKeysRoot
from xrdsst.core.excplanation import Excplanatory
from xrdsst.core.util import op_node_to_ctr_cmd_text, get_admin_credentials, get_ssh_key, get_ssh_user
from xrdsst.core.version import get_version
from xrdsst.resources.texts import texts
from xrdsst.configuration.configuration import Configuration
from xrdsst.rest.rest import ApiException

BANNER = texts['app.description'] + ' ' + get_version(
) + '\n' + get_version_banner()


class BaseControllerException(Exception):
    """Exception raised for errors related to UserController.

    Attributes:
        message -- explanation of the error
    """
    def __init__(self, message):
        self.message = message
        super().__init__(self.message)


class BaseController(Controller):
    _TRANSIENT_API_KEY_ROLES = [
Example #3
0
File: base.py Project: undp/yager
from cement import Controller, ex
from cement.utils.version import get_version_banner

from jinja2 import Environment, FileSystemLoader

from tabulate import tabulate

from ..core.version import get_version

VERSION_BANNER = """
Yager %s
%s
""" % (
    get_version(),
    get_version_banner(),
)


class Base(Controller):
    """ Class implementing base app controller."""
    class Meta:
        """Controller meta-data."""

        label = "base"

        description = "Yet Another GEneric Reporter tool for parsing of XML data into an SQLite database and subsequent universal reporting based on SQL queries and Jinja2 templates."  # noqa: E501
        epilog = "Usage: yager {sub-command} {options}"

        arguments = [
            (["-v", "--version"], {
Example #4
0
from cement import Controller, ex
from cement.utils.version import get_version_banner
from ..core.version import get_version

VERSION_BANNER = """
A Simple TODO Application %s
%s
""" % (get_version(), get_version_banner())


class Base(Controller):
    class Meta:
        label = 'base'

        # text displayed at the top of --help output
        description = 'A Simple TODO Application'

        # text displayed at the bottom of --help output
        epilog = 'Usage: todo command1 --foo bar'

        # controller level arguments. ex: 'todo --version'
        arguments = [
            ### add a version banner
            ( [ '-v', '--version' ],
              { 'action'  : 'version',
                'version' : VERSION_BANNER } ),
        ]


    def _default(self):
Example #5
0
from cement import Controller
from cement.utils.version import get_version_banner

BANNER = get_version_banner()


class Base(Controller):
    class Meta:
        label = 'base'
        description = 'Cement Framework Developer Tools'
        epilog = 'Example: cement generate project /path/to/myapp'

        arguments = [
            (['-v', '--version'], {
                'action': 'version',
                'version': BANNER
            }),
        ]

    def _default(self):
        self.app.args.print_help()
Example #6
0
    def __init__(self):
        """
        A class to define the default configuration for cement apps

        Attributes
        ----------
        system : str
            the name of the OS that's running the app
        bng_name : str
            OS appropriate name of the BNG folder
        bng_path : str
            full absolute path to the BNG folder
        lib_path : str
            path to CLI library
        stdout : str
            the name of the subprocess attribute to pass stdout to
        stderr : str
            the name of the subprocess attribute to pass stderr to
        config : dict
            dictionary containing the application defaults
        banner : str
            app banner that gets printed when ran with -v
        """
        # determine what bng we are using
        system = platform.system()
        if system == "Linux":
            bng_name = "bng-linux"
        elif system == "Windows":
            bng_name = "bng-win"
        elif system == "Darwin":
            bng_name = "bng-mac"
        # set attributes
        self.system = system
        self.bng_name = bng_name
        # configuration defaults
        CONFIG = init_defaults("bionetgen")
        lib_path = os.path.dirname(__file__)
        lib_path = os.path.split(lib_path)[0]
        CONFIG["bionetgen"]["bngpath"] = os.path.join(lib_path, bng_name)
        # notebook
        CONFIG["bionetgen"]["notebook"] = {}
        CONFIG["bionetgen"]["notebook"]["path"] = os.path.join(
            lib_path, "assets", "bionetgen.ipynb")
        CONFIG["bionetgen"]["notebook"]["template"] = os.path.join(
            lib_path, "assets", "bionetgen-temp.ipynb")
        CONFIG["bionetgen"]["notebook"]["name"] = "bng-notebook.ipynb"
        # cvode paths
        CONFIG["bionetgen"]["cvode_lib"] = None
        CONFIG["bionetgen"]["cvode_include"] = None
        # set attributes
        self.bng_path = os.path.join(lib_path, bng_name)
        self.lib_path = lib_path
        # version banner
        VERSION_BANNER = """BioNetGen simple command line interface {}\nBioNetGen version: {}\n{}
        """.format(get_version(), get_latest_bng_version(),
                   get_version_banner())
        # set attributes
        self.banner = VERSION_BANNER
        # stdout
        CONFIG["bionetgen"]["stdout"] = "PIPE"
        CONFIG["bionetgen"]["stderr"] = "STDOUT"
        self.stdout = subprocess.PIPE
        self.stderr = subprocess.PIPE
        self.config = CONFIG