parser.error("options -i and -s are mutually exclusive")
    if options.i and options.o:
        parser.error("options -i and -o are mutually exclusive")
    if not options.i and not options.p:
        parser.error("either -i or -p must be specified")

    logname = os.path.basename(options.mission).replace('.', '_')
    DBlogging.change_logfile(logname)

    if options.loglevel not in DBlogging.LEVELS:
        parser.error("invalid --log-level specified")

    DBlogging.dblogger.setLevel(DBlogging.LEVELS[options.loglevel])

    pq = dbprocessing.ProcessQueue(options.mission,
                                   dryrun=options.dryrun,
                                   echo=options.echo)

    # check currently processing
    curr_proc = pq.dbu.currentlyProcessing()
    if curr_proc:  # returns False or the PID
        # check if the PID is running
        if Utils.processRunning(curr_proc):
            # we still have an instance processing, don't start another
            pq.dbu.closeDB()
            DBlogging.dblogger.error(
                "There is a process running, can't start another: PID: %d" %
                (curr_proc))
            raise (ProcessException(
                "There is a process running, can't start another: PID: %d" %
                (curr_proc)))
    else:
        startDate = datetime.datetime(2012, 8, 30)

    startDate = startDate.date()

    if options.endDate is not None:
        endDate = dup.parse(options.endDate)
    else:
        endDate = datetime.datetime.now()

    endDate = endDate.date()

    if endDate < startDate:
        parser.error("endDate must be >= to startDate")

    db = dbprocessing.ProcessQueue(options.mission,)

    dbu = DButils.DButils(options.mission, echo=options.echo)

    dates = [startDate + datetime.timedelta(days=v) for v in range((endDate-startDate).days +1)]
    if not dates: # only one day
        dates = [startDate]

    # this is the possible dates for a product
    dates = sorted(dates)

    product_id = args[0]

    dbfiles = dbu.getFilesByProductDate(product_id,
                                        [startDate, endDate],
                                        newest_version=True)
Esempio n. 3
0
    (options, args) = parser.parse_args()
    if len(args) != 0:
        parser.error("incorrect number of arguments")

    if options.startDate is not None:
        startDate = dup.parse(options.startDate)
    else:
        parser.error("-s must be specified")

    if options.endDate is not None:
        endDate = dup.parse(options.endDate)
    else:
        parser.error("-e must be specified")

    if options.force not in [None, 0, 1, 2]:
        parser.error("invalid force option [0,1,2]")

    db = dbprocessing.ProcessQueue(options.mission, echo=options.echo)

    print(startDate, endDate)

    num = db.reprocessByDate(startDate=startDate,
                             endDate=endDate,
                             incVersion=options.force,
                             level=options.level)
    if num is None:
        num = 0
    print('Added {0} files to be reprocessed'.format(num))
    DBlogging.dblogger.info('Added {0} files to be reprocessed'.format(num))