Beispiel #1
0
 def test_load_method(self):
     
     class DB(object):
         def dummy():
             pass
     
     db = DB()
     with self.assertRaises(SystemExit) as context:
         with suppress_stderr():
             utils.load_method('not_a_valid_method', DB())
     self.assertRegexpMatches(context.exception.message,
                              'not a valid method')
     sys.path.insert(1, os.path.join(os.path.dirname(__file__), '../..'))
     method = utils.load_method('_import', DB())
     self.assertRegexpMatches(str(method), 'import')
Beispiel #2
0
 def execute(self, args):
     """Run calculations."""
     if args.inchikeys.name == '<stdin>' and args.inchikeys.isatty():
         sys.exit('No input specified.')
     else:
         try:
             inchikeys = set(row.split()[0].strip()
                             for row in args.inchikeys)
         except IndexError:
             inchikeys = set([])
             return
     method = load_method(args.method)
     method.set_parent_path(args.parent_path)
     if args.map:
         args.inchikeys.close()
         self.map_client(method, args.hostname)
         return
     elif args.reduce:
         args.inchikeys.close()
         self.reduce_client(method, args.hostname)
         return
     method.setup()
     if args.mapreduce_server:
         self.mapreduce_server(inchikeys, method)
     else:
         self.mapreduce_local(inchikeys, method)