Exemplo n.º 1
0
 def __call__(self, xmlrpc_func, format_func, debug):
     try:
         raw = util.to_utf8(xmlrpc_func())
         fmt = format_func(raw)
         return fmt
     except:
         if debug:
             util.print_exception()
         return ''
Exemplo n.º 2
0
 def __call__ (self, xmlrpc_func, format_func, debug):
     try:
         raw = util.to_utf8 (xmlrpc_func ())
         fmt = format_func (raw)
         return fmt
     except:
         if debug:
             util.print_exception()
         return ''
Exemplo n.º 3
0
    def __monitor_dir (self, dir):
        dir = os.path.normpath (dir)
        
        if len (self.watches) >= N_WATCHES_LIMIT:
            if not self.too_many_watches:
                print "Too many directories to watch on %s" % (self.directory)
                self.too_many_watches = True
            return

        try:
            gfile = gio.File (dir)
            self.watches [dir] = gfile.monitor_directory ()
            self.watches [dir].connect ("changed", self.__handle_file_monitor_event) 
            dprint ("Added directory watch for '%s'", dir)
        except:
            print ("Failed to add monitor for %s") % (dir)
            util.print_exception ()
Exemplo n.º 4
0
if rank == 0:
    start = MPI.Wtime()
    print("Collecting and validating data...", end="")
    try:
        mat_file, est_file, eps = util.read_config()
        a, b, est = util.read_data_and_validate(mat_file, est_file, root=ROOT)

        # converting to one-dimensional array
        a = matrix_to_vector(a)
        # converting to numpy arrays
        b = np.asarray(b)
        est = np.asarray(est)
        eps = to_buffer(eps)
        n[0] = len(b)
    except Exception as e:
        util.print_exception(e)
        MPI.Finalize()
        exit(-1)

    end = MPI.Wtime()
    print("done in %.2f" % ((end - start) * 1000), "ms")
    print("Data exchange...")

# broadcast epsilon and n
comm.Bcast([eps, MPI.DOUBLE], root=0)
comm.Bcast([n, MPI.INT], root=0)

# extract value from array ([1.2] => 1.2)
eps = np.asscalar(eps)
n = int(np.asscalar(n))
chunk = n // pool_size