利用者:Eibriel/BAMtest

提供: wiki
移動先: 案内検索

I'm testing the Blender Management System.

  • done
      Install Client
  • done
      Install Server
  • done
      Run Server
  • done
      Run Tests

Installation

Installation steps I've followed on GNULinux/Ubuntu 14.04. This is a simple setup focused on development, not production.

Setup environment

Download code

$ mkdir ~/BAM
$ cd ~/BAM
$ git clone git://git.blender.org/blender-asset-manager.git

Generate virtual environment (requires python3.4-venv)

$ pyvenv-3.4 --without-pip myvenv

Initialize virtual environment

$ source ./myvenv/bin/activate

Install pip (pip is not installed by default by a bug)

$ wget https://pypi.python.org/packages/source/s/setuptools/setuptools-3.4.4.tar.gz
$ tar -vzxf setuptools-3.4.4.tar.gz
$ cd setuptools-3.4.4
$ python setup.py install
$ cd ..
$ wget https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz
$ tar -vzxf pip-1.5.6.tar.gz
$ cd pip-1.5.6
$ python setup.py install
$ cd ..
$ deactivate
$ source ./myvenv/bin/activate

Install required libraries

$ pip3 install -r blender-asset-manager/webservice/requirements.txt
$ pip install requests

Create several folders to be used by BAM

$ mkdir uploadfiles
$ mkdir svn_repo
$ mkdir svn_local
$ mkdir storage
$ mkdir upload

Configure BAM

$ cd blender-asset-manager/webservice/bam/
$ cp config.py.example config.py
$ gedit config.py

Change file content to (setup proper paths): On SQLALCHEMY_DATABASE_URI you can put any valid SQLAlchemy database URI.

class Config:
    DEBUG = True

class Development(Config):
    STORAGE_PATH = "/path/to/BAM/storage"
    UPLOAD_FOLDER = "/path/to/BAM/upload"
    ALLOWED_EXTENSIONS = {'txt', 'mp4', 'png', 'jpg', 'jpeg', 'gif', 'blend', 'zip'}
    SQLALCHEMY_DATABASE_URI = "sqlite:////absolute/path/to/BAM/bam_database.db"

Set environment vars:

$ export BAM_VERBOSE=bam

Initialize database migration:

$ ./manage.py db upgrade

INFO  [alembic.migration] Context impl SQLiteImpl.
INFO  [alembic.migration] Will assume non-transactional DDL.
INFO  [alembic.migration] Running upgrade None -> 4918c57ece7, initial_tables
INFO  [alembic.migration] Running upgrade 4918c57ece7 -> 52d9e7b917f, project_settings

If the process is correct running:

$ ./manage.py db current

INFO  [alembic.migration] Context impl SQLiteImpl.
INFO  [alembic.migration] Will assume non-transactional DDL.
Current revision for sqlite:////path/to/bam_database.db: 4918c57ece7 -> 52d9e7b917f (head), project_settings

If you get something like this (ending with None), means that Alembic cant connect to the database:

INFO  [alembic.migration] Context impl SQLiteImpl.
INFO  [alembic.migration] Will assume non-transactional DDL.
Current revision for sqlite:////path/to/bam_database.db: None

Setup subversion repository

$ cd ~/BAM/svn_repo
$ svnadmin create ~/BAM/svn_repo

Set user and password:

$ gedit conf/passwd

Add:

$ bamuser = bampassword

Save and exit.

Now tell svnserve to use this passwords:

$ gedit conf/svnserve.conf

Uncoment:

password-db = passwd

Open a new terminal instance, and launch svnserve:

$ svnserve --daemon --foreground

Go back to previous terminal instance, and checkout:

$ cd /path/to/svn_local
$ svn checkout svn://127.0.0.1/path/to/svn_repo --username bamuser --password bampassword

Add some files:

$ cd svn_repo
$ mkdir shot001
$ mkdir characters

Open Blender and save a file named shot001.blend on shot001 folder and bamcharacter.blend on characters folder. Link the default cube from bamcharacter.blend into shot001.blend, make sure you are using relative paths.

Commit changes:

$ svn add shot001 characters
$ svn ci -m "First commit"

Start BAM server

$ ./manage.py runserver

On your browser go to http://127.0.0.1:5000, go to Projects, the Create, and set:

  • Name: myproject
  • Repository Path: /path/to/svn_local/svn_repo
  • Upload Path: /path/to/uploadfiles

Click on Add Settings and fill:

  • Name: svn_password
  • Value: bampassword
  • Data Type: svn_password

Click Add Settings again and fill:

  • Name: svn_default_user
  • Value: bamuser
  • Data Type: svn_default_user

Click on Submit

Test BAM

Open a new Terminal instance to test bam client:

$ export PATH=$PATH:/path/to/blender-asset-manager/
$ export PATH=$PATH:/path/to/blender/
$ mkdir ~/projects
$ cd ~/projects
$ bam_cli.py init http://127.0.0.1:5000/myproject
$ cd myproject

List files:

$ bam_cli.py ls

Initialize session for shot001:

$ bam_cli.py co shot001/shot001.blend

scanning deps: b'/path/to/BAM/svn_local/svn_repo/shot001/shot001.blend'...
  blend:       b'/path/to/BAM/svn_local/svn_repo/shot001/shot001.blend'
  blend:       b'/path/to/BAM/svn_local/svn_repo/characters/bamcharacter.blend'

archiving: 2 files
  copying: b'/tmp/__blendfile_temp__/_characters/bamcharacter.blend@' -> <archive>
  copying: b'/tmp/__blendfile_temp__/shot001.blend@' -> <archive>
  written: b'/tmp/tmp1v9901on.zip'
download: [100%]
written: 'shot001'

You can edit your files now, and check the modifications:

$ bam_cli.py status

  M: shot001.blend

And commit the changes:

$ bam_cli.py ci -m "First modification"

  Remapping: b'//_character/bamcharacter.blend' -> b'//../character/bamcharacter.blend'
Now make a zipfile
  packing (M): '/path/to/BAM/projects/myproject/.bam/tmp/shot001.blend'