Пример #1
0
def main(args):
    #location = "localhost:9999"
    location = "192.168.1.2:9999"
    flame = Pyro4.core.Proxy("PYRO:%s@%s" %
                             (Pyro4.constants.FLAME_NAME, location))
    #flame._pyroHmacKey = "FOO"
    flame._pyroBind()

    # print something to the remote server output
    #flame.builtin("print")("Hello there, remote server stdout!")

    if len(args) < 2:
        args.append('help')  # you need help

    # remote console
    if args[1] == 'console':
        with flame.console() as console:
            console.interact()
    elif args[1] == 'send':
        flame.evaluate(
            "setattr(sys.modules['deltabar'], 'has_error', True)"
        )  # HACK FIXME TODO, this pauses acUpdate while we reload the module
        time.sleep(0.1)  # HACK
        #    sys.exit(1)  # FIXME
        for filename in ("sim_info.py", "config.py", "lap.py",
                         "lap_serialize.py", "statusbox.py",
                         "deltabar_lib.py"):
            modulename = filename[:filename.rindex(".py")]
            modulesource = open("deltabar_lib/" + filename).read()
            flame.sendmodule("deltabar_lib." + modulename, modulesource)


# lame, this is not exposed:
#      flame.createModule(modulename, modulesource, filename=filename)
        time.sleep(0.1)  # HACK
        flame.evaluate("setattr(sys.modules['deltabar'], 'has_error', False)")
    elif args[1] in ('error', 'errors', 'watch'):
        while True:
            logged_errors = flame.evaluate(
                "sys.modules['deltabar'].logged_errors")
            #      print(logged_errors)
            #      sys.exit(0)
            #      delta = flame.module('deltabar')
            #      print(list(delta.logged_errors))
            #      import code
            #      foo = globals().copy()
            #      foo.update(locals())
            #      code.InteractiveConsole(locals=foo).interact()
            for error in logged_errors:
                print(error)
            if args[1] == 'watch':
                time.sleep(1)
                print()
            else:
                break
    else:
        print("use 'console', 'send', or 'errors' command")
        sys.exit(1)
Пример #2
0
def main(args):
  # EDIT your AC host IP address here
  #location = "localhost:9999"
  location = "192.168.1.77:9999"
  flame = Pyro4.core.Proxy("PYRO:%s@%s" % (Pyro4.constants.FLAME_NAME, location))
  #flame._pyroHmacKey = "FOO"
  flame._pyroBind()

  # print something to the remote server output
  #flame.builtin("print")("Hello there, remote server stdout!")

  if len(args) < 2:
    args.append('help')  # you need help

  # remote console
  if args[1] == 'console':
    with flame.console() as console:
      console.interact()
  elif args[1] == 'send':
    # This pauses acUpdate while we reload the module
    flame.evaluate("setattr(sys.modules['%s'], 'has_error', True)" % (APP_MODULE,))
    time.sleep(0.1)  # wait for another frame to pass

    for filename in SOURCE_FILES:
      modulename = filename[:filename.rindex(".py")]
      modulesource = open(os.path.join(APP_LIBDIR, filename)).read()
      flame.sendmodule('.'.join((APP_LIBDIR, modulename)), modulesource)

    # Allow acUpdate to run again
    time.sleep(0.1)
    flame.evaluate("setattr(sys.modules['%s'], 'has_error', False)" % (APP_MODULE,))
  elif args[1] in ('error', 'errors', 'watch'):
    while True:
      logged_errors = flame.evaluate("sys.modules['%s'].logged_errors" % (APP_MODULE,))
#      print(logged_errors)
#      sys.exit(0)
#      delta = flame.module(APP_MODULE)
#      print(list(delta.logged_errors))
#      import code
#      foo = globals().copy()
#      foo.update(locals())
#      code.InteractiveConsole(locals=foo).interact()
      for error in logged_errors:
        print(error)
      if args[1] == 'watch':
        time.sleep(1)
        print()
      else:
        break
  else:
    print("use 'console', 'send', or 'errors' command")
    sys.exit(1)
Пример #3
0
# basic stuff
socketmodule = flame.module("socket")
osmodule = flame.module("os")
print("remote host name=", socketmodule.gethostname())
print("remote server current directory=", osmodule.getcwd())
flame.execute("import math")
root = flame.evaluate("math.sqrt(500)")
print("calculated square root=", root)
try:
    print("remote exceptions also work...", flame.evaluate("1//0"))
except ZeroDivisionError:
    print("(caught ZeroDivisionError)")

# print something to the remote server output
flame.builtin("print")("Hello there, remote server stdout!")

# upload a module source and call a function, on the server, in this new module
modulesource = open("stuff.py").read()
flame.sendmodule("flameexample.stuff", modulesource)
result = flame.module("flameexample.stuff").doSomething("hello", 42)
print("\nresult from uploaded module:", result)

# remote console
with flame.console() as console:
    print(
        "\nStarting a remote console. Enter some commands to execute remotely. End the console as usual."
    )
    console.interact()
    print("Console session ended.")
Пример #4
0
# basic stuff
socketmodule = flame.module("socket")
osmodule = flame.module("os")
print("remote host name=", socketmodule.gethostname())
print("remote server current directory=", osmodule.getcwd())
flame.execute("import math")
root = flame.evaluate("math.sqrt(500)")
print("calculated square root=", root)
try:
    print("remote exceptions also work...", flame.evaluate("1//0"))
except ZeroDivisionError:
    print("(caught ZeroDivisionError)")

# print something to the remote server output
flame.builtin("print")("Hello there, remote server stdout!")

# upload a module source and call a function, on the server, in this new module
modulesource = open("stuff.py").read()
flame.sendmodule("flameexample.stuff", modulesource)
result = flame.module("flameexample.stuff").doSomething("hello", 42)
print("\nresult from uploaded module:", result)

# remote console
with flame.console() as console:
    print("\nStarting a remote console. Enter some commands to execute remotely. End the console as usual.")
    console.interact()
    print("Console session ended.")