Example #1
0
def inject(sharedBase=None, **Settings):

  import sys
  from json import dumps
  from urllib import quote

  from ec import interface
  from ec.ec import settings

  import delegator # #Note: An ec module is used, instead of making the call directly, so to utilize ec's features like debugging etc.

  if sharedBase:
    delegator.setSharedBase(sharedBase)

  if Settings:
    settings(**Settings)

  Args = sys.argv[1:]

  interface.setBase(delegator)
  interface.call('makeCall %s %s' % (Args[0], quote(dumps(Args[1:]))), silent=False)
Example #2
0
  @task
  def wrapper():
    """Calls nut_shell.simple with some arguments, the args that aren't provided will be collected.
    """
    call(simple, arg1=1, arg2=2)

  @task
  def get():
    """Get user input through utils.get.
    """
    print get(desc='Email id', type=regex.email)

  def log(message):
    """A helper method.
    """
    print message

  name = 'intro' # Groups could even have variables.

# importing other modules
import simple
member(simple) # member() is used to expose imported members as the children of the current module

@exit_hook
def clean_up(): # exit hooks are called when ec exits. There may be more than one hook.
  print ':)'

module(desc='A module to test decorator based configuration.') # module is an optional call, used to configure the group that wraps current module.

settings(dev_mode=True) # settings for ec
Example #3
0
  @task
  def get():
    r"""Get user input through utils.get.
    """
    print get(desc='Email id', type=regex.email)

  def log(message):
    r"""A helper method.
    """
    print message

  name = 'intro' # Groups could even have variables.

@task
@arg(type=lambda v: (int(v) if int(v) > 10 else throw()), desc='Some int', type_str='a number greater than 10') # a lambda as a custom type
def task2(arg1):
  print arg1

# importing other ec modules
import simple
member(simple) # member() is used to expose imported members as the children of the current module

@exit_hook
def clean_up(): # exit hooks are called when ec exits. There may be more than one hook.
  print ':)'

module(desc='A module to test decorator based configuration.') # module is an optional call, used to configure the group that wraps current module.

settings(silent=False) # settings for ec
Example #4
0
    r"""Installs a development version of the library.
	"""
    call('python setup.py develop', cwd='..')


@task(alias='t')
@arg(type=multi.one_of(TestNames + ['*']), sep='\n\t')
@arg(type=basics.yn)
@arg(type=basics.yn)
def test(testName='*', isVerbose=False, debug=False):
    r"""The task under development.
	"""
    from laufire.shell import run
    cleanUp()

    if debug:
        testFile = (
            '%s/test_%s.py' %
            (Config['Paths']['tests'], testName)) if testName != '*' else ''
        assert run('nosetests -vsx --pdb %s' % testFile,
                   shell=True) == 0, 'Testing failed.'

    else:
        assert run(
            'python -m unittest discover -s "%s" -p test_%s.py -fc%s' %
            (Config['Paths']['tests'], testName, 'v' if isVerbose else ''),
            shell=True) == 0, 'Testing failed.'


settings(debug=Config['debug'])