• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python db.setup函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中stalker.db.setup函数的典型用法代码示例。如果您正苦于以下问题:Python setup函数的具体用法?Python setup怎么用?Python setup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了setup函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_update_with_studio_is_working_properly

    def test_update_with_studio_is_working_properly(self):
        """testing if the default values are updated with the Studio instance
        if there is a database connection and there is a Studio in there
        """
        import datetime
        from stalker import db, defaults
        from stalker.db.session import DBSession
        from stalker.models.studio import Studio

        db.setup()
        db.init()

        # check the defaults are still using them self
        self.assertEqual(
            defaults.timing_resolution,
            datetime.timedelta(hours=1)
        )

        studio = Studio(
            name='Test Studio',
            timing_resolution=datetime.timedelta(minutes=15)
        )
        DBSession.add(studio)
        DBSession.commit()

        # now check it again
        self.assertEqual(
            defaults.timing_resolution,
            studio.timing_resolution
        )
开发者ID:Industriromantik,项目名称:stalker,代码行数:30,代码来源:test_config.py


示例2: create_db

def create_db():
    """creates a test database
    """
    import os
    os.environ.pop('STALKER_PATH')
    from stalker import db
    db.setup({'sqlalchemy.url': 'sqlite://'})
    db.init()
开发者ID:eoyilmaz,项目名称:anima,代码行数:8,代码来源:test_template_parser.py


示例3: setUp

    def setUp(self):
        """set the test up
        """
        db.setup({'sqlalchemy.url': 'sqlite:///:memory:'})

        self.kwargs = {
            'name': 'Test DAG Mixin'
        }
开发者ID:Industriromantik,项目名称:stalker,代码行数:8,代码来源:test_dagMixin.py


示例4: setUpClass

 def setUpClass(cls):
     """setup tests in class level
     """
     cls.config = {
         'sqlalchemy.url':
             'postgresql://stalker_admin:[email protected]/stalker_test',
         'sqlalchemy.echo': False
     }
     # clean up test database
     db.setup(cls.config)
     from stalker.db.declarative import Base
     Base.metadata.drop_all(db.DBSession.connection())
     DBSession.commit()
开发者ID:Industriromantik,项目名称:stalker,代码行数:13,代码来源:test_taskJuggler_scheduler.py


示例5: test_get_last_version_is_working_properly

    def test_get_last_version_is_working_properly(self):
        """testing if hte get_last_version() method will return Version
        instance properly
        """
        # need a database for this test
        from stalker import db

        db.setup({"sqlalchemy.url": "sqlite:///:memory:"})
        db.DBSession.add(self.version)
        db.DBSession.commit()
        self.assertTrue(self.version.id is not None)
        self.external_env.append_to_recent_files(self.version)
        last_version = self.external_env.get_last_version()
        self.assertEqual(last_version, self.version)
开发者ID:theomission,项目名称:anima,代码行数:14,代码来源:test_external.py


示例6: test_cut_duration_initialization_bug_with_cut_out

    def test_cut_duration_initialization_bug_with_cut_out(self):
        """testing if the _cut_duration attribute is initialized correctly for
        a Shot restored from DB
        """
        # re connect to the database
        db.setup({'sqlalchemy.url': 'sqlite:///%s' % self.db_path})

        # retrieve the shot back from DB
        test_shot_db = Shot.query.filter_by(name=self.kwargs['name']).first()
        # trying to change the cut_in and cut_out values should not raise any
        # errors
        test_shot_db.cut_out = 100
        db.DBSession.add(test_shot_db)
        db.DBSession.commit()
开发者ID:noflame,项目名称:stalker,代码行数:14,代码来源:test_shot.py


示例7: setUp

    def setUp(self):
        """setup the test
        """
        db.setup()

        # create permissions
        self.test_perm1 = Permission(
            access='Allow',
            action='Create',
            class_name='Something'
        )
        self.test_instance = TestClassForACL()
        self.test_instance.name = 'Test'
        self.test_instance.permissions.append(self.test_perm1)
开发者ID:2008chny,项目名称:stalker,代码行数:14,代码来源:test_aclMixin.py


