Пример #1
0
    def validate(self, s):
        v = self.select.value
        v = del_ftime(v)
        # build paths
        if self.multiple:
            vs = v
            paths = [os.path.join(self.curdir, v) for v in vs]
        else:
            path = os.path.join(self.curdir, v)
            paths = [path]
        # check type
        if self.type == 'file':
            for p in paths:
                if not os.path.isfile(p):
                    js_alert("Please select file(s)")
                    return
        else:
            assert self.type == 'directory'
            for p in paths:
                if not os.path.isdir(p):
                    js_alert("Please select directory(s)")
                    return
        # set output
        if self.multiple:
            self.selected = paths
        else:
            self.selected = paths[0]

        # clean up unless user choose not to
        if not self.stay_alive: self.remove()

        # next step
        if self.next:
            self.next(self.selected)
        return
Пример #2
0
 def validate_IPTS(self, s):
     ipts1 = self.text.value.encode()
     facility = self.context.config.facility
     instrument = self.context.config.instrument
     path = os.path.abspath('/%s/%s/IPTS-%s' %
                            (facility, instrument, ipts1))
     if not os.path.exists(path):
         s = "Cannot open directory %s ! Please check IPTS number" % path
         js_alert(s)
     else:
         self.context.config.ipts = ipts = ipts1
         # use your experiment IPTS number
         self.context.config.iptsdir = iptsdir = path
         # path to the directory with ct, ob, and df data files or subdirs
         datadir = self.context.config.datadir = os.path.join(
             iptsdir, "raw/")
         # make sure there is ct scan directory
         self.context.config.ct_scan_root = ct_scan_root = os.path.join(
             datadir, 'ct_scans')
         ct_scan_subdirs = [
             d for d in os.listdir(ct_scan_root)
             if os.path.isdir(os.path.join(ct_scan_root, d))
         ]
         self.context.config.ct_scan_subdirs = ct_scan_subdirs
         self.nextStep()
     return
Пример #3
0
 def validate_IPTS(self, s):
     ipts1 = self.text.value.encode()
     facility = self.context.config.facility
     instrument = self.context.config.instrument
     path = os.path.abspath('/{0}/{1}/IPTS-{2}'.format(
         facility, instrument, ipts1))
     if not os.path.exists(path):
         s = "Cannot open directory {} ! Please check IPTS number".format(
             path)
         js_alert(s)
     else:
         self.context.config.ipts = ipts = ipts1
         # use your experiment IPTS number
         self.context.config.iptsdir = iptsdir = path
         # path to the directory with ct, ob, and df data files or subdirs
         datadir = self.context.config.datadir = os.path.join(
             iptsdir, "raw/")
         self.remove()
         # make sure there is ct scan directory
         self.context.config.ct_scan_root = ct_scan_root = os.path.join(
             datadir, 'ct_scans')
         ct_scan_subdirs = [
             d for d in os.listdir(ct_scan_root)
             if os.path.isdir(os.path.join(ct_scan_root, d))
         ]
         self.context.config.ct_scan_subdirs = ct_scan_subdirs
         scan_panel = ScanNamePanel(self.context)
         scan_panel.show()
     return
Пример #4
0
 def validate(self, s):
     v = [i.encode() for i in self.select.value]
     if not v:
         js_alert("Please select at least one DF file")
         return
     config = self.context.config
     config.df_files = [os.path.join(config.df_dir, f) for f in v]
     self.remove()
     self.nextStep()
     return
Пример #5
0
 def validate(self, s):
     instrument = self.text.value.encode()
     if instrument.lower() not in self.instruments.keys():
         s = "instrument %s not supported!" % instrument
         js_alert(s)
     else:
         self.context.config.instrument = instrument.upper()
         self.context.config.facility = self.instruments[
             instrument.lower()].upper()
         self.nextStep()
     return
Пример #6
0
 def validate(self, s):
     v = self.text.value
     if not v:
         s = 'Please specify a name for your tomography scan'
         js_alert(s)
     else:
         self.context.config.scan = v.encode()
         self.remove()
         wd_panel = WorkDirPanel(self.context, self.context.config.scan)
         wd_panel.show()
     return
Пример #7
0
 def validate(self, s):
     instrument = self.text.value.encode()
     if instrument.lower() not in self.instruments.keys():
         s = "instrument {} not supported!".format(instrument)
         js_alert(s)
     else:
         self.context.config.instrument = instrument.upper()
         self.context.config.facility = self.instruments[
             instrument.lower()].upper()
         self.remove()
         ipts_panel = IPTSpanel(self.context)
         ipts_panel.show()
     return
Пример #8
0
 def handle_changedir(self, s):
     v = self.select.value
     v = del_ftime(v)
     if self.multiple:
         if len(v) != 1:
             js_alert("Please select a directory")
             return
         v = v[0]
     p = os.path.abspath(os.path.join(self.curdir, v))
     if os.path.isdir(p):
         # update first search text
         self.searching_string = self.search_text.value.strip()
         self.changeDir(p)
     return
Пример #9
0
 def removeSelectedDir(self, s):
     self.remove()
     wait = ipyw.HTML(value="<p>Removing. Please wait...</p>")
     display(wait)
     time.sleep(0.2)
     import shutil
     if os.path.islink(self.path_candidate):
         os.unlink(self.path_candidate)
     else:
         try:
             shutil.rmtree(self.path_candidate)
         except:
             wait.close()
             js_alert("Unable to remove directory tree %s" %
                      self.path_candidate)
             self.askForDir(s)
             return
     wait.close()
     self.selected = self.path_candidate
     self.nextStep()
     return
Пример #10
0
 def _check_space(self):
     free_in_G = get_space(self.root)
     if free_in_G < 200:
         js_alert(
             "%s only has %s GB left. Reconstruction may encounter problems."
             % (self.root, int(free_in_G)))