Example #1
0
def set_project_data(gazu_project_id, avalon_project_id, avalon_collection):
    # Lookup the Zou Id and Avalon Id key value pair of the asset

    # Set the directory where partd stores it's data
    base_directory = os.environ["DATA_PATH"]
    data_directory = os.path.join(base_directory, "data")
    directory = os.path.join(data_directory, gazu_project_id)

    # Create the data directory for the project if it doesn't exist.
    if not os.path.exists(directory):
        if not os.path.exists(data_directory):
            os.mkdir(data_directory)
        os.mkdir(directory)

    # Init partd
    p = partd.Pickle(partd.File(directory))

    # Check if the project set is already stored and delete it if it is.
    # (We're making the assumption that IDs supplied to us are unique).
    if p.get(gazu_project_id):
        p.delete(gazu_project_id)
        logger.info("Removing old project info for: {0}".format(
            avalon_collection))

    # Encode and store the data as a utf-8 bytes
    value = [avalon_project_id, avalon_collection]
    key_values = {gazu_project_id: value}
    p.append(key_values)
    logger.info("Adding new project info for: {0}".format(
        avalon_collection))
Example #2
0
def test_partition_collect():
    with partd.Pickle() as p:
        partition(identity, range(6), 3, p)
        assert set(p.get(0)) == set([0, 3])
        assert set(p.get(1)) == set([1, 4])
        assert set(p.get(2)) == set([2, 5])

        assert sorted(collect(identity, 0, p, '')) == [(0, [0]), (3, [3])]
Example #3
0
def test_partition_collect():
    with partd.Pickle() as p:
        partition(identity, range(6), 3, p)
        assert set(p.get(0)) == {0, 3}
        assert set(p.get(1)) == {1, 4}
        assert set(p.get(2)) == {2, 5}

        assert sorted(collect(identity, 0, p, "")) == [(0, [0]), (3, [3])]
Example #4
0
def get_project_data(project_id):
    # Lookup the Zou Id and Avalon Id key value pair of the asset

    # Set the directory where partd stores it's data
    directory = os.path.join(os.environ["DATA_PATH"], "data", project_id)

    # Init partd
    p = partd.Pickle(partd.File(directory))

    if not p.get(project_id):
        return False
    else:
        # Get the Avalon asset ID from partd
        project_info = p.get(project_id)
        project_data = {
            "id": project_info[0],
            "collection": project_info[1]
        }
        return project_data