コード例 #1
0
    def on_but_flst(self):
        self.exportLocalPars()

        logger.debug('on_but_flst', __name__)
        msg = '\n' + 50 * '-' + '\nFile status in %s for run %s:\n' % (
            fnm.path_dir_work(), self.run_number)
        list_of_files = self.get_list_of_files_peds()
        for fname in list_of_files:

            exists = os.path.exists(fname)
            msg += '%s  %s' % (os.path.basename(fname).ljust(75),
                               self.dict_status[exists].ljust(5))

            if exists:
                ctime_sec = os.path.getctime(fname)
                ctime_str = gu.get_local_time_str(ctime_sec,
                                                  fmt='%Y-%m-%d %H:%M:%S')
                size_byte = os.path.getsize(fname)
                file_owner = gu.get_path_owner(fname)
                file_mode = gu.get_path_mode(fname)
                msg += '  %s  %12d(Byte) %s  %s\n' % (
                    ctime_str, size_byte, file_owner, str(oct(file_mode)))
            else:
                msg += '\n'
        logger.info(msg, __name__)
コード例 #2
0
    def setStyleButtons(self):
        """Set buttons enabled or disabled depending on status of other fields
        """

        file_is_enable = True
        if self.str_path() == '' :
            file_is_enable = False
            self.but_browse.setStyleSheet(cp.styleButtonGood)
        else :
            self.but_browse.setStyleSheet(cp.styleButton)

        self.but_view.setEnabled(file_is_enable)
        self.but_plot.setEnabled(file_is_enable)

        #print '\nself.str_path()', self.str_path()
        #print 'fnm.path_dir_work()', fnm.path_dir_work().lstrip('.')

        is_enable_delete = file_is_enable \
                           and (self.str_path().find(fnm.path_to_calib_dir()) != -1
                                or self.str_path().find(fnm.path_dir_work().lstrip('.')) != -1
                                )
        self.but_delete.setEnabled(is_enable_delete)

        is_enable_copy = file_is_enable \
                         and self.source_name != 'Select' \
                         and self.calib_type != 'Select' 
        self.but_copy  .setEnabled(is_enable_copy)
        
        if self.source_name == 'Select' : self.but_src .setStyleSheet(cp.stylePink)
        else                            : self.but_src .setStyleSheet(cp.styleButton)
        if self.calib_type  == 'Select' : self.but_type.setStyleSheet(cp.stylePink)
        else                            : self.but_type.setStyleSheet(cp.styleButton)
コード例 #3
0
    def onButPlot(self):
        logger.info('onButPlot', __name__)

        try :
            cp.plotimgspe.close()
            cp.plotimgspe = None

        except :
            list_of_fnames = cp.guidirtree.get_list_of_checked_item_names()
            if list_of_fnames == [] :
                logger.info('\nThe list of checked files is empty IS EMPTY ! Click on check-box of desired file(s).', __name__)
                return

            fname = list_of_fnames[0]
            if len(list_of_fnames) > 1 :
                fname = gu.selectFromListInPopupMenu(list_of_fnames)

            if fname is None or fname == '' : return

            msg = 'Selected file to plot: %s' % fname
            logger.info(msg, __name__)
            #print msg

            ifname = fname
            ofname = os.path.join(fnm.path_dir_work(),'image.png')
            tit = 'Plot for %s' % os.path.basename(ifname)            
            cp.plotimgspe = PlotImgSpe(None, ifname=ifname, ofname=ofname, title=tit, load_is_visible=True)
            cp.plotimgspe.move(cp.guimain.pos().__add__(QtCore.QPoint(720,120)))
            cp.plotimgspe.show()
コード例 #4
0
    def onButPlot(self):
        logger.info('onButPlot', __name__)

        try :
            cp.plotimgspe.close()
            cp.plotimgspe = None

        except :
            list_of_fnames = cp.guidirtree.get_list_of_checked_item_names()
            if list_of_fnames == [] :
                logger.info('\nThe list of checked files is empty IS EMPTY ! Click on check-box of desired file(s).', __name__)
                return

            fname = list_of_fnames[0]
            if len(list_of_fnames) > 1 :
                fname = gu.selectFromListInPopupMenu(list_of_fnames)

            if fname is None or fname == '' : return

            msg = 'Selected file to plot: %s' % fname
            logger.info(msg, __name__)
            #print msg

            ifname = fname
            ofname = os.path.join(fnm.path_dir_work(),'image.png')
            tit = 'Plot for %s' % os.path.basename(ifname)            
            cp.plotimgspe = PlotImgSpe(None, ifname=ifname, ofname=ofname, title=tit, is_expanded=False)
            cp.plotimgspe.move(cp.guimain.pos().__add__(QtCore.QPoint(720,120)))
            cp.plotimgspe.show()
