<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import rpc4django <EOL> from django . core import exceptions as django_ex <EOL> from services . configuration . models import segments as segment_models <EOL> from services . leop import push as launch_push <EOL> from services . leop import utils as launch_utils <EOL> from services . leop . models import launch as launch_models <EOL> from services . leop . models import ufos as ufo_models <EOL> from services . leop . jrpc . serializers import launch as launch_serial <EOL> from services . simulation . models import passes as pass_models <EOL> from services . simulation . jrpc . serializers import passes as pass_serializers <EOL> from website import settings as satnet_settings <EOL> @ rpc4django . rpcmethod ( <EOL> name = '<STR_LIT>' , <EOL> signature = [ '<STR_LIT>' ] , <EOL> login_required = satnet_settings . JRPC_LOGIN_REQUIRED <EOL> ) <EOL> def list_groundstations ( launch_id , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if satnet_settings . JRPC_PERMISSIONS : <EOL> http_request = kwargs . get ( '<STR_LIT>' , None ) <EOL> if not http_request or not http_request . user . is_staff : <EOL> raise django_ex . PermissionDenied ( ) <EOL> leop_cluster = launch_models . Launch . objects . get ( identifier = launch_id ) <EOL> u_gs = leop_cluster . groundstations . all ( ) <EOL> all_gs = segment_models . GroundStation . objects . all ( ) <EOL> a_gs = [ item for item in all_gs if item not in u_gs ] <EOL> return launch_serial . serialize_gs_lists ( a_gs , u_gs ) <EOL> @ rpc4django . rpcmethod ( <EOL> name = '<STR_LIT>' , <EOL> signature = [ '<STR_LIT>' ] , <EOL> login_required = satnet_settings . JRPC_LOGIN_REQUIRED <EOL> ) <EOL> def list_spacecraft ( launch_id , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if satnet_settings . JRPC_PERMISSIONS : <EOL> http_request = kwargs . get ( '<STR_LIT>' , None ) <EOL> if not http_request or not http_request . user . is_staff : <EOL> raise django_ex . PermissionDenied ( ) <EOL> launch = launch_models . Launch . objects . get ( identifier = launch_id ) <EOL> scs = [ launch . cluster_spacecraft_id ] <EOL> for identified_o in launch . identified_objects . all ( ) : <EOL> scs += [ <EOL> launch_utils . generate_object_sc_identifier ( <EOL> launch_id , identified_o . identifier <EOL> ) <EOL> ] <EOL> return scs <EOL> @ rpc4django . rpcmethod ( <EOL> name = '<STR_LIT>' , <EOL> signature = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> login_required = satnet_settings . JRPC_LOGIN_REQUIRED <EOL> ) <EOL> def add_groundstations ( launch_id , groundstations , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> http_request = kwargs . get ( '<STR_LIT>' , None ) <EOL> if not http_request or not http_request . user . is_staff : <EOL> raise django_ex . PermissionDenied ( ) <EOL> if not groundstations : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> result = launch_serial . serialize_leop_id ( <EOL> launch_models . Launch . objects . add_ground_stations ( <EOL> launch_id , groundstations <EOL> ) <EOL> ) <EOL> launch_push . LaunchPush . trigger_gss_assigned ( launch_id , groundstations ) <EOL> return result <EOL> @ rpc4django . rpcmethod ( <EOL> name = '<STR_LIT>' , <EOL> signature = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> login_required = satnet_settings . JRPC_LOGIN_REQUIRED <EOL> ) <EOL> def remove_groundstations ( launch_id , groundstations , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> http_request = kwargs . get ( '<STR_LIT>' , None ) <EOL> if not http_request or not http_request . user . is_staff : <EOL> raise django_ex . PermissionDenied ( ) <EOL> if not groundstations : <EOL> return launch_serial . serialize_leop_id ( launch_id ) <EOL> launch_models . Launch . objects . remove_groundstations ( <EOL> launch_id , groundstations <EOL> ) <EOL> launch_push . LaunchPush . trigger_gss_released ( launch_id , groundstations ) <EOL> return True <EOL> @ rpc4django . rpcmethod ( <EOL> name = '<STR_LIT>' , <EOL> signature = [ '<STR_LIT>' , '<STR_LIT:int>' ] , <EOL> login_required = satnet_settings . JRPC_LOGIN_REQUIRED <EOL> ) <EOL> def add_unknown ( launch_id , object_id ) : <EOL> """<STR_LIT>""" <EOL> return launch_models . Launch . objects . add_unknown ( <EOL> launch_id , object_id <EOL> ) <EOL> @ rpc4django . rpcmethod ( <EOL> name = '<STR_LIT>' , <EOL> signature = [ '<STR_LIT>' , '<STR_LIT:int>' ] , <EOL> login_required = satnet_settings . JRPC_LOGIN_REQUIRED <EOL> ) <EOL> def remove_unknown ( launch_id , object_id ) : <EOL> """<STR_LIT>""" <EOL> return launch_models . Launch . objects . remove_unknown ( <EOL> launch_id , object_id <EOL> ) <EOL> @ rpc4django . rpcmethod ( <EOL> name = '<STR_LIT>' , <EOL> signature = [ '<STR_LIT>' , '<STR_LIT:int>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> login_required = satnet_settings . JRPC_LOGIN_REQUIRED <EOL> ) <EOL> def identify ( launch_id , object_id , callsign , tle_l1 , tle_l2 ) : <EOL> """<STR_LIT>""" <EOL> object_id , spacecraft_id = launch_models . Launch . objects . identify ( <EOL> launch_id , object_id , callsign , tle_l1 , tle_l2 <EOL> ) <EOL> launch_push . LaunchPush . trigger_ufo_identified ( <EOL> launch_id , object_id , spacecraft_id <EOL> ) <EOL> return { <EOL> launch_serial . JRPC_K_OBJECT_ID : object_id , <EOL> launch_serial . JRPC_K_SC_ID : spacecraft_id <EOL> } <EOL> @ rpc4django . rpcmethod ( <EOL> name = '<STR_LIT>' , <EOL> signature = [ '<STR_LIT>' , '<STR_LIT:int>' ] , <EOL> login_required = satnet_settings . JRPC_LOGIN_REQUIRED <EOL> ) <EOL> def forget ( launch_id , object_id ) : <EOL> """<STR_LIT>""" <EOL> spacecraft_id = ufo_models . IdentifiedObject . objects . get ( <EOL> identifier = object_id <EOL> ) . spacecraft . identifier <EOL> result = launch_models . Launch . objects . forget ( launch_id , object_id ) <EOL> launch_push . LaunchPush . trigger_ufo_forgotten ( <EOL> launch_id , object_id , spacecraft_id <EOL> ) <EOL> return result <EOL> @ rpc4django . rpcmethod ( <EOL> name = '<STR_LIT>' , <EOL> signature = [ '<STR_LIT>' , '<STR_LIT:int>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> login_required = satnet_settings . JRPC_LOGIN_REQUIRED <EOL> ) <EOL> def update ( launch_id , object_id , callsign , tle_l1 , tle_l2 ) : <EOL> """<STR_LIT>""" <EOL> object_id , spacecraft_id = launch_models . Launch . objects . update_identified ( <EOL> launch_id , object_id , callsign , tle_l1 , tle_l2 <EOL> ) <EOL> launch_push . LaunchPush . trigger_ufo_updated ( <EOL> launch_id , object_id , spacecraft_id <EOL> ) <EOL> return { <EOL> launch_serial . JRPC_K_OBJECT_ID : object_id , <EOL> launch_serial . JRPC_K_SC_ID : spacecraft_id <EOL> } <EOL> @ rpc4django . rpcmethod ( <EOL> name = '<STR_LIT>' , <EOL> signature = [ '<STR_LIT>' ] , <EOL> login_required = satnet_settings . JRPC_LOGIN_REQUIRED <EOL> ) <EOL> def get_configuration ( launch_id ) : <EOL> """<STR_LIT>""" <EOL> launch = launch_models . Launch . objects . get ( identifier = launch_id ) <EOL> return launch_serial . serialize_launch ( launch ) <EOL> @ rpc4django . rpcmethod ( <EOL> name = '<STR_LIT>' , <EOL> signature = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> login_required = satnet_settings . JRPC_LOGIN_REQUIRED <EOL> ) <EOL> def set_configuration ( launch_id , configuration ) : <EOL> """<STR_LIT>""" <EOL> launch = launch_models . Launch . objects . get ( identifier = launch_id ) <EOL> if not configuration : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> cfg_params = launch_serial . deserialize_launch ( configuration ) <EOL> launch . update ( <EOL> date = cfg_params [ <NUM_LIT:0> ] , <EOL> tle_l1 = cfg_params [ <NUM_LIT:1> ] , <EOL> tle_l2 = cfg_params [ <NUM_LIT:2> ] <EOL> ) <EOL> return launch . identifier <EOL> @ rpc4django . rpcmethod ( <EOL> name = '<STR_LIT>' , <EOL> signature = [ '<STR_LIT>' ] , <EOL> login_required = satnet_settings . JRPC_LOGIN_REQUIRED <EOL> ) <EOL> def get_pass_slots ( launch_id ) : <EOL> """<STR_LIT>""" <EOL> launch = launch_models . Launch . objects . get ( identifier = launch_id ) <EOL> scs = [ <EOL> segment_models . Spacecraft . objects . get ( <EOL> identifier = launch . cluster_spacecraft_id <EOL> ) <EOL> ] <EOL> for i_object in launch . identified_objects . all ( ) : <EOL> scs . append ( i_object . spacecraft ) <EOL> slots = [ ] <EOL> for sc in scs : <EOL> slots += pass_models . PassSlots . objects . filter ( spacecraft = sc ) . filter ( <EOL> groundstation__in = launch . groundstations . all ( ) <EOL> ) <EOL> return pass_serializers . serialize_pass_slots ( slots ) </s>
