コード例 #1
0
ファイル: Main.py プロジェクト: dasbavaria/echomesh
def main():
  import sys

  times = []

  def p(msg=''):
    """Print progress messages while echomesh loads."""
    print(msg, end='\n' if msg else '')
    global COUNT
    dot = str(COUNT % 10) if USE_DIGITS_FOR_PROGRESS_BAR else '.'
    print(dot, end='')
    COUNT += 1

    sys.stdout.flush()

    import time
    times.append(time.time())

  p('Loading echomesh ')

  from echomesh.base import Path
  p()

  Path.fix_sys_path()
  p()

  from echomesh.base import Args
  p()

  Args.set_arguments(sys.argv)
  p()

  from echomesh.base import Config
  p()

  Config.recalculate()
  p()

  if Config.get('autostart') and not Config.get('permission', 'autostart'):
    print()
    from echomesh.util import Log
    Log.logger(__name__).info("Not autostarting because autostart=False")
    exit(0)
  p()

  from echomesh import Instance
  print()

  if Config.get('diagnostics', 'startup_times'):
    print()
    for i in range(len(times) - 1):
      print(i, ':', int(1000 * (times[i + 1] - times[i])))
    print()

  Instance.main()

  if Config.get('diagnostics', 'unused_configs'):
    import yaml
    print(yaml.safe_dump(Config.get_unvisited()))
コード例 #2
0
    def _args_to_settings(self, args, error):
        args = ' '.join(args)
        settings = {}
        base_settings = self.file_settings[0][1][0]
        assert isinstance(base_settings, dict)
        try:
            split_args = Args.split(args)
        except Exception as e:
            e.arg = '%s %s' % (error, args)
            raise

        for addr, value in split_args:
            try:
                GetPrefix.set_assignment(
                    addr,
                    value,
                    base_settings,
                    settings,
                    unmapped_keys=Merge.SETTINGS_EXCEPTIONS)
            except GetPrefix.PrefixException:
                raise Exception('Can\'t understand settings address "%s"' %
                                addr)
            except Exception:
                raise Exception(
                    'Can\'t understand settings value "%s" in %s=%s' %
                    (value, addr, value))
        return settings
コード例 #3
0
ファイル: MergeConfig.py プロジェクト: florian-f/echomesh
  def _assignment_to_config(self, args, error):
    args = ' '.join(args)
    config = {}
    base_config = self.file_configs[0][1][0]
    assert isinstance(base_config, dict)
    try:
      split_args = Args.split(args)
    except Exception as e:
      e.arg = '%s %s' % (error, args)
      raise

    for addr, value in split_args:
      try:
        GetPrefix.set_assignment(addr, value, base_config, config,
                                 unmapped_names=Merge.CONFIG_EXCEPTIONS)
      except GetPrefix.PrefixException:
        raise Exception('Can\'t understand configuration address "%s"' % addr)
      except Exception:
        raise Exception('Can\'t understand configuration value "%s" in %s=%s' %
                        (value, addr, value))
    return config
コード例 #4
0
ファイル: MergeSettings.py プロジェクト: TopRamenGod/echomesh
    def _args_to_settings(self, args, error):
        args = ' '.join(args)
        settings = {}
        base_settings = self.file_settings[0][1][0]
        assert isinstance(base_settings, dict)
        try:
            split_args = Args.split(args)
        except Exception as e:
            e.arg = '%s %s' % (error, args)
            raise

        for addr, value in split_args:
            try:
                GetPrefix.set_assignment(
                    addr, value, base_settings, settings,
                    unmapped_keys=Merge.SETTINGS_EXCEPTIONS)
            except GetPrefix.PrefixException:
                raise Exception('Can\'t understand settings address "%s"' %
                                addr)
            except Exception:
                raise Exception(
                    'Can\'t understand settings value "%s" in %s=%s' %
                    (value, addr, value))
        return settings
コード例 #5
0
ファイル: Args_test.py プロジェクト: florian-f/echomesh
 def assertTest(self, args, expected):
   try:
     result = Args.split(args)
   except Exception as e:
     result = 'ERROR: %s' % str(e)
   self.assertEqual(result, expected)
コード例 #6
0
ファイル: Config.py プロジェクト: dasbavaria/echomesh
def assign(*values):
  assignments = Args.split_args(values)
  merged = MergeConfig.merge_assignments(CONFIG, assignments)
  if merged:
    update_clients()
  return merged
コード例 #7
0
ファイル: Args_test.py プロジェクト: sagistrauss/echomesh
 def assertTest(self, args, expected):
     try:
         result = Args.split(args)
     except Exception as e:
         result = 'ERROR: %s' % str(e)
     self.assertEqual(result, expected)