示例8: setUpClass

    def setUpClass(cls):
        """setup once
        """
        # create a test database
        db.setup()
        db.init()

        # create test repositories
        cls.repo1 = Repository(
            name='Test Repo 1',
            linux_path='/test/repo/1/linux/path',
            windows_path='T:/test/repo/1/windows/path',
            osx_path='/test/repo/1/osx/path',
        )

        cls.repo2 = Repository(
            name='Test Repo 2',
            linux_path='/test/repo/2/linux/path',
            windows_path='T:/test/repo/2/windows/path',
            osx_path='/test/repo/2/osx/path',
        )

        cls.repo3 = Repository(
            name='Test Repo 3',
            linux_path='/test/repo/3/linux/path',
            windows_path='T:/test/repo/3/windows/path',
            osx_path='/test/repo/3/osx/path',
        )

        cls.repo4 = Repository(
            name='Test Repo 4',
            linux_path='/test/repo/4/linux/path',
            windows_path='T:/test/repo/4/windows/path',
            osx_path='/test/repo/4/osx/path',
        )

        cls.repo5 = Repository(
            name='Test Repo 5',
            linux_path='/test/repo/5/linux/path',
            windows_path='T:/test/repo/5/windows/path',
            osx_path='/test/repo/5/osx/path',
        )

        cls.all_repos = [cls.repo1, cls.repo2, cls.repo3, cls.repo4, cls.repo5]

        db.DBSession.add_all(cls.all_repos)
        db.DBSession.commit()
开发者ID:sergeneren,项目名称:anima,代码行数:47,代码来源:test_repo_vars.py


示例9: setUp

    def setUp(self):
        self.config = testing.setUp()
        db.setup({'sqlalchemy.url': 'sqlite:///:memory:'})

        self.test_status1 = Status(name='Test Status 1', code='TS1')
        self.test_status2 = Status(name='Test Status 2', code='TS2')
        self.test_status3 = Status(name='Test Status 3', code='TS3')

        self.test_project_status_list = StatusList(
            target_entity_type='Project',
            statuses=[
                self.test_status1,
                self.test_status2,
                self.test_status3
            ]
        )

        self.test_repo = Repository(
            name='Test Repository',
            windows_path='T:/',
            linux_path='/mnt/T',
            osx_path='/Volumes/T'
        )

        self.test_project = Project(
            name='Test Project 1',
            code='TP1',
            status_list=self.test_project_status_list,
            repository=self.test_repo
        )

        DBSession.add(self.test_project)
        transaction.commit()

        DBSession.add(self.test_project)

        self.params = {
            'mode': 'CREATE'
        }

        self.matchdict = {
            'project_id': self.test_project.id
        }
        self.request = testing.DummyRequest(params=self.params)
        self.request.matchdict = self.matchdict
开发者ID:Dr-Rakcha,项目名称:stalker-pyramid,代码行数:45,代码来源:test_asset.py


示例10: setUp

    def setUp(self):
        """setup the test
        """
        # create mock objects
        self.start = datetime.datetime(2013, 3, 22, 15, 15)
        self.end = self.start + datetime.timedelta(days=20)
        self.duration = datetime.timedelta(days=10)

        self.kwargs = {
            'name': 'Test Daterange Mixin',
            'description': 'This is a simple entity object for testing '
                           'DateRangeMixin',
            'start': self.start,
            'end': self.end,
            'duration': self.duration
        }
        db.setup({'sqlalchemy.url': 'sqlite:///:memory:'})
        self.test_foo_obj = DateRangeMixFooMixedInClass(**self.kwargs)
开发者ID:2008chny,项目名称:stalker,代码行数:18,代码来源:test_dateRangeMixin.py


示例11: test_cut_values_are_set_correctly

    def test_cut_values_are_set_correctly(self):
        """testing if the cut_in attribute is set correctly in db
        """
        self.test_shot.cut_in = 100
        self.assertEqual(self.test_shot.cut_in, 100)

        self.test_shot.cut_out = 153
        self.assertEqual(self.test_shot.cut_in, 100)
        self.assertEqual(self.test_shot.cut_out, 153)

        db.DBSession.add(self.test_shot)
        db.DBSession.commit()

        # re connect to the database
        db.setup({'sqlalchemy.url': 'sqlite:///%s' % self.db_path})

        # retrieve the shot back from DB
        test_shot_db = Shot.query.filter_by(name=self.kwargs['name']).first()

        self.assertEqual(test_shot_db.cut_in, 100)
        self.assertEqual(test_shot_db.cut_out, 153)
开发者ID:noflame,项目名称:stalker,代码行数:21,代码来源:test_shot.py


