Ejemplo n.º 1
0
def joinvessels(vesselname1, vesselname2):
  if vesselname1 not in vesseldict:
    raise BadRequest, "No such vessel '"+vesselname1+"'"
  if vesselname2 not in vesseldict:
    raise BadRequest, "No such vessel '"+vesselname2+"'"

  if vesseldict[vesselname1]['ownerkey'] != vesseldict[vesselname2]['ownerkey']:
    raise BadRequest("Vessels must have the same owner")
  
  if vesseldict[vesselname1]['status'] == 'Started' or vesseldict[vesselname2]['status'] == 'Started':
    raise BadRequest("Attempting to join a running vessel")
  
  # get the new name
  newname = get_new_vessel_name()


  currentresourcedict1, call_list_v1 = resourcemanipulation.read_resourcedict_from_file(vesseldict[vesselname1]['resourcefilename'])
  currentresourcedict2, call_list_v2 = resourcemanipulation.read_resourcedict_from_file(vesseldict[vesselname2]['resourcefilename'])
  offcutresourcedict, offcut_call_list = resourcemanipulation.read_resourcedict_from_file(offcutfilename)


  # the final resources are reconstructed from the offcut + vessel1 + vessel2
  intermediateresourcedict = resourcemanipulation.add_resourcedicts(currentresourcedict1, currentresourcedict2)

  finalresourcedict = resourcemanipulation.add_resourcedicts(intermediateresourcedict, offcutresourcedict)

  # MMM: We add in the call list of resources from one of the original 
  # resource file. Since this is for backward compatibility for Repy V1,
  # it does not matter which call list we add in to the final resource file.
  _setup_vessel(newname, vesselname1, finalresourcedict, call_list_v1)
  _destroy_vessel(vesselname1)
  _destroy_vessel(vesselname2)
    
  persist.commit_object(vesseldict, "vesseldict")
  return newname+"\nSuccess"
Ejemplo n.º 2
0
def joinvessels(vesselname1, vesselname2):
  if vesselname1 not in vesseldict:
    raise BadRequest, "No such vessel '"+vesselname1+"'"
  if vesselname2 not in vesseldict:
    raise BadRequest, "No such vessel '"+vesselname2+"'"

  if vesseldict[vesselname1]['ownerkey'] != vesseldict[vesselname2]['ownerkey']:
    raise BadRequest("Vessels must have the same owner")
  
  if vesseldict[vesselname1]['status'] == 'Started' or vesseldict[vesselname2]['status'] == 'Started':
    raise BadRequest("Attempting to join a running vessel")
  
  # get the new name
  newname = get_new_vessel_name()


  currentresourcedict1 = resourcemanipulation.read_resourcedict_from_file(vesseldict[vesselname1]['resourcefilename'])
  currentresourcedict2 = resourcemanipulation.read_resourcedict_from_file(vesseldict[vesselname2]['resourcefilename'])
  offcutresourcedict = resourcemanipulation.read_resourcedict_from_file(offcutfilename)


  # the final resources are reconstructed from the offcut + vessel1 + vessel2
  intermediateresourcedict = resourcemanipulation.add_resourcedicts(currentresourcedict1, currentresourcedict2)

  finalresourcedict = resourcemanipulation.add_resourcedicts(intermediateresourcedict, offcutresourcedict)

  _setup_vessel(newname, vesselname1, finalresourcedict)
  _destroy_vessel(vesselname1)
  _destroy_vessel(vesselname2)
    
  persist.commit_object(vesseldict, "vesseldict")
  return newname+"\nSuccess"
Ejemplo n.º 3
0
def joinvessels(vesselname1, vesselname2):
    if vesselname1 not in vesseldict:
        raise BadRequest, "No such vessel '" + vesselname1 + "'"
    if vesselname2 not in vesseldict:
        raise BadRequest, "No such vessel '" + vesselname2 + "'"

    if vesseldict[vesselname1]['ownerkey'] != vesseldict[vesselname2][
            'ownerkey']:
        raise BadRequest("Vessels must have the same owner")

    if vesseldict[vesselname1]['status'] == 'Started' or vesseldict[
            vesselname2]['status'] == 'Started':
        raise BadRequest("Attempting to join a running vessel")

    # get the new name
    newname = get_new_vessel_name()

    currentresourcedict1, call_list_v1 = resourcemanipulation.read_resourcedict_from_file(
        vesseldict[vesselname1]['resourcefilename'])
    currentresourcedict2, call_list_v2 = resourcemanipulation.read_resourcedict_from_file(
        vesseldict[vesselname2]['resourcefilename'])
    offcutresourcedict, offcut_call_list = resourcemanipulation.read_resourcedict_from_file(
        offcutfilename)

    # the final resources are reconstructed from the offcut + vessel1 + vessel2
    intermediateresourcedict = resourcemanipulation.add_resourcedicts(
        currentresourcedict1, currentresourcedict2)

    finalresourcedict = resourcemanipulation.add_resourcedicts(
        intermediateresourcedict, offcutresourcedict)

    # MMM: We add in the call list of resources from one of the original
    # resource file. Since this is for backward compatibility for Repy V1,
    # it does not matter which call list we add in to the final resource file.
    _setup_vessel(newname, vesselname1, finalresourcedict, call_list_v1)
    _destroy_vessel(vesselname1)
    _destroy_vessel(vesselname2)

    persist.commit_object(vesseldict, "vesseldict")
    return newname + "\nSuccess"