コード例 #1
0
def enter_new_order(email, order_source, scene_list, option_string, note=''):
    '''Places a new espa order in the database'''
    order = Order()
    order.orderid = generate_order_id(email)
    order.email = email
    order.note = note
    order.status = 'ordered'
    order.order_date = datetime.datetime.now()
    order.product_options = option_string
    order.order_source = order_source
    order.save()

    for s in set(scene_list):
        scene = Scene()
        scene.name = s
        scene.order = order
        scene.order_date = datetime.datetime.now()
        scene.status = 'submitted'
        scene.save()

    return order
コード例 #2
0
ファイル: core.py プロジェクト: USGS-EROS/espa-junk-drawer
def enter_new_order(email, order_source, scene_list, option_string, note=""):
    """Places a new espa order in the database"""
    order = Order()
    order.orderid = generate_order_id(email)
    order.email = email
    order.note = note
    order.status = "ordered"
    order.order_date = datetime.datetime.now()
    order.product_options = option_string
    order.order_source = order_source
    order.save()

    for s in set(scene_list):
        scene = Scene()
        scene.name = s
        scene.order = order
        scene.order_date = datetime.datetime.now()
        scene.status = "submitted"
        scene.save()

    return order
コード例 #3
0
def load_ee_orders():
    ''' Loads all the available orders from lta into our database and updates their status '''
    lta_service = lta.LtaServices()

    #This returns a dict that contains a list of dicts{}
    #key:(order_num,email) = list({sceneid:, unit_num:})
    orders = lta_service.get_available_orders()

    #This sets (hard codes) the product options that comes in from EE when someone
    #is requesting processing via their interface
    ee_options = {
        'include_sourcefile': False,
        'include_source_metadata': False,
        'include_sr_toa': False,
        'include_sr_thermal': False,
        'include_sr': True,
        'include_sr_browse': False,
        'include_sr_ndvi': False,
        'include_sr_ndmi': False,
        'include_sr_nbr': False,
        'include_sr_nbr2': False,
        'include_sr_savi': False,
        'include_sr_evi': False,
        'include_solr_index': False,
        'include_cfmask': False,
        'reproject': False,
        'resize': False,
        'image_extents': False
    }

    #Capture in our db
    for eeorder, email in orders:

        #create the orderid based on the info from the eeorder
        order_id = generate_ee_order_id(email, eeorder)
        order = None

        #go look to see if it already exists in the db
        try:
            order = Order.objects.get(orderid=order_id)
        except:
            #Didn't find it in the db... make the order now
            order = Order()
            order.orderid = generate_ee_order_id(email, eeorder)
            order.email = email
            order.chain = 'sr_ondemand'
            order.status = 'ordered'
            order.note = 'EarthExplorer order id: %s' % eeorder
            order.product_options = json.dumps(ee_options)
            order.ee_order_id = eeorder
            order.order_source = 'ee'
            order.order_date = datetime.datetime.now()
            order.save()

        for s in orders[eeorder, email]:
            #go look for the scene by ee_unit_id.  This will stop
            #duplicate key update collisions

            scene = None
            try:
                scene = Scene.objects.get(order=order,
                                          ee_unit_id=s['unit_num'])
                if scene.status == 'complete':
                    success, msg, status = lta_service.update_order(
                        eeorder, s['unit_num'], "C")
                    if not success:
                        log_msg = "Error updating lta for [eeorder:%s ee_unit_num:%s scene name:%s order:%s" % (
                            eeorder, s['unit_num'], scene.name, order.orderid)
                        helperlogger(log_msg)
                        log_msg = "Error detail: lta return message:%s  lta return status code:%s" % (
                            msg, status)
                        helperlogger(log_msg)
                elif scene.status == 'unavailable':
                    success, msg, status = lta_service.update_order(
                        eeorder, s['unit_num'], "R")
                    if not success:
                        log_msg = "Error updating lta for [eeorder:%s ee_unit_num:%s scene name:%s order:%s" % (
                            eeorder, s['unit_num'], scene.name, order.orderid)
                        helperlogger(log_msg)
                        log_msg = "Error detail: lta return message:%s  lta return status code:%s" % (
                            msg, status)
                        helperlogger(log_msg)
            except:
                scene = Scene()
                scene.name = s['sceneid']
                scene.ee_unit_id = s['unit_num']
                scene.order = order
                scene.order_date = datetime.datetime.now()
                scene.status = 'submitted'
                scene.save()

            #Update LTA
            success, msg, status = lta_service.update_order(
                eeorder, s['unit_num'], "I")
            if not success:
                log_msg = "Error updating lta for [eeorder:%s ee_unit_num:%s scene name:%s order:%s" % (
                    eeorder, s['unit_num'], scene.name, order.orderid)
                helperlogger(log_msg)
                log_msg = "Error detail: lta return message:%s  lta return status code:%s" % (
                    msg, status)
                helperlogger(log_msg)
