Skip to main content

Unity Assets Server http client

https://badge.fury.io/py/django-unity-asset-server-http-client.svg

LICENSE

MIT

Requirements

  • python 2.7

  • django 1.6+

  • djangorestframework 2.4.3+

  • django-filter 0.8

Quick start

  1. Add “duashttp” to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = (
        ...
        'duashttp',
    )

2. Add unity asset server router in your INSTALLED_APPS settings and configure access to unity asset server access.

DATABASE_ROUTERS = ['duashttp.router.UnityAssetServerRouter', ]
DATABASES = {
   'default': {
     'ENGINE': 'django.db.backends.sqlite3',
     'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
   },
   'unity_asset_server': {
      'ENGINE': 'django.db.backends.postgresql_psycopg2',
      'NAME': 'game_project_database_name',
      'USER': 'admin',
      'PASSWORD': 'admin_password',
      'HOST': '192.168.0.1',  # There UNITY asset server is placed on
      'PORT': '10733'  # standard unity asset server port number
    }
}

3. Manage your settings.py with django restframe work settings to get optimal config:

REST_FRAMEWORK = {
 'PAGINATE_BY': 10,
 'PAGINATE_BY_PARAM': 'page_size',
 # Maximum limit allowed when using `?page_size=xxx`.
 'MAX_PAGINATE_BY': 100,
 'DEFAULT_AUTHENTICATION_CLASSES': (
     'rest_framework.authentication.BasicAuthentication',
     'rest_framework.authentication.SessionAuthentication',
 ),
 'DEFAULT_FILTER_BACKENDS': ('rest_framework.filters.DjangoFilterBackend',)
}
  1. Apply your custom view sets or use existent and include them in “urls.py”:

# -*- views.py -*-
from duashttp.views.api import AssetVersionViewSetBase

from rest_framework.decorators import list_route
from rest_framework.response import Response

from django.db.models import Q


class AssetVersionViewSet(AssetVersionViewSetBase):
    """ AssetVersion view set """
    @list_route()
    def configs(self, request):
        """get xml configs with their last revision"""
        qset = (
            Q(name__icontains='.xml') &
            ~Q(name__icontains='(DEL_') &
            ~Q(name__icontains='~$')
        )
        xml_docs = self.queryset.filter(qset).order_by(
            'name', '-revision').distinct('name')
        docs = self.filter_queryset(xml_docs)
        page = self.paginate_queryset(docs)
        serializer = self.get_pagination_serializer(page)
        return Response(serializer.data)
# -*- urls.py -*-
from django.conf.urls import patterns, include, url
from views import *
from rest_framework import routers

router = routers.DefaultRouter()
router.register(r'asset_versions', AssetVersionViewSet)


urlpatterns = patterns('',
    # Examples:
    url(r'^api/', include(router.urls)),
    url(r'^api/', include(router.urls, namespace='api')),
)
  1. Start the development server and visit http://127.0.0.1:8000/api/ to see available api calls.

Models

You can fetch data from unity asset server (based on posgres 8.3) using this:

>>> from duashttp.models import AssetVersion
>>> versions = AssetVersion.objects.filter(name__icontains='Actions.xml')
>>> versions
... [<AssetVersion: Actions.xml [46]>, <AssetVersion: Actions.xml [45]>,
... <AssetVersion: Actions.xml [44]>, <AssetVersion: Actions.xml [43]>,
... <AssetVersion: Actions.xml [42]>, <AssetVersion: Actions.xml [41]>,
... <AssetVersion: Actions.xml [40]>, <AssetVersion: Actions.xml [39]>,
... <AssetVersion: Actions.xml [38]>, <AssetVersion: Actions.xml [37]>,
... <AssetVersion: Actions.xml [36]>, <AssetVersion: Actions.xml [35]>,
... <AssetVersion: Actions.xml [34]>, '...(remaining elements truncated)...']
>>> version = versions.get(revision=45)
>>> print(version.get_blob_data())
... <?xml version="1.0" encoding="utf-8"?>
... <DocumentElement>
...     <Data_Table>
...         <id>1</id>
...         <num>1</num>
...         <prefab_name />
...         <small_prefab_name>SmallAction_gems_3_dollar</small_prefab_name>
...         <icon_sprite>lucky_gem</icon_sprite>
...         <is_small_action>1</is_small_action>
...         <is_big_action />
...         <is_top_panel_action />
...         <move_to_window />
...         <affected_id />
...         <appear_date>27/10/2014 08:00</appear_date>
...         <start_date>27/10/2014 08:00</start_date>
...         <end_date>31/10/2014 08:00</end_date>
...         <expire_date>31/10/2014 08:00</expire_date>
...         <source />
...         <patch />
...         <bind_id />
...     </Data_Table>
... </DocumentElement>

Metadata

Release files for django-unity-asset-server-http-client 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-unity-asset-server-http-client 0.1.5
File Size Uploaded Provenance
django-unity-asset-server-http-client-0.1.5.tar.gz 10.0 kB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for django-unity-asset-server-http-client 0.1.5
File Interpreter ABI Platform
django_unity_asset_server_http_client-0.1.5-py2-none-any.whl Python 2 none any Details
django-unity-asset-server-http-client-0.1.5.linux-x86_64.tar.gz Details

Total release size: 40.1 kB

Release files / django-unity-asset-server-http-client-0.1.5.tar.gz

Download URL django-unity-asset-server-http-client-0.1.5.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a639e9412c8253c117d325876d4ff983f1f48d55196bd06a5c3b6e43bcab3a9c
BLAKE2b-256 checksum
How to use checksums
d222bf6426784de35d31a5b0f02cbfaacaec2fe0c371cc2603fd910f52dd0629
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_unity_asset_server_http_client-0.1.5-py2-none-any.whl

Download URL django_unity_asset_server_http_client-0.1.5-py2-none-any.whl
Size 16.3 kB
Tags Python 2
SHA-256 checksum
How to use checksums
59dec887ff89874f74a3350054a023995894f373206f58f6aefd8bbfdd3720a9
BLAKE2b-256 checksum
How to use checksums
4d318cbd409cb3021374e0736223920f5aa4209c17c16bafe21bed81ae3e7ce5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django-unity-asset-server-http-client-0.1.5.linux-x86_64.tar.gz

Download URL django-unity-asset-server-http-client-0.1.5.linux-x86_64.tar.gz
Size 13.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e96714dec53543ef36a87f37770a6af5f1df08de5cc2fe84f219209808c0841f
BLAKE2b-256 checksum
How to use checksums
8dca33a8348d1276ec2c662584ff6cd4cf3d69d658487e8919206bbf57d8049d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-unity-asset-server-http-client 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.5 This release

3 release files No provenance

0.1.2

0.1.1

0.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page