コード例 #5
0
    def selectDirFromPopupMenu(self, dir_current='.'):

        list_of_opts = [
            'Use WORK directory', 'Use CALIB directory',
            'Use CURRENT FILE directory', 'Use OTHER EXPERIMENT directory',
            'Use ALIGNMENT ARCHIVE', 'Use ./', 'Reset', 'Cancel'
        ]

        selected = gu.selectFromListInPopupMenu(list_of_opts)
        logger.info('selected option: %s' % selected, __name__)

        if selected == list_of_opts[0]: return fnm.path_dir_work()
        elif selected == list_of_opts[1]: return fnm.path_to_calib_dir()
        elif selected == list_of_opts[2]: return dir_current
        elif selected == list_of_opts[3]:
            return os.path.join(fnm.path_to_calib_dir(), '../../')
        elif selected == list_of_opts[4]:
            return '/reg/g/psdm/detector/alignment/'
        elif selected == list_of_opts[5]:
            return './'
        elif selected == list_of_opts[6]:
            return ''
        elif selected == list_of_opts[7]:
            return None
        else:
            return None
コード例 #6
0
    def onButPlot(self):
        logger.debug('onButPlot', __name__)
        try :
            cp.plotimgspe.close()
            try    : del cp.plotimgspe
            except : pass

        except :
            ifname = self.str_path()
            ofname = os.path.join(fnm.path_dir_work(),'image.png')
            tit = 'Plot for %s' % os.path.basename(ifname)            
            cp.plotimgspe = PlotImgSpe(None, ifname=ifname, ofname=ofname, title=tit, is_expanded=False)
            cp.plotimgspe.move(cp.guimain.pos().__add__(QtCore.QPoint(720,120)))
            cp.plotimgspe.show()
コード例 #7
0
    def onButPlot(self):
        logger.debug('onButPlot', __name__)

        logger.debug('onButPlot', __name__)
        try :
            cp.plotimgspe.close()
            try    : del cp.plotimgspe
            except : pass

        except :
            ifname = self.str_path()
            ofname = os.path.join(fnm.path_dir_work(),'image.png')
            tit = 'Plot for %s' % os.path.basename(ifname)            
            cp.plotimgspe = PlotImgSpe(None, ifname=ifname, ofname=ofname, title=tit, load_is_visible=True)
            cp.plotimgspe.move(cp.guimain.pos().__add__(QtCore.QPoint(720,120)))
            cp.plotimgspe.show()
コード例 #8
0
    def on_but_flst(self):
        self.exportLocalPars()

        logger.debug('on_but_flst', __name__)
        msg = '\n' + 50*'-' + '\nFile status in %s for run %s:\n' % (fnm.path_dir_work(), self.run_number)
        list_of_files = self.get_list_of_files_peds()
        for fname in list_of_files :

            exists     = os.path.exists(fname)
            msg += '%s  %s' % (os.path.basename(fname).ljust(75), self.dict_status[exists].ljust(5))

            if exists :
                ctime_sec  = os.path.getctime(fname)
                ctime_str  = gu.get_local_time_str(ctime_sec, fmt='%Y-%m-%d %H:%M:%S')
                size_byte  = os.path.getsize(fname)
                file_owner = gu.get_path_owner(fname)
                file_mode  = gu.get_path_mode(fname)
                msg += '  %s  %12d(Byte) %s  %s\n' % (ctime_str, size_byte, file_owner, str(oct(file_mode)) )
            else :
                msg += '\n'
        logger.info(msg, __name__ )
