<s> '''<STR_LIT>''' <EOL> import os <EOL> import sys <EOL> import argparse <EOL> import logging <EOL> from datetime import datetime , time <EOL> ERR_NO_ERROR = <NUM_LIT:0> <EOL> ERR_BAD_PARAMS = <NUM_LIT:2> <EOL> from stacker import Stacker <EOL> console_handler = logging . StreamHandler ( sys . stdout ) <EOL> console_handler . setLevel ( logging . INFO ) <EOL> console_formatter = logging . Formatter ( '<STR_LIT>' ) <EOL> console_handler . setFormatter ( console_formatter ) <EOL> logger = logging . getLogger ( __name__ ) <EOL> if not logger . level : <EOL> logger . setLevel ( logging . DEBUG ) <EOL> logger . addHandler ( console_handler ) <EOL> class CLI_Utilities ( Stacker ) : <EOL> def __init__ ( self ) : <EOL> Stacker . __init__ ( self ) <EOL> def command_get_tile_indexes ( self , argsList ) : <EOL> arg_parser = argparse . ArgumentParser ( add_help = False , description = '<STR_LIT>' ) <EOL> arg_parser . add_argument ( '<STR_LIT>' , dest = "<STR_LIT>" , default = <NUM_LIT> , help = '<STR_LIT>' ) <EOL> arg_parser . add_argument ( '<STR_LIT>' , nargs = "<STR_LIT:?>" , dest = "<STR_LIT:file>" , type = argparse . FileType ( '<STR_LIT:w>' ) , default = sys . stdout , help = "<STR_LIT>" ) <EOL> arg_parser . add_argument ( '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> if ( argsList is None ) : <EOL> arg_parser . print_help ( ) <EOL> return ERR_BAD_PARAMS <EOL> args , others = arg_parser . parse_known_args ( argsList ) <EOL> intersectingTiles = self . get_intersecting_tiles ( args . geometry_wkt , args . geometry_srid ) <EOL> for ( x , y , id ) in intersectingTiles : <EOL> args . file . write ( '<STR_LIT>' % ( x , y ) ) <EOL> return ERR_NO_ERROR <EOL> def command_get_tile_paths ( self , argsList ) : <EOL> arg_parser = argparse . ArgumentParser ( add_help = False , description = '<STR_LIT>' ) <EOL> arg_parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , required = True , help = '<STR_LIT>' ) <EOL> arg_parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , required = True , help = '<STR_LIT>' ) <EOL> arg_parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , required = False , default = None , help = '<STR_LIT>' ) <EOL> arg_parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , required = False , default = None , help = '<STR_LIT>' ) <EOL> arg_parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , required = False , default = None , help = '<STR_LIT>' ) <EOL> arg_parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , required = False , default = None , help = '<STR_LIT>' ) <EOL> arg_parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , required = False , default = None , help = '<STR_LIT>' ) <EOL> arg_parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT:path>' , required = False , default = None , help = '<STR_LIT>' ) <EOL> arg_parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , required = False , default = None , help = '<STR_LIT>' ) <EOL> arg_parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , required = False , default = None , help = '<STR_LIT>' ) <EOL> arg_parser . add_argument ( '<STR_LIT>' , nargs = "<STR_LIT:?>" , dest = "<STR_LIT:file>" , type = argparse . FileType ( '<STR_LIT:w>' ) , default = sys . stdout , help = "<STR_LIT>" ) <EOL> if ( argsList is None ) : <EOL> arg_parser . print_help ( ) <EOL> return ERR_BAD_PARAMS <EOL> args , others = arg_parser . parse_known_args ( argsList ) <EOL> def date2datetime ( input_date , time_offset = time . min ) : <EOL> if not input_date : <EOL> return None <EOL> return datetime . combine ( input_date , time_offset ) <EOL> stack_info_dict = self . stack_tile ( x_index = int ( args . x_index ) , <EOL> y_index = int ( args . y_index ) , <EOL> stack_output_dir = None , <EOL> start_datetime = date2datetime ( args . start_date , time . min ) , <EOL> end_datetime = date2datetime ( args . end_date , time . max ) , <EOL> satellite = args . satellite , sensor = args . sensor , <EOL> tile_type_id = args . default_tile_type_id , <EOL> path = args . path , <EOL> row = args . row , <EOL> create_band_stacks = False , <EOL> disregard_incomplete_data = False ) <EOL> for processing_level in sorted ( stack_info_dict . keys ( ) ) : <EOL> if args . processing_level is None or args . processing_level == processing_level : <EOL> for start_date_time in stack_info_dict [ processing_level ] : <EOL> args . file . write ( '<STR_LIT>' % stack_info_dict [ processing_level ] [ start_date_time ] [ '<STR_LIT>' ] ) <EOL> return ERR_NO_ERROR <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> utilities = CLI_Utilities ( ) <EOL> command_names = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> arg_parser = argparse . ArgumentParser ( add_help = False , description = '<STR_LIT>' ) <EOL> arg_parser . add_argument ( '<STR_LIT>' , help = '<STR_LIT>' , choices = command_names ) <EOL> args , options = arg_parser . parse_known_args ( ) <EOL> command = args . command <EOL> if ( command == '<STR_LIT>' ) : <EOL> assert len ( options ) > <NUM_LIT:0> , '<STR_LIT>' + str ( command_names ) <EOL> command = options [ <NUM_LIT:0> ] <EOL> options = None <EOL> if ( command == '<STR_LIT>' ) : <EOL> sys . exit ( utilities . command_get_tile_indexes ( options ) ) <EOL> elif ( command == '<STR_LIT>' ) : <EOL> sys . exit ( utilities . command_get_tile_paths ( options ) ) <EOL> else : <EOL> assert False , '<STR_LIT>' + command </s>