示例12: setUp

    def setUp(self):
        """set up the test
        """
        db.setup()
        db.init()

        self.temp_path = tempfile.mkdtemp()
        self.repo = Repository(
            name="Test Repository", linux_path=self.temp_path, windows_path=self.temp_path, osx_path=self.temp_path
        )
        self.status_new = Status.query.filter_by(code="NEW").first()
        self.status_wip = Status.query.filter_by(code="WIP").first()
        self.status_cmpl = Status.query.filter_by(code="CMPL").first()

        self.project_status_list = StatusList(
            target_entity_type="Project",
            name="Project Statuses",
            statuses=[self.status_new, self.status_wip, self.status_cmpl],
        )
        self.task_filename_template = FilenameTemplate(
            name="Task Filename Template",
            target_entity_type="Task",
            path="{{project.code}}/{%- for parent_task in parent_tasks -%}" "{{parent_task.nice_name}}/{%- endfor -%}",
            filename="{{version.nice_name}}" '_v{{"%03d"|format(version.version_number)}}{{extension}}',
        )
        self.project_structure = Structure(name="Project Structure", templates=[self.task_filename_template])
        self.project = Project(
            name="Test Project",
            code="TP",
            status_list=self.project_status_list,
            repository=self.repo,
            structure=self.project_structure,
        )

        self.task = Task(name="Test Task", project=self.project)
        self.version = Version(task=self.task)

        self.kwargs = {"name": "Photoshop", "extensions": ["psd"], "structure": ["Outputs"]}

        self.external_env = ExternalEnv(**self.kwargs)
开发者ID:theomission,项目名称:anima,代码行数:40,代码来源:test_external.py


示例13: setUp

 def setUp(self):
     """setup the test
     """
     # create a database
     db.setup()
开发者ID:Industriromantik,项目名称:stalker,代码行数:5,代码来源:test_statusMixin.py


示例14: setUp

 def setUp(self):
     """set up the test
     """
     db.setup({"sqlalchemy.url": "sqlite:///:memory:"})
开发者ID:theomission,项目名称:anima,代码行数:4,代码来源:test_environmentBase.py


示例15: setUp

    def setUp(self):
        """setup the tests
        """
        # -----------------------------------------------------------------
        # start of the setUp
        # create the environment variable and point it to a temp directory
        db.setup()
        db.init()

        self.temp_repo_path = tempfile.mkdtemp()

        self.user1 = User(
            name='User 1',
            login='user1',
            email='[email protected]',
            password='12345'
        )
        db.DBSession.add(self.user1)
        db.DBSession.commit()

        # login as self.user1
        from stalker import LocalSession
        local_session = LocalSession()
        local_session.store_user(self.user1)
        local_session.save()

        self.repo1 = Repository(
            name='Test Project Repository',
            linux_path=self.temp_repo_path,
            windows_path=self.temp_repo_path,
            osx_path=self.temp_repo_path
        )

        self.status_new = Status.query.filter_by(code='NEW').first()
        self.status_wip = Status.query.filter_by(code='WIP').first()
        self.status_comp = Status.query.filter_by(code='CMPL').first()

        self.task_template = FilenameTemplate(
            name='Task Template',
            target_entity_type='Task',
            path='{{project.code}}/'
                 '{%- for parent_task in parent_tasks -%}'
                 '{{parent_task.nice_name}}/'
                 '{%- endfor -%}',
            filename='{{version.nice_name}}'
                     '_v{{"%03d"|format(version.version_number)}}',
        )

        self.asset_template = FilenameTemplate(
            name='Asset Template',
            target_entity_type='Asset',
            path='{{project.code}}/'
                 '{%- for parent_task in parent_tasks -%}'
                 '{{parent_task.nice_name}}/'
                 '{%- endfor -%}',
            filename='{{version.nice_name}}'
                     '_v{{"%03d"|format(version.version_number)}}',
        )

        self.shot_template = FilenameTemplate(
            name='Shot Template',
            target_entity_type='Shot',
            path='{{project.code}}/'
                 '{%- for parent_task in parent_tasks -%}'
                 '{{parent_task.nice_name}}/'
                 '{%- endfor -%}',
            filename='{{version.nice_name}}'
                     '_v{{"%03d"|format(version.version_number)}}',
        )

        self.sequence_template = FilenameTemplate(
            name='Sequence Template',
            target_entity_type='Sequence',
            path='{{project.code}}/'
                 '{%- for parent_task in parent_tasks -%}'
                 '{{parent_task.nice_name}}/'
                 '{%- endfor -%}',
            filename='{{version.nice_name}}'
                     '_v{{"%03d"|format(version.version_number)}}',
        )

        self.structure = Structure(
            name='Project Struture',
            templates=[self.task_template, self.asset_template,
                       self.shot_template, self.sequence_template]
        )

        self.project_status_list = StatusList(
            name='Project Statuses',
            target_entity_type='Project',
            statuses=[self.status_new, self.status_wip, self.status_comp]
        )

        self.image_format = ImageFormat(
            name='HD 1080',
            width=1920,
            height=1080,
            pixel_aspect=1.0
        )

#.........这里部分代码省略.........
开发者ID:eoyilmaz,项目名称:anima,代码行数:101,代码来源:test_version_updater.py


示例16: setUp

 def setUp(self):
     """setup the test
     """
     DBSession.remove()
     db.setup()
     defaults.local_storage_path = tempfile.mktemp()