コード例 #9
0
    def selectDirFromPopupMenu(self, dir_current='.'):

        list_of_opts = [  'Use WORK directory'
                         ,'Use CALIB directory'
                         ,'Use CURRENT FILE directory'
                         ,'Use OTHER EXPERIMENT directory'
                         ,'Use ./'
                         ,'Reset'
                         ,'Cancel'
                        ]

        selected = gu.selectFromListInPopupMenu(list_of_opts)
        logger.info('selected option: %s' % selected, __name__ )

        if   selected == list_of_opts[0] : return fnm.path_dir_work()
        elif selected == list_of_opts[1] : return fnm.path_to_calib_dir()
        elif selected == list_of_opts[2] : return dir_current
        elif selected == list_of_opts[3] : return os.path.join(fnm.path_to_calib_dir(),'../../')
        elif selected == list_of_opts[4] : return './'
        elif selected == list_of_opts[5] : return ''
        elif selected == list_of_opts[6] : return None
        else                             : return None
コード例 #10
0
    def on_but_diff(self):
        logger.info('on_but_diff', __name__)

        list_of_opts = [
            'Load from WORK directory', 'Load from CALIB directory',
            'Load initial image', 'Cancel'
        ]

        selected = gu.selectFromListInPopupMenu(list_of_opts)
        logger.debug('selected option: %s' % selected, __name__)

        path0 = self.ifname
        if selected is None: return
        elif selected == list_of_opts[0]: path0 = fnm.path_dir_work()
        elif selected == list_of_opts[1]: path0 = fnm.path_to_calib_dir()
        elif selected == list_of_opts[2]: path0 = self.ifname
        elif selected == list_of_opts[3]: return
        else: return

        file_filter = 'Files (*.txt *.data *.npy)\nAll files (*)'
        path = gu.get_open_fname_through_dialog_box(self,
                                                    path0,
                                                    'Select file to subtract',
                                                    filter=file_filter)
        if path == None or path == '':
            logger.info('Loading is cancelled...', __name__)
            return

        arr_sub = gu.get_image_array_from_file(path)  # dtype=np.float32)
        if arr_sub is None: return

        if arr_sub.size != self.widgimage.arr.size:
            msg = 'Subtracted array size: %d is different from current image size: %d. Diff plotting is cancelled.' % \
                  (arr_sub.size, self.widgimage.arr.size)
            logger.warning(msg, __name__)
            #print msg
            return

        self.widgimage.subtract_from_image_array(arr_sub)
コード例 #11
0
    def on_but_diff(self):
        logger.info('on_but_diff', __name__ )

        list_of_opts = ['Load from WORK directory',
                        'Load from CALIB directory',
                        'Load initial image',
                        'Cancel'
                        ]

        selected = gu.selectFromListInPopupMenu(list_of_opts)
        logger.debug('selected option: %s' % selected, __name__ )

        path0 = self.ifname
        if selected is None              : return
        elif selected == list_of_opts[0] : path0 = fnm.path_dir_work()
        elif selected == list_of_opts[1] : path0 = fnm.path_to_calib_dir()
        elif selected == list_of_opts[2] : path0 = self.ifname
        elif selected == list_of_opts[3] : return
        else                             : return

        file_filter = 'Files (*.txt *.data *.npy)\nAll files (*)'
        path = gu.get_open_fname_through_dialog_box(self, path0, 'Select file to subtract', filter=file_filter)
        if path == None or path == '' :
            logger.info('Loading is cancelled...', __name__ )
            return

        arr_sub = gu.get_image_array_from_file(path) # dtype=np.float32)
        if arr_sub is None : return

        if arr_sub.size != self.widgimage.arr.size :
            msg = 'Subtracted array size: %d is different from current image size: %d. Diff plotting is cancelled.' % \
                  (arr_sub.size, self.widgimage.arr.size)
            logger.warning(msg, __name__ )
            #print msg
            return

        self.widgimage.subtract_from_image_array(arr_sub)
コード例 #12
0
ファイル: GUIMetrology.py プロジェクト: FilipeMaia/psdmrepo
 def onButList(self):
     msg = 'List of metrology text files in %s\n' % fnm.path_dir_work()
     for fname in fnm.get_list_of_metrology_text_files() : msg += '    %s\n' % fname
     logger.info(msg, __name__)        
コード例 #13
0
 def onButList(self):
     msg = 'List of metrology text files in %s\n' % fnm.path_dir_work()
     for fname in fnm.get_list_of_metrology_text_files():
         msg += '    %s\n' % fname
     logger.info(msg, __name__)