示例#1
0
    def list_lcls_runs(self):
        if self.params.facility.lcls.web.location is None or len(
                self.params.facility.lcls.web.location) == 0:
            from xfel.command_line.auto_submit import match_runs
            import os
            exp_prefix = self.params.facility.lcls.experiment[0:3].upper()
            xtc_dir = os.path.join(
                os.environ.get('SIT_PSDM_DATA', '/reg/d/psdm'), exp_prefix,
                self.params.facility.lcls.experiment, 'xtc')
            return [{
                'run': str(r.id)
            } for r in sorted(match_runs(xtc_dir, False), key=lambda x: x.id)]
        else:
            import json
            from six.moves import urllib
            basequery = "https://pswww.slac.stanford.edu/ws/lgbk/lgbk/%s/ws/files_for_live_mode_at_location?location=%s"
            query = basequery % (self.params.facility.lcls.experiment,
                                 self.params.facility.lcls.web.location)
            R = urllib.request.urlopen(query)
            if R.getcode() != 200:
                print("Couldn't connect to LCLS webservice to list runs, code",
                      R.getcode())
                return []

            j = json.loads(R.read())
            if not j.get('success'):
                print("Web service query to list runs failed")
                return []

            return [{
                'run': str(int(r['run_num']))
            } for r in sorted(j['value'], key=lambda x: x['run_num'])
                    if r['all_present']]
示例#2
0
 def list_lcls_runs(self):
   if self.params.facility.lcls.web.user is None or len(self.params.facility.lcls.web.user) == 0:
     from xfel.command_line.auto_submit import match_runs
     import os
     exp_prefix = self.params.facility.lcls.experiment[0:3].upper()
     xtc_dir = os.path.join(os.environ.get('SIT_PSDM_DATA', '/reg/d/psdm'), exp_prefix, self.params.facility.lcls.experiment, 'xtc')
     return [{'run':str(r.id)} for r in match_runs(xtc_dir, False)]
   else:
     from xfel.xpp.simulate import file_table
     query = "https://pswww.slac.stanford.edu/ws-auth/dataexport/placed?exp_name=%s" % (self.params.facility.lcls.experiment)
     FT = file_table(self.params.facility.lcls, query, enforce80=self.params.facility.lcls.web.enforce80, enforce81=self.params.facility.lcls.web.enforce81)
     runs = FT.get_runs()
     for r in runs: r['run'] = str(r['run'])
     return runs