Beispiel #1
0
def main(args, parser, subparser):

    from scif.main import ScifRecipe

    client = ScifRecipe(writable=False, quiet=True)
    longlist = args.longlist

    result = []
    for app in client.apps():
        config = client.get_appenv(app)

        # Long listing includes a number with path to app
        if longlist is True:
            result.append([app.rjust(10), config["SCIF_APPROOT"]])
        else:
            result.append(app.rjust(10))

    if len(result) > 0:

        if longlist is True:
            header = "[app]              [root]"
            bot.custom(prefix="SCIF", message=header, color="CYAN")
            bot.table(result)
        else:
            print("\n".join(result))
Beispiel #2
0
def main(args, parser, subparser):

    from scif.main import ScifRecipe

    # Inspect choices, r, e, l, a
    choices = [
        "r",
        "e",
        "l",
        "a",
        "f",
        "i",
        "h",
        "dump",
        "labels",
        "all",
        "files",
        "help",
        "install",
        "environment",
        "definition",
        "runscript",
    ]

    attributes = [x for x in args.attributes if x in choices]

    write_recipe = False
    if "dump" in attributes:
        write_recipe = True
        attributes.pop(attributes.index("dump"))

    apps = [x for x in args.attributes if x not in attributes]

    # First instantiate the client
    client = ScifRecipe(quiet=True, writable=False)

    # Filter down to apps that we want
    if len(apps) == 0:
        apps = client.apps()

    if len(attributes) == 0:
        attributes = ["a"]

    result = {}
    for app in apps:

        inspection = client.inspect(app, attributes)
        if len(inspection) > 0:
            result[app] = inspection

    if write_recipe is True:
        for app, atts in result.items():
            for key, val in atts.items():
                print("%" + key)
                print("\n".join(val) + "\n")
    else:
        print(json.dumps(result, indent=4, separators=(",", ": ")))
Beispiel #3
0
def main(args, parser, subparser):

    from scif.main import ScifRecipe
    app = args.app
    client = ScifRecipe(quiet=True, writable=args.writable)

    # Only allow interactive shell if the base exists
    if os.path.exists(SCIF_BASE):
        client.shell(app, cmd=[SCIF_SHELL])
Beispiel #4
0
def main(args, parser, subparser):

    from scif.main import ScifRecipe
    apps = args.app
    client = ScifRecipe(quiet=True, writable=False)

    if len(apps) == 0:
        bot.info("Usage: scif help <hello-world>")
    for app in apps:
        client.help(app)
Beispiel #5
0
def main(args,parser,subparser):

    from scif.main import ScifRecipe
    cmd = args.cmd

    if len(cmd) < 2:
        bot.warning('You must supply an appname and command to execute.')
        bot.custom(prefix="Example: ", message="scif exec app echo $SCIF_APPNAME")
        sys.exit(1)

    app = cmd.pop(0)
    client = ScifRecipe(quiet=True, writable=args.writable)
    client.execute(app, cmd)
Beispiel #6
0
def main(args, parser, subparser):

    from scif.main import ScifRecipe

    client = ScifRecipe(quiet=True, writable=False)
    apps = client.apps()

    for app in apps:
        inspection = client.inspect(app)
        if len(inspection) > 0:
            for key, val in inspection.items():
                print('%' + key)
                print('\n'.join(val) + '\n')
Beispiel #7
0
def main(args, parser, subparser):

    from scif.main import ScifRecipe
    client = ScifRecipe(writable=False, quiet=True)

    result = []
    for app in client.apps():
        config = client.get_appenv(app)
        result.append([app.rjust(10), config['SCIF_APPROOT']])

    if len(result) > 0:
        header = "[app]              [root]"
        bot.custom(prefix="SCIF", message=header, color="CYAN")
        bot.table(result)
Beispiel #8
0
def main(args, parser, subparser):

    from scif.main import ScifRecipe
    cmd = args.cmd

    if len(cmd) == 0:
        bot.warning('You must supply an appname to run.')
        bot.custom(prefix="Example: ", message="scif run <app>")
        sys.exit(1)

    app = cmd.pop(0)

    # Remaining arguments indicate options/args to pass on
    if len(cmd) == 0:
        cmd = None

    client = ScifRecipe(quiet=True, writable=args.writable)
    client.run(app, args=cmd)
Beispiel #9
0
def main(args, parser, subparser):

    from scif.main import ScifRecipe
    apps = args.recipe

    if len(apps) > 0:
        recipe = apps.pop(0)

        if not os.path.exists(recipe):
            bot.exit("Cannot find recipe file %s" % recipe)

        client = ScifRecipe(recipe, writable=False)

        # Preview the entire recipe, or the apps chosen
        client.preview(apps)

    else:
        bot.info('You must provide a recipe file to preview!')
Beispiel #10
0
def main(args,parser,subparser):

    from scif.main import ScifRecipe

    # Inspect choices, r, e, l, a
    choices = ['r', 'e', 'l', 'a', 'f', 'i', 'h', 'dump',
               'labels', 'all', 'files', "help", "install",
               'environment', 'definition', 'runscript'] 

    attributes = [x for x in args.attributes if x in choices]

    write_recipe = False
    if "dump" in attributes:
        write_recipe = True
        attributes.pop(attributes.index('dump'))

    apps = [x for x in args.attributes if x not in attributes]
    
    # First instantiate the client
    client = ScifRecipe(quiet=True, writable=False)

    # Filter down to apps that we want
    if len(apps) == 0:
        apps = client.apps()

    if len(attributes) == 0:
        attributes = ['a']

    result = {}
    for app in apps:

        inspection = client.inspect(app, attributes)
        if len(inspection) > 0:
            result[app] = inspection 

    if write_recipe is True:
        for app, atts in result.items():
            for key,val in atts.items():
                print('%' + key)
                print('\n'.join(val) + '\n')
    else:
        print(json.dumps(result,
                         indent=4,
                         separators=(',', ': ')))
Beispiel #11
0
def main(args, parser, subparser):

    from scif.main import ScifRecipe
    apps = args.recipe

    if len(apps) == 0:
        bot.exit("You must provide a recipe (.scif) file to install.")

    recipe = apps.pop(0)

    if not os.path.exists(recipe):
        bot.exit("Cannot find recipe file %s" % recipe)

    if len(apps) == 0:
        apps = None

    client = ScifRecipe(path=recipe)  # writable is True

    # Preview the entire recipe, or the apps chosen
    client.install(apps)
Beispiel #12
0
def python(recipe, app=None, quiet=False, writable=True):
    from scif.main import ScifRecipe
    import code
    client = ScifRecipe(recipe, quiet=quiet, writable=writable)
    client.speak()
    if app is not None:
        client.activate(app)
    code.interact(local={"client": client})
Beispiel #13
0
def bpython(recipe, app=None, quiet=False, writable=True):
    from scif.main import ScifRecipe
    import bpython
    client = ScifRecipe(recipe, quiet=quiet, writable=writable)
    client.speak()
    if app is not None:
        client.activate(app)
    bpython.embed(locals_={'client': client})
Beispiel #14
0
def ipython(recipe, app=None, quiet=False, writable=True):
    '''embed the client with loaded recipe into an ipython session
    '''
    from scif.main import ScifRecipe
    from IPython import embed
    client = ScifRecipe(recipe, quiet=quiet, writable=writable)
    client.speak()
    if app is not None:
        client.activate(app)
    embed()
Beispiel #15
0
Datei: run.py Projekt: satra/scif
def main(args, parser, subparser):

    from scif.main import ScifRecipe
    app = args.app
    client = ScifRecipe(quiet=True, writable=args.writable)
    client.run(app)