Example #1
0
    def newFamily(self):
        '''
           Create a new mdi's
        '''
        self.statsig.emit("Setting up/Checking processing area.")
        #   Set up family processing via fio
        if not self.setupProcessing():
            return
        #   Ts is a list of family names
        Ts = self.info.keys()
        Ts.sort()
        self.children = {}
        self.inputs.runButton.setDisabled(True)
        self.runAct.setDisabled(True)
        for T in Ts:
            #   Commands to run for this family
            c = self.cmds[T]
            #   What are the types of data being converted?
            i = self.info[T]
            #   Get number of raw files to convert in this family
            m = 0
            for f in self.info[T]['lists']:
                m += get_len(f)

            if m > 0:
                #   Create a new mdi child
                child = self.createMdiChild(c, i, T, m)
                child.show()
                self.children[T] = child
        #   Set up an after to check on children
        self.wd = watchit.Watchdog(12, userHandler=self.checkOnChildren)
        self.wd.start()
        self.statsig.emit("Processing {0}".format("/".join(
            self.children.keys())))
Example #2
0
def set_up_queue (fifo, timeout, handler) :
    #   Set up non-blocking read.
    q = Queue()
    t = Thread(target=enqueue_output, args=(fifo, q))
    t.daemon = True # thread dies with the program
    t.start()
    #   Set up watchdog for each raw file conversion.
    if timeout > 0 :
    #if False :
        wd = watchit.Watchdog (timeout, userHandler=handler)
        wd.start ()
    else : wd = None
    
    return q, t, wd
Example #3
0
 def __init__ (self, fio, cmds, info, title='X', mmax=100) :
     '''
         fio -> pforma_io object
         cmds -> list of commands
         title -> window title
         mmax -> max value for progress bar
     '''
     QtGui.QWidget.__init__ (self)
     #self.sizeHint ()
     self.fio = fio                        #   pforma_io instance
     self.cmds = cmds                      #   List of commands to monitor
     self.info = info                      #   Info about files to convert
     self.family = title                   #   Name of family A, B, C etc.
     self.cmdN = 0                         #   Command that is currently executing
     self.pee = None                       #   Process as returned by subprocess.Popen
     self.fifo = None                      #   STDOUT + STDERR of process (a pipe)
     self.fifoerr = None
     self.mmax = mmax
     self.fp = FamilyProgress (title, mmax)#   The progress bar and friends
     box = QtGui.QVBoxLayout ()
     box.addWidget (self.fp)
                                           #   Set button to start conversion
     self.fp.btn.clicked.connect (self.startConversion)
     self.running = False                  #   Not looping on output of fifo
     self.numFiles = mmax                  #   Number of files to convert
     self.cnt = 0                          #   Number of files converted
     self.seconds = TIMEOUT                #   Time out for conversion of a raw file
     self.log = []                         #   Running log of conversion (mostly from fifo)
                                           #   trddone is signal to progress bar
     #self.trddone.connect (self.fp.pbar.setValue)
     QtCore.QObject.connect (self, 
                             QtCore.SIGNAL("trddone(int)"), 
                             self.fp.pbar,
                             QtCore.SLOT("setValue(int)"),
                             QtCore.Qt.QueuedConnection)
                                           #   Wait for progress bar to display 
                                           #   before starting to monitor conversion
     wd = watchit.Watchdog (1, userHandler=self.startConversion)
     wd.start ()
     self.setLayout (box)
     self.setWindowTitle (self.family)
     self.processedFiles = {}              #   Lists of files successfully converted keyed by DAS sn
     self.monPercent = 0.01