コード例 #4
0
ファイル: core.py プロジェクト: USGS-EROS/espa-junk-drawer
def load_ee_orders():
    """ Loads all the available orders from lta into our database and updates their status """
    lta_service = lta.LtaServices()

    # This returns a dict that contains a list of dicts{}
    # key:(order_num,email) = list({sceneid:, unit_num:})
    orders = lta_service.get_available_orders()

    # This sets (hard codes) the product options that comes in from EE when someone
    # is requesting processing via their interface
    ee_options = {
        "include_sourcefile": False,
        "include_source_metadata": False,
        "include_sr_toa": False,
        "include_sr_thermal": False,
        "include_sr": True,
        "include_sr_browse": False,
        "include_sr_ndvi": False,
        "include_sr_ndmi": False,
        "include_sr_nbr": False,
        "include_sr_nbr2": False,
        "include_sr_savi": False,
        "include_sr_evi": False,
        "include_solr_index": False,
        "include_cfmask": False,
        "reproject": False,
        "resize": False,
        "image_extents": False,
    }

    # Capture in our db
    for eeorder, email in orders:

        # create the orderid based on the info from the eeorder
        order_id = generate_ee_order_id(email, eeorder)
        order = None

        # go look to see if it already exists in the db
        try:
            order = Order.objects.get(orderid=order_id)
        except:
            # Didn't find it in the db... make the order now
            order = Order()
            order.orderid = generate_ee_order_id(email, eeorder)
            order.email = email
            order.chain = "sr_ondemand"
            order.status = "ordered"
            order.note = "EarthExplorer order id: %s" % eeorder
            order.product_options = json.dumps(ee_options)
            order.ee_order_id = eeorder
            order.order_source = "ee"
            order.order_date = datetime.datetime.now()
            order.save()

        for s in orders[eeorder, email]:
            # go look for the scene by ee_unit_id.  This will stop
            # duplicate key update collisions

            scene = None
            try:
                scene = Scene.objects.get(order=order, ee_unit_id=s["unit_num"])
                if scene.status == "complete":
                    success, msg, status = lta_service.update_order(eeorder, s["unit_num"], "C")
                    if not success:
                        log_msg = "Error updating lta for [eeorder:%s ee_unit_num:%s scene name:%s order:%s" % (
                            eeorder,
                            s["unit_num"],
                            scene.name,
                            order.orderid,
                        )
                        helperlogger(log_msg)
                        log_msg = "Error detail: lta return message:%s  lta return status code:%s" % (msg, status)
                        helperlogger(log_msg)
                elif scene.status == "unavailable":
                    success, msg, status = lta_service.update_order(eeorder, s["unit_num"], "R")
                    if not success:
                        log_msg = "Error updating lta for [eeorder:%s ee_unit_num:%s scene name:%s order:%s" % (
                            eeorder,
                            s["unit_num"],
                            scene.name,
                            order.orderid,
                        )
                        helperlogger(log_msg)
                        log_msg = "Error detail: lta return message:%s  lta return status code:%s" % (msg, status)
                        helperlogger(log_msg)
            except:
                scene = Scene()
                scene.name = s["sceneid"]
                scene.ee_unit_id = s["unit_num"]
                scene.order = order
                scene.order_date = datetime.datetime.now()
                scene.status = "submitted"
                scene.save()

            # Update LTA
            success, msg, status = lta_service.update_order(eeorder, s["unit_num"], "I")
            if not success:
                log_msg = "Error updating lta for [eeorder:%s ee_unit_num:%s scene name:%s order:%s" % (
                    eeorder,
                    s["unit_num"],
                    scene.name,
                    order.orderid,
                )
                helperlogger(log_msg)
                log_msg = "Error detail: lta return message:%s  lta return status code:%s" % (msg, status)
                helperlogger(log_msg)