开发者ID:2008chny,项目名称:stalker,代码行数:6,代码来源:test_local_session.py


示例17: setUpClass

 def setUpClass(cls):
     """set up once
     """
     db.setup()
     db.init()
开发者ID:theomission,项目名称:anima,代码行数:5,代码来源:test_external.py


示例18: import

"""This is an example which uses two different folder structure in two
different projects.

The first one prefers to use a flat one, in which all the files are in the same
folder.

The second project uses a more traditional folder structure where every
Task/Asset/Shot/Sequence has its own folder and the Task hierarchy is directly
reflected to folder hierarchy.
"""

from stalker import (db, Project, Repository, Structure, FilenameTemplate,
                     Task, Status, StatusList, Version, Sequence, Shot)

# initialize an in memory sqlite3 database
db.setup()

# fill in default data
db.init()

# create a new repository
repo = Repository(
    name='Test Repository',
    linux_path='/mnt/T/stalker_tests/',
    osx_path='/Volumes/T/stalker_tests/',
    windows_path='T:/stalker_tests/'
)

# create a Structure for our flat project
flat_task_template = FilenameTemplate(
    name='Flat Task Template',
开发者ID:Industriromantik,项目名称:stalker,代码行数:31,代码来源:flat_project_example.py


示例19: User

from datetime import datetime
from stalker import db, User, Department, Project, ImageFormat
from stalker.db.session import session

db.setup("sqlite:////tmp/studio.db")

myUser = User(
    name="Erkan Ozgur Yilmaz",
    login_name="eoyilmaz",
    email="[email protected]",
    password="secret",
    description="This is me"
)

tds_department = Department(
    name="TDs",
    description="This is the TDs department"
)

tds_department.users.append(myUser)

all_departments = Department.query.all()
all_members_of_dep = all_departments[0].members
print all_members_of_dep[0].first_name

session.add(myUser)
session.add(tds_department)

new_project = Project(name="Fancy Commercial")
开发者ID:2008chny,项目名称:stalker,代码行数:29,代码来源:tutorial_v001.py


示例20: setUp

    def setUp(self):
        """sets up the test
        """
        db.setup()
        db.init()

        self.test_repo_path = tempfile.mkdtemp()

        # create test data
        self.test_repo = Repository(
            name='Test Repository',
            linux_path=self.test_repo_path,
            windows_path=self.test_repo_path,
            osx_path=self.test_repo_path
        )

        self.test_task_template = FilenameTemplate(
            name='Task Template',
            target_entity_type='Task',
            path='{{project.code}}/{%- for parent_task in parent_tasks -%}'
                 '{{parent_task.nice_name}}/{%- endfor -%}',
            filename='{{version.nice_name}}'
                     '_v{{"%03d"|format(version.version_number)}}',
        )

        self.test_structure = Structure(
            name='Test Project Structure',
            templates=[self.test_task_template]
        )

        self.status_new = Status.query.filter_by(code='NEW').first()
        self.status_wip = Status.query.filter_by(code='WIP').first()
        self.status_cmpl = Status.query.filter_by(code='CMPL').first()

        self.test_project_status_list = StatusList(
            name='Project Statuses',
            statuses=[self.status_new, self.status_wip, self.status_cmpl],
            target_entity_type='Project'
        )

        self.test_project1 = Project(
            name='Test Project 1',
            code='TP1',
            repository=self.test_repo,
            structure=self.test_structure,
            status_list=self.test_project_status_list
        )
        db.DBSession.add(self.test_project1)
        db.DBSession.commit()

        # now create tasks

        # root tasks
        self.test_task1 = Task(
            name='Task1',
            project=self.test_project1
        )

        self.test_task2 = Task(
            name='Task2',
            project=self.test_project1
        )

        self.test_task3 = Task(
            name='Task3',
            project=self.test_project1
        )

        # child of Task1
        self.test_task4 = Task(
            name='Task4',
            parent=self.test_task1
        )

        self.test_task5 = Task(
            name='Task5',
            parent=self.test_task1
        )

        self.test_task6 = Task(
            name='Task6',
            parent=self.test_task1
        )

        # child of Task2
        self.test_task7 = Task(
            name='Task7',
            parent=self.test_task2
        )

        self.test_task8 = Task(
            name='Task8',
            parent=self.test_task2
        )

        self.test_task9 = Task(
            name='Task9',
            parent=self.test_task2
        )

#.........这里部分代码省略.........
开发者ID:eoyilmaz,项目名称:anima,代码行数:101,代码来源:test_version_mover.py



注:本文中的stalker.db.setup函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python db.DBSession类代码示例发布时间:2022-05-27
下一篇:
Python stagger.read_tag函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap