#
# Copyright 2017 Two Pore Guys, Inc.
# All rights reserved
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted providing that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES LOSS OF USE, DATA, OR PROFITS OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#

import types
import argparse
import librpc


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--uri', help='Server URI')
    args = parser.parse_args()
    client = librpc.Client()
    client.connect(args.uri)

    try:
        while True:
            line = input('> ')
            tokens = line.split()

            if not tokens:
                continue

            method = tokens[0]
            args = [eval(s) for s in tokens[1:]]

            result = client.call_sync(method, *args)
            if isinstance(result, types.GeneratorType):
                for r in result:
                    print(r)
            else:
                print(result)

    except KeyboardInterrupt:
        pass


if __name__ == '__main__':
    main()

@@ -1293,21 +1293,8 @@
 %0A#%0A%0A
-import types%0A
 impo
@@ -1815,46 +1815,34 @@
  if 
-isinstance(result, types.GeneratorType
+hasattr(result, '__next__'
 ):%0A 

work around issue with types.GeneratorType not detecting a generator