Esempio n. 1
0
 def __init__(self,section):
     """ Connect to database using user's .desservices file"""
     dbh = DesDbi(None,section, retry = True)
     cur = dbh.cursor()
     self.section = section
     self.dbh = dbh
     self.cur = cur 
Esempio n. 2
0
stop_if_already_running()
"""Create command line arguments"""
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--nite', '-n', required=True, help="i.e., 20140929")
parser.add_argument('--reqnum', '-r', required=True, help="i.e., 1065")
parser.add_argument('--precalnite', '-pn', required=True, help="i.e.,20140928")
parser.add_argument('--precalrun', '-pr', required=True, help="i.e., r1065p01")
parser.add_argument('--section', '-s', required=True, help="i.e., db-desoper")
args = vars(parser.parse_args())
"""Connect to database using user's .desservices file"""
try:
    desdmfile = os.environ["des_services"]
except KeyError:
    desdmfile = None

dbh = DesDbi(desdmfile, args['section'])
cur = dbh.cursor()
""" Get exposure numbers and band for incoming exposures"""
get_expnum_and_band = "select distinct expnum, band from exposure where nite = '%s' and object != 'zeropoint' and object not like '%%pointing%%' and object not like '%%focus%%' and object not like '%%donut%%' and object not like '%%test%%' and object not like '%%junk%%' and obstype='object'" % args[
    'nite']
cur.execute(get_expnum_and_band)
allexpnumnband = cur.fetchall()
""" If no exposures are found. Do nothing."""
if len(allexpnumnband) == 0:
    message = "No exposures found on %s." % datetime.datetime.now()
    print message
    sys.exit(0)
""" Create log file if exposures found"""
log = '%s_firstcut_submit_%s.log' % (args['nite'], time.strftime("%X"))
logfile = open(log, 'a')
""" Keep only exposures that have not already been processed"""
Esempio n. 3
0
 def __init__(self, section):
     """Connect to database using user's .desservices file"""
     dbh = DesDbi(None, section)
     self.section = section
     self.cur = dbh.cursor()
Esempio n. 4
0
def connect_to_db(section):
    dbh = DesDbi(os.getenv("DES_SERVICES"),section)
    cur = dbh.cursor()
    return (dbh,cur)
    field_shallow = [
        "SN-C1", "SN-C2", "SN-E1", "SN-E2", "SN-S1", "SN-S2", "SN-X1", "SN-X2"
    ]
    field_deep = ["SN-C3", "SN-X3"]
    sequencer = {}
    sequencer = reset_sequencer(sequencer)
    min_exptime = 29.9

    #
    #   Setup DB connection
    #
    try:
        desdmfile = os.environ["des_services"]
    except KeyError:
        desdmfile = None
    dbh = DesDbi(desdmfile, args.section)
    cur = dbh.cursor()
    #
    #   If an association with a JIRA ticket has been requested then make sure that a connection can be made to jira also.
    #   NOTE: Could use try for inital connect if suitable means to catch an error was known....
    #
    if (args.jira is not None):
        jira_connect = jiracmd.Jira('jira-desdm')
        try:
            check_parent_issue = jira_connect.jira.issue(args.jira)
        except:
            print 'Parent issue %s does not exist!' % args.jira
            sys.exit()

#
#   Main (workhorse) query to collect exposure information