Exemplo n.º 1
0
def GetViewMapCFromTestSuite():
    #need to do some locking to avoid parallel issues
    try:
        #ff = open('NextTestToRun.txt', 'rb')
        #label = ff.readline()
        #testDirectory = ff.readline()
        #label = ff.readline()
        #testInputDeck = ff.readline()
        #label = ff.readline()
        #testJsonFile = ff.readline()
        #myLen = len(testJsonFile)
        #if testJsonFile[myLen -1 ] == '\n':
        #  testJsonFile = testJsonFile[0:myLen - 1]
        #phactori.myDebugPrint2("running test ->xzq<-\ntest directory: " + \
        #  testDirectory + "\ntest input deck: " + testInputDeck + \
        #  "\ntest json file: ->" + testJsonFile + "<-\n")
        #ff.close()
        import glob
        jsonFilelist = glob.glob('*.json.correct')
        phactori.myDebugPrint2("about to open json file\n")
        phactori.myDebugPrint2("json file name: " + jsonFilelist[0] + "\n")
        jff = open(jsonFilelist[0], 'rb')
        phactori.myDebugPrint2("about to read json file\n")
        testJsonString = jff.read()
        phactori.myDebugPrint2("test json string: " + testJsonString + "\n")
        import json
        testJson = json.loads(testJsonString)
        testJson = phactori.convertJsonUnicodeToStrings(testJson)

    except:
        phactori.myDebugPrint2("GetViewMapCFromTestSuite error\n")
        exit()

    return testJson
Exemplo n.º 2
0
def GetViewMapCFromUserData(datadescription):
  """given a datadescription, get the json string view map from the user data
     and convert it into a python dict using the json library, and return
     that item.  Also determine the separator character and input deck
     filename"""
  import json

  #the following code forces a UserData item for internal testing
  #phactori.myDebugPrint2("GetViewMapCFromUserData entered\n")
  #import paraview.vtk as vtk
  #newFd = vtk.vtkFieldData()
  #newStringArray = vtk.vtkStringArray()
  #xxViewMapCStr = '{ "camera blocks": { }, "representation blocks": { }, \
  #    "operation blocks": { }, "imageset blocks": {}, \
  #    "scatter plot blocks": { }, "plot over time blocks": { } }'
  #newStringArray.InsertNextValue(xxViewMapCStr)
  #x2str = '_'
  #x3str = 'cool_input_deck'
  #newStringArray.InsertNextValue(x2str)
  #newStringArray.InsertNextValue(x3str)
  #newFd.AddArray(newStringArray)

  #datadescription.SetUserData(newFd)


  fd = datadescription.GetUserData()

  if fd == None:
    phactori.myDebugPrint2("no user data, returning {}\n")
    returnViewMapC = {}
    return returnViewMapC

  sa = fd.GetAbstractArray(0)

  testJsonString = sa.GetValue(0)
  separatorCharacterString = sa.GetValue(1)
  inputDeckFilename = sa.GetValue(2)
  phactori.myDebugPrint2("gGetJsonViewMapCFromUserData string:\n" + \
      str(testJsonString) + "\n")
  phactori.myDebugPrint2("separator string: " + separatorCharacterString + \
      "\ninputDeckFilename: " + inputDeckFilename + "\n")
  extraFileString = sa.GetValue(3) 
  phactori.myDebugPrint2("extraFileString: " + extraFileString + "\n")
  phactori.myDebugPrint2("num strings2: " + str(sa.GetNumberOfValues()))
  phactori.SetSeparatorString(separatorCharacterString)
  phactori.SetExtraFileString(extraFileString)
  returnViewMapC = json.loads(testJsonString)
  returnViewMapC = phactori.convertJsonUnicodeToStrings(returnViewMapC)

  phactori.SetDefaultImageBasename(inputDeckFilename)

  phactori.myDebugPrint2("GetViewMapCFromUserData returning\n")

  return returnViewMapC