Example #1
0
def init():
  if Settings.get('helper_tasks', True):
    import helper_tasks
    helper_tasks.main()


  def worker(line):
    try:
      result = execCommand(split(line), True)
      print '' if result is None else '%s\n' % str(result)

    except HandledException as e:
      err('%s\n' % e)

  if stdin.isatty(): # Enter interactive shell

    prompt = Settings.get('prompt', '>')

    while True:
      try:
        line = raw_input(prompt)

        if line:
          worker(line)

      except EOFError: # ^z (null character) was passed.
        exit()

  else:

    for line in stdin.readlines():
      worker(line.strip('\r\n ')) # #Pending: As of now, stdin should provide whole commands. Commands and argoments couldn't be separated into multiple lines (like with the interactive mode). Fix this,
Example #2
0
File: core.py Project: Laufire/ec
def start():
  r"""Starts ec.
  """
  processPendingModules()

  if not state.main_module_name in ModuleMembers: # don't start the core when main is not Ec-ed
    return

  MainModule = sys.modules[state.main_module_name]

  if not MainModule.__ec_member__.Members: # there was some error while loading script(s)
    return

  global BaseGroup
  BaseGroup = MainModule.__ec_member__

  Argv = sys.argv[1:]
  global mode
  mode = 'd' if Argv else 's' # dispatch / shell mode

  global is_silent
  is_silent = Settings.get('silent', False)
  
  global should_debug
  should_debug = Settings.get('debug', False)

  if mode == 's':
    import shell
    shell.init()

  else:
    import dispatch
    dispatch.init(Argv)

  processExitHooks()
Example #3
0
def start():
    r"""Starts ec.
  """
    processPendingModules()

    if not state.main_module_name in ModuleMembers:  # don't start the core when main is not Ec-ed
        return

    MainModule = sys.modules[state.main_module_name]

    if not MainModule.__ec_member__.Members:  # there was some error while loading script(s)
        return

    global BaseGroup
    BaseGroup = MainModule.__ec_member__

    Argv = sys.argv[1:]
    global mode
    mode = 'd' if Argv else 's'  # dispatch / shell mode

    global is_dev_mode
    is_dev_mode = Settings.get('dev_mode', False)

    if mode == 's':
        import shell
        shell.init()

    else:
        import dispatch
        dispatch.init(Argv)

    processExitHooks()
Example #4
0
def main():
  ThisModule = sys.modules[__name__]
  core.processModule(__name__)

  __ec_member__ = ThisModule.__ec_member__

  helper_route = Settings.get('helper_route')

  if helper_route:
    __ec_member__.Config['name'] = helper_route
    core.BaseGroup.Members[helper_route] = __ec_member__

  else:
    core.BaseGroup.Members.update(__ec_member__.Members.iteritems())
Example #5
0
def init():
  if Settings.get('helper_tasks', True):
    import helper_tasks
    helper_tasks.main()

  while True:
    try:
      line = raw_input('>')

      if line:
        result = execCommand(split(line), True)
        print '' if result is None else '%s\n' % str(result)

    except HandledException as e:
      err('%s\n' % e)

    except EOFError: # ^z (null character) was passed
      exit()