示例#1
0
def extractProjectDict(pr_dict):
  """Generate a project object from the JSON flle"""

  pr = Project()
  tk = Token()

  try:
    pr.project_name = pr_dict['project_name']
  except Exception, e:
    print "Missing required fields"
    raise
示例#2
0
def createTestDB(project_name,
                 channel_list=['unit_anno'],
                 channel_type=ANNOTATION,
                 channel_datatype=UINT32,
                 public=0,
                 ximagesize=10000,
                 yimagesize=10000,
                 zimagesize=1000,
                 xvoxelres=4.0,
                 yvoxelres=4.0,
                 zvoxelres=3.0,
                 scalingoption=ZSLICES,
                 scalinglevels=5,
                 readonly=READONLY_FALSE,
                 propagate=NOT_PROPAGATED,
                 window=[0, 0],
                 time=[0, 0],
                 default=False,
                 ocp_version=OCP_VERSION):
    """Create a unit test data base on the specified sit and name"""

    unituser = User.objects.get(username='******')

    ds = Dataset(dataset_name="unittest",
                 user=unituser,
                 ximagesize=ximagesize,
                 yimagesize=yimagesize,
                 zimagesize=zimagesize,
                 xoffset=0,
                 yoffset=0,
                 zoffset=1,
                 xvoxelres=xvoxelres,
                 yvoxelres=yvoxelres,
                 zvoxelres=zvoxelres,
                 scalingoption=scalingoption,
                 scalinglevels=scalinglevels,
                 starttime=time[0],
                 endtime=time[1],
                 dataset_description="Unit test")
    ds.save()

    # RBTODO need to add a window and a project

    # make the project entry
    pr = Project(project_name=project_name,
                 project_description='Unit test',
                 user=unituser,
                 dataset=ds,
                 ocp_version=ocp_version,
                 kvengine=kvengine_to_test.kvengine,
                 kvserver=kvengine_to_test.kvserver)
    pr.save()

    # and create the database
    pd = ocpcaproj.OCPCAProjectsDB()

    # create a token
    tk = Token(token_name=project_name,
               user=unituser,
               token_description='Unit test token',
               project_id=pr,
               public=public)
    tk.save()

    pd.newOCPCAProject(pr.project_name)
    try:
        for channel_name in channel_list:
            ch = Channel(channel_name=channel_name,
                         channel_type=channel_type,
                         channel_datatype=channel_datatype,
                         channel_description='Unit test channel',
                         project_id=pr,
                         readonly=readonly,
                         propagate=propagate,
                         resolution=0,
                         exceptions=1,
                         startwindow=window[0],
                         endwindow=window[1],
                         default=default)
            ch.save()
            pd.newOCPCAChannel(pr.project_name, ch.channel_name)
    except Exception, e:
        pass