예제 #1
0
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger('reset_observations.py')

if args.debug:
    logger.setLevel(logging.DEBUG)
else:
    logger.setLevel(logging.INFO)


# for each file get the obsnum, then reset the status to first item in config files workflow_actions

obsnum=0
# for filename in glob.glob(args.files):

for jd in args.jds:
    #update observation set observation.status = 'UV_POT' where observation.date like '2456663%';
    try:
        s = dbi.Session()
        OBSES = s.query(Observation).filter(Observation.date.like('{jd}%'.format(jd=jd)))  # XXX note assumes we are not noting that this file is copied.
        obsnumbs = [obs.obsnum for obs in OBSES]
        s.close()
        for obsnum in obsnumbs:
            dbi.set_obs_status(obsnum,args.status)
            dbi.set_obs_pid(obsnum, None)
            dbi.set_obs_still_host(obsnum, None)
            dbi.add_log(obsnum, args.status, "issuing a reset_observations", 0)
            dbi.update_obs_current_stage(obsnum,None)
    except Exception as e:
        print("failed on jd/obsnum %s/%s: %s") % (jd,obsnum, e)
        continue
예제 #2
0
logging.basicConfig(
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger('reset_observations.py')

if args.debug:
    logger.setLevel(logging.DEBUG)
else:
    logger.setLevel(logging.INFO)

# for each file get the obsnum, then reset the status to first item in
# config files workflow_actions

obsnum = 0
# for filename in glob.glob(args.files):

for jd in args.jds:
    try:
        s = dbi.Session()
        # XXX note assumes we are not noting that this file is copied.
        OBSES = s.query(Observation).filter(
            Observation.date.like('{jd}%'.format(jd=jd)))
        obsnumbs = [obs.obsnum for obs in OBSES]
        s.close()
        for obsnum in obsnumbs:
            dbi.set_obs_pid(obsnum, None)
            dbi.add_log(obsnum, args.status, "issuing a retry_observations", 0)
            dbi.update_obs_current_stage(obsnum, None)
    except Exception as e:
        print("failed on jd/obsnum %s/%s: %s") % (jd, obsnum, e)
        continue
예제 #3
0
s = dbi.Session()

for name in args.names:
    try:
        # In current usage, the "obsnum" is the file basename.
        obsnum = os.path.basename(name)

        obs = s.query(Observation).filter(
            Observation.obsnum == obsnum).one_or_none()
        if obs is None:
            print("failed on filename \"%s\": nothing with that obsnum" % name)
            continue

        if obs.current_stage_in_progress not in ('FAILED', 'KILLED'):
            print("skipping \"%s\": current_stage is \"%s\", not FAILED or KILLED" % (name,
                                                                                      obs.current_stage_in_progress))
            continue

        print("issuing a %s for \"%s\"" % (desc, name))
        if args.reset:
            dbi.set_obs_status(obsnum, reset_status)
            dbi.set_obs_still_host(obsnum, None)
        dbi.update_obs_current_stage(obsnum, None)
        dbi.set_obs_pid(obsnum, None)
        dbi.add_log(obsnum, desc.upper(),
                    "doing a %s at user request" % desc, 0)
    except Exception as e:
        print("failed on filename \"%s\": %s" % (name, e), file=sys.stderr)

s.close()
예제 #4
0
if args.status == '':
    args.status = wf.workflow_actions[0]

dbi = StillDataBaseInterface(sg.dbhost,
                             sg.dbport,
                             sg.dbtype,
                             sg.dbname,
                             sg.dbuser,
                             sg.dbpasswd,
                             test=False)

# Let's do it.

try:
    s = dbi.Session()
    obsnums = [
        o.obsnum for o in s.query(Observation).filter(
            Observation.obsnum.in_(args.obsnums))
    ]
    s.close()

    for obsnum in obsnums:
        dbi.set_obs_status(obsnum, args.status)
        dbi.set_obs_pid(obsnum, None)
        dbi.set_obs_still_host(obsnum, None)
        dbi.add_log(obsnum, args.status,
                    "resetting (reset_observations_by_obsnum)", 0)
        dbi.update_obs_current_stage(obsnum, None)
except Exception as e:
    print("error: %s") % e
예제 #5
0
args = parser.parse_args()

# Set up stuff

sg = SpawnerClass()
wf = WorkFlow()

sg.config_file = args.config_file
process_client_config_file(sg, wf)
if args.status == '':
    args.status = wf.workflow_actions[0]

dbi = StillDataBaseInterface(sg.dbhost, sg.dbport, sg.dbtype, sg.dbname, sg.dbuser, sg.dbpasswd, test=False)

# Let's do it.

try:
    s = dbi.Session()
    obsnums = [o.obsnum for o in s.query(Observation).filter(Observation.obsnum.in_ (args.obsnums))]
    s.close()

    for obsnum in obsnums:
        dbi.set_obs_status(obsnum, args.status)
        dbi.set_obs_pid(obsnum, None)
        dbi.set_obs_still_host(obsnum, None)
        dbi.add_log(obsnum, args.status, "resetting (reset_observations_by_obsnum)", 0)
        dbi.update_obs_current_stage(obsnum, None)
except Exception as e:
    print("error: %s") % e