Example #1
0
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()))
Example #2
0
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 Version
    if Version.TOO_NEW:
        print(Version.ERROR)

    from echomesh.base import Path
    if not Path.project_path():
        return
    p()

    Path.fix_home_directory_environment_variable()
    p()

    Path.fix_sys_path()
    p()

    from echomesh.base import Settings
    p()

    Settings.read_settings(sys.argv[1:])
    p()

    if Settings.get('execution', 'autostart') and not Settings.get(
            'permission', 'autostart'):
        print()
        from echomesh.util import Log
        Log.logger(__name__).info('No permission to autostart')
        return
    p()

    from echomesh.base import Quit
    p()

    Quit.register_atexit(Settings.save)
    p()

    from echomesh.Instance import Instance
    p()

    instance = Instance()
    print()
    p()

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

    instance.main()
Example #3
0
from __future__ import absolute_import, division, print_function, unicode_literals

from echomesh.base import Path

Path.fix_sys_path()

import unittest

class TestCase(unittest.TestCase):
    EPSILON = 0.000001

    def assertNear(self, x, y, msg=None):
        try:
            lx, ly = len(x), len(y)
        except:
            self.assertTrue(abs(x - y) < self.EPSILON,
                            msg or ('%s != %s' % (x, y)))
        else:
            self.assertEquals(lx, ly)
            for xi, yi in zip(x, y):
                self.assertNear(xi, yi, msg)

main = unittest.main
Example #4
0
from __future__ import absolute_import, division, print_function, unicode_literals

from echomesh.base import Path

Path.fix_sys_path(show_error=False, prompt=False)

import unittest


class TestCase(unittest.TestCase):
    EPSILON = 0.000001

    def assertNear(self, x, y, msg=None):
        try:
            lx, ly = len(x), len(y)
        except:
            self.assertTrue(
                abs(x - y) < self.EPSILON, msg or ('%s != %s' % (x, y)))
        else:
            self.assertEquals(lx, ly)
            for xi, yi in zip(x, y):
                self.assertNear(xi, yi, msg)


main = unittest.main
Example #5
0
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 Version
    if Version.TOO_NEW:
        print(Version.ERROR)

    from echomesh.base import Path
    if not Path.project_path():
        return
    p()

    Path.fix_home_directory_environment_variable()
    p()

    Path.fix_sys_path()
    p()

    from echomesh.base import Settings
    p()

    Settings.read_settings(sys.argv[1:])
    p()

    if Settings.get('execution', 'autostart') and not Settings.get(
            'permission', 'autostart'):
        print()
        from echomesh.util import Log
        Log.logger(__name__).info('No permission to autostart')
        return
    p()

    from echomesh.base import Quit
    p()

    Quit.register_atexit(Settings.save)
    p()

    from echomesh.Instance import Instance
    p()

    instance = Instance()
    print()
    p()

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

    instance.main()
Example #6
0
from __future__ import absolute_import, division, print_function, unicode_literals

from echomesh.base import Path

Path.fix_sys_path(show_error=False, prompt=False)

import unittest

class TestCase(unittest.TestCase):
    EPSILON = 0.000001

    def assertNear(self, x, y, msg=None):
        try:
            lx, ly = len(x), len(y)
        except:
            self.assertTrue(abs(x - y) < self.EPSILON,
                            msg or ('%s != %s' % (x, y)))
        else:
            self.assertEquals(lx, ly)
            for xi, yi in zip(x, y):
                self.assertNear(xi, yi, msg)

main = unittest.main
Example #7
0
#!/usr/bin/env python

from __future__ import absolute_import, division, print_function, unicode_literals

import sys

from echomesh.base import Path
Path.fix_sys_path()

from echomesh.network.Server import Server

DEFAULT_ARGS = 'server localhost 1239 0.100'


def server(host, port, timeout):
    print('Starting server %s:%d' % (host, port))
    server = Server(host, port, timeout, True)
    server.start()
    parts = []

    while True:
        line = raw_input('%d: ' % len(parts))
        strip = line.strip()
        if strip and 'quit'.startswith(strip):
            return
        parts.append(line)
        if line.startswith('---'):
            server.write(''.join(parts))
            parts = []
            print('....sent!')