当前位置: 首页>>代码示例>>Python>>正文


Python Location.force_initialize方法代码示例

本文整理汇总了Python中tardis.tardis_portal.models.Location.force_initialize方法的典型用法代码示例。如果您正苦于以下问题:Python Location.force_initialize方法的具体用法?Python Location.force_initialize怎么用?Python Location.force_initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tardis.tardis_portal.models.Location的用法示例。


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

示例1: setUp

# 需要导入模块: from tardis.tardis_portal.models import Location [as 别名]
# 或者: from tardis.tardis_portal.models.Location import force_initialize [as 别名]
    def setUp(self):
        from tardis.tardis_portal import models
        from tempfile import mkdtemp, mktemp
        from django.conf import settings
        from os import path
        import os

        # Disconnect post_save signal
        from django.db.models.signals import post_save
        from tardis.tardis_portal.models import \
            staging_hook, Dataset_File, Replica, Location
        post_save.disconnect(staging_hook, sender=Replica)

        from django.contrib.auth.models import User
        user = 'tardis_user1'
        pwd = 'secret'
        email = ''
        self.user = User.objects.create_user(user, email, pwd)

        try:
            os.makedirs(settings.GET_FULL_STAGING_PATH_TEST)
        except OSError:
            pass
        self.temp = mkdtemp(dir=settings.GET_FULL_STAGING_PATH_TEST)

        self.file = mktemp(dir=self.temp)
        content = 'test file'
        with open(self.file, "w+b") as f:
            f.write(content)

        Location.force_initialize()

        # make datafile
        exp = models.Experiment(title='test exp1',
                                institution_name='monash',
                                created_by=self.user)
        exp.save()

        # make dataset
        dataset = models.Dataset(description="dataset description...")
        dataset.save()
        dataset.experiments.add(exp)
        dataset.save()

        # create datafile
        df = models.Dataset_File(dataset=dataset, size = len(content),
                                 filename = path.basename(self.file),
                                 md5sum='f20d9f2072bbeb6691c0f9c5099b01f3')
        df.save()

        # create replica
        base_url = 'file://' + settings.GET_FULL_STAGING_PATH_TEST
        location = Location.load_location({
            'name': 'staging-test-yyy', 'url': base_url, 'type': 'external', 
            'priority': 10, 'transfer_provider': 'local'}) 
        replica = models.Replica(datafile=df, url='file://'+self.file,
                                 protocol="staging",location=location)
        replica.verify()
        replica.save()
        self.replica = replica
开发者ID:TheGoodRob,项目名称:mytardis,代码行数:62,代码来源:test_staging.py

示例2: setUpClass

# 需要导入模块: from tardis.tardis_portal.models import Location [as 别名]
# 或者: from tardis.tardis_portal.models.Location import force_initialize [as 别名]
    def setUpClass(cls):
        cls.priorcwd = os.getcwd()
        os.chdir(os.path.dirname(__file__)+'/atom_test')
        cls.server = TestWebServer()
        cls.server.start()

        Location.force_initialize()
        Location.load_location({
            'name': 'test-atom',
            'transfer_provider': 'http',
            'url': 'http://localhost:4272/files/',
            'type': 'external',
            'priority': 10})
        Location.load_location({
            'name': 'test-atom2', 
            'transfer_provider': 'http',
            'url': 'http://mydatagrabber.cmm.uq.edu.au/files',
            'type': 'external',
            'priority': 10})

        files = path.realpath(path.join(path.dirname(__file__), 
                                        'atom_test', 'files'))
        Location.load_location({
            'name': 'test-atom3',
            'transfer_provider': 'local',
            'url': 'file://' + files,
            'type': 'external',
            'priority': 10})
开发者ID:CVL-dev,项目名称:mytardis-app-atom,代码行数:30,代码来源:test_atom_ingest.py

示例3: setUp

# 需要导入模块: from tardis.tardis_portal.models import Location [as 别名]
# 或者: from tardis.tardis_portal.models.Location import force_initialize [as 别名]
 def setUp(self):
     self.user = generate_user('fred')
     Location.force_initialize()
     self.experiment = generate_experiment(users=[self.user])
     self.dataset = generate_dataset(experiments=[self.experiment])
     self.server = SimpleHttpTestServer()
     self.server.start()
开发者ID:crawley,项目名称:mytardis,代码行数:9,代码来源:test_transfer.py

示例4: setUp

# 需要导入模块: from tardis.tardis_portal.models import Location [as 别名]
# 或者: from tardis.tardis_portal.models.Location import force_initialize [as 别名]
    def setUp(self):
        # Create test owner without enough details
        username, email, password = ('testuser',
                                     '[email protected]',
                                     'password')
        user = User.objects.create_user(username, email, password)
        profile = UserProfile(user=user, isDjangoAccount=True)
        profile.save()

        Location.force_initialize()

        # Create test experiment and make user the owner of it
        experiment = Experiment(title='Text Experiment',
                                institution_name='Test Uni',
                                created_by=user)
        experiment.save()
        acl = ObjectACL(
            pluginId='django_user',
            entityId=str(user.id),
            content_object=experiment,
            canRead=True,
            canWrite=True,
            canDelete=True,
            isOwner=True,
            aclOwnershipType=ObjectACL.OWNER_OWNED)
        acl.save()

        dataset = Dataset(description='dataset description...')
        dataset.save()
        dataset.experiments.add(experiment)
        dataset.save()

        def create_datafile(filename):
            testfile = path.join(path.dirname(__file__), 'fixtures',
                                 filename)

            size, sha512sum = get_size_and_sha512sum(testfile)

            datafile = Dataset_File(dataset=dataset,
                                    filename=path.basename(testfile),
                                    size=size,
                                    sha512sum=sha512sum)
            datafile.save()
            base_url = 'file://' + path.abspath(path.dirname(testfile))
            location = Location.load_location({
                'name': 'test-grabber', 'url': base_url, 'type': 'external',
                'priority': 10, 'transfer_provider': 'local'})
            replica = Replica(datafile=datafile,
                              url='file://'+path.abspath(testfile),
                              protocol='file',
                              location=location)
            replica.verify()
            replica.save()
            return Dataset_File.objects.get(pk=datafile.pk)

        self.dataset = dataset
        self.datafiles = [create_datafile('data_grabber_test1.admin'),
                          create_datafile('testfile.txt')
                         ] 
开发者ID:UQ-CMM-Mirage,项目名称:mytardis-app-datagrabber,代码行数:61,代码来源:test_datagrabber.py

示例5: setUp

# 需要导入模块: from tardis.tardis_portal.models import Location [as 别名]
# 或者: from tardis.tardis_portal.models.Location import force_initialize [as 别名]
 def setUp(self):
     from django.contrib.auth.models import User
     from tardis.tardis_portal.models import Location
     user = 'tardis_user1'
     pwd = 'secret'
     email = ''
     self.user = User.objects.create_user(user, email, pwd)
     Location.force_initialize()
开发者ID:cvl-em-apm,项目名称:mytardis,代码行数:10,代码来源:test_models.py

示例6: setUp

# 需要导入模块: from tardis.tardis_portal.models import Location [as 别名]
# 或者: from tardis.tardis_portal.models.Location import force_initialize [as 别名]
 def setUp(self):
     self.user = generate_user('fred')
     Location.force_initialize()
     self.experiment = generate_experiment(
         users=[self.user],
         title='Meanwhile, down in the archives ...',
         url='http://example.com/something')
     self.dataset = generate_dataset(experiments=[self.experiment])
开发者ID:crawley,项目名称:mytardis,代码行数:10,代码来源:test_archiving.py

示例7: setUp

# 需要导入模块: from tardis.tardis_portal.models import Location [as 别名]
# 或者: from tardis.tardis_portal.models.Location import force_initialize [as 别名]
    def setUp(self):
        from os import path, mkdir
        from tempfile import mkdtemp

        user = 'tardis_user1'
        pwd = 'secret'
        email = ''
        self.user = User.objects.create_user(user, email, pwd)

        self.userProfile = UserProfile(user=self.user).save()

        self.test_dir = mkdtemp()

        Location.force_initialize()

        self.exp = Experiment(title='test exp1',
                institution_name='monash', created_by=self.user)
        self.exp.save()

        acl = ObjectACL(
            pluginId=django_user,
            entityId=str(self.user.id),
            content_object=self.exp,
            canRead=True,
            isOwner=True,
            aclOwnershipType=ObjectACL.OWNER_OWNED,
        )
        acl.save()

        self.dataset = \
            Dataset(description='dataset description...')
        self.dataset.save()
        self.dataset.experiments.add(self.exp)
        self.dataset.save()

        self.experiment_path = path.join(settings.FILE_STORE_PATH,
                str(self.dataset.get_first_experiment().id))

        self.dataset_path = path.join(self.experiment_path,
                                      str(self.dataset.id))

        if not path.exists(self.experiment_path):
            mkdir(self.experiment_path)
        if not path.exists(self.dataset_path):
            mkdir(self.dataset_path)

        # write test file

        self.filename = 'testfile.txt'

        self.f1 = open(path.join(self.test_dir, self.filename), 'w')
        self.f1.write('Test file 1')
        self.f1.close()

        self.f1_size = path.getsize(path.join(self.test_dir,
                                    self.filename))

        self.f1 = open(path.join(self.test_dir, self.filename), 'r')
开发者ID:crawley,项目名称:mytardis,代码行数:60,代码来源:test_views.py

示例8: setUp

# 需要导入模块: from tardis.tardis_portal.models import Location [as 别名]
# 或者: from tardis.tardis_portal.models.Location import force_initialize [as 别名]
    def setUp(self):
        # Create test owner without enough details
        username, email, password = ('testuser',
                                     '[email protected]',
                                     'password')
        user = User.objects.create_user(username, email, password)
        profile = UserProfile(user=user, isDjangoAccount=True)
        profile.save()
        # Need UserAuthentication
        UserAuthentication(userProfile=profile,
                           username=username,
                           authenticationMethod='localdb').save()
        # Create staging dir
        from os import path, makedirs
        staging_dir = path.join(settings.STAGING_PATH, username)
        if not path.exists(staging_dir):
            makedirs(staging_dir)
        # Ensure that staging dir is set up properly
        expect(get_full_staging_path(username)).to_be_truthy()

        Location.force_initialize()

        # Create test experiment and make user the owner of it
        experiment = Experiment(title='Text Experiment',
                                institution_name='Test Uni',
                                created_by=user)
        experiment.save()
        acl = ExperimentACL(
            pluginId=django_user,
            entityId=str(user.id),
            experiment=experiment,\

            canRead=True,
            isOwner=True,
            aclOwnershipType=ExperimentACL.OWNER_OWNED,
            )
        acl.save()

        self.dataset = \
            Dataset(description='dataset description...')
        self.dataset.save()
        self.dataset.experiments.add(experiment)
        self.dataset.save()

        self.username, self.password = (username, password)
开发者ID:guillaumeprevost,项目名称:mytardis,代码行数:47,代码来源:test_views.py

示例9: _create_datafile

# 需要导入模块: from tardis.tardis_portal.models import Location [as 别名]
# 或者: from tardis.tardis_portal.models.Location import force_initialize [as 别名]
def _create_datafile():
    user = User.objects.create_user("testuser", "[email protected]", "pwd")
    user.save()
    UserProfile(user=user).save()

    Location.force_initialize()

    full_access = Experiment.PUBLIC_ACCESS_FULL
    experiment = Experiment.objects.create(title="IIIF Test", created_by=user, public_access=full_access)
    experiment.save()
    ObjectACL(
        content_object=experiment,
        pluginId="django_user",
        entityId=str(user.id),
        isOwner=True,
        canRead=True,
        canWrite=True,
        canDelete=True,
        aclOwnershipType=ObjectACL.OWNER_OWNED,
    ).save()
    dataset = Dataset()
    dataset.save()
    dataset.experiments.add(experiment)
    dataset.save()

    # Create new Datafile
    tempfile = TemporaryUploadedFile("iiif_stored_file", None, None, None)
    with Image(filename="magick:rose") as img:
        img.format = "tiff"
        img.save(file=tempfile.file)
        tempfile.file.flush()
    datafile = Dataset_File(dataset=dataset, size=os.path.getsize(tempfile.file.name), filename="iiif_named_file")
    replica = Replica(
        datafile=datafile,
        url=write_uploaded_file_to_dataset(dataset, tempfile),
        location=Location.get_default_location(),
    )
    replica.verify(allowEmptyChecksums=True)
    datafile.save()
    replica.datafile = datafile
    replica.save()
    return datafile
开发者ID:crawley,项目名称:mytardis,代码行数:44,代码来源:test_iiif.py

示例10: _setup

# 需要导入模块: from tardis.tardis_portal.models import Location [as 别名]
# 或者: from tardis.tardis_portal.models.Location import force_initialize [as 别名]
 def _setup(self):
     Location.force_initialize()
     self.user1 = generate_user('joe', 2)
     self.user2 = generate_user('fred', 1)
     self.exp1 = generate_experiment(users=[self.user1, self.user2])
     self.exp2 = generate_experiment(users=[self.user1])
     self.exp3 = generate_experiment(users=[self.user1])
     self.exp4 = generate_experiment(users=[self.user1])
     self.ds1 = generate_dataset(experiments=[self.exp1])
     self.ds2 = generate_dataset(experiments=[self.exp1, self.exp2])
     self.ds3 = generate_dataset(experiments=[self.exp3])
     self.ds4 = generate_dataset(experiments=[self.exp4])
     self.df1, self.rep1 = generate_datafile('1/2/1', self.ds1, size=100)
     self.df2, self.rep2 = generate_datafile('1/2/2', self.ds1, size=100, 
                                             verified=False)
     self.df3, self.rep3 = generate_datafile(
         'http://127.0.0.1:4272/data/1/2/3', self.ds1, size=1000)
     self.df4, self.rep4 = generate_datafile('1/2/4', self.ds2, size=1000)
     self.df5, self.rep5 = generate_datafile('1/2/5', self.ds2, size=10000)
     self.df6, self.rep6 = generate_datafile('1/2/6', self.ds3, size=100000)
     self.df7, self.rep7 = generate_datafile('1/2/7', self.ds4, size=0)
     self.df8, self.rep8 = generate_datafile('1/2/8', self.ds4, size=-1)
开发者ID:TheGoodRob,项目名称:mytardis,代码行数:24,代码来源:test_scorer.py

示例11: setUpClass

# 需要导入模块: from tardis.tardis_portal.models import Location [as 别名]
# 或者: from tardis.tardis_portal.models.Location import force_initialize [as 别名]
    def setUpClass(cls):
        cls.priorcwd = os.getcwd()
        os.chdir(os.path.dirname(__file__) + "/atom_test")
        cls.server = TestWebServer()
        cls.server.start()

        Location.force_initialize()
        Location.load_location(
            {
                "name": "test-atom",
                "transfer_provider": "http",
                "url": "http://localhost:4272/files/",
                "type": "external",
                "priority": 10,
            }
        )
        Location.load_location(
            {
                "name": "test-atom2",
                "transfer_provider": "http",
                "url": "http://mydatagrabber.cmm.uq.edu.au/files",
                "type": "external",
                "priority": 10,
            }
        )

        files = path.realpath(path.join(path.dirname(__file__), "atom_test", "files"))
        Location.load_location(
            {
                "name": "test-atom3",
                "transfer_provider": "local",
                "url": "file://" + files,
                "type": "external",
                "priority": 10,
            }
        )
开发者ID:UQ-CMM-Mirage,项目名称:mytardis-app-atom,代码行数:38,代码来源:test_atom_ingest.py

示例12: setUp

# 需要导入模块: from tardis.tardis_portal.models import Location [as 别名]
# 或者: from tardis.tardis_portal.models.Location import force_initialize [as 别名]
 def setUp(self):
     Location.force_initialize()
     self.dataset = self._create_dataset()
开发者ID:crawley,项目名称:mytardis,代码行数:5,代码来源:test_tasks.py

示例13: setUp

# 需要导入模块: from tardis.tardis_portal.models import Location [as 别名]
# 或者: from tardis.tardis_portal.models.Location import force_initialize [as 别名]
 def setUp(self):
     self.dummy_user = generate_user('joe')
     self.server = SimpleHttpTestServer()
     self.server.start()
     Location.force_initialize()
开发者ID:TheGoodRob,项目名称:mytardis,代码行数:7,代码来源:test_command.py

示例14: setUp

# 需要导入模块: from tardis.tardis_portal.models import Location [as 别名]
# 或者: from tardis.tardis_portal.models.Location import force_initialize [as 别名]
    def setUp(self):
        # create a test user
        self.user = User.objects.create_user(username='DownloadTestUser',
                                             email='',
                                             password='secret')

        Location.force_initialize()

        # create a public experiment
        self.experiment1 = Experiment(title='Experiment 1',
                                      created_by=self.user,
                                      public_access=Experiment.PUBLIC_ACCESS_FULL)
        self.experiment1.save()

        # create a non-public experiment
        self.experiment2 = Experiment(title='Experiment 2',
                                      created_by=self.user,
                                      public_access=Experiment.PUBLIC_ACCESS_NONE)
        self.experiment2.save()

        # dataset1 belongs to experiment1
        self.dataset1 = Dataset()
        self.dataset1.save()
        self.dataset1.experiments.add(self.experiment1)
        self.dataset1.save()

        # dataset2 belongs to experiment2
        self.dataset2 = Dataset()
        self.dataset2.save()
        self.dataset2.experiments.add(self.experiment2)
        self.dataset2.save()

        # absolute path first
        filename1 = 'testfile.txt'
        filename2 = 'testfile.tiff'
        self.dest1 = abspath(join(settings.FILE_STORE_PATH, '%s/%s/'
                                  % (self.experiment1.id,
                                  self.dataset1.id)))
        self.dest2 = abspath(join(settings.FILE_STORE_PATH,
                                '%s/%s/'
                                  % (self.experiment2.id,
                                  self.dataset2.id)))
        if not exists(self.dest1):
            makedirs(self.dest1)
        if not exists(self.dest2):
            makedirs(self.dest2)

        testfile1 = abspath(join(self.dest1, filename1))
        f = open(testfile1, 'w')
        f.write("Hello World!\n")
        f.close()

        testfile2 = abspath(join(self.dest2, filename2))
        _generate_test_image(testfile2)

        self.datafile1 = self._build_datafile( \
            testfile1, filename1, self.dataset1,
            '%d/%d/%s' % (self.experiment1.id, self.dataset1.id, filename1))
                          
        self.datafile2 = self._build_datafile( \
            testfile2, filename2, self.dataset2,
            '%d/%d/%s' % (self.experiment2.id, self.dataset2.id, filename2))
开发者ID:crawley,项目名称:mytardis,代码行数:64,代码来源:test_download.py

示例15: setUp

# 需要导入模块: from tardis.tardis_portal.models import Location [as 别名]
# 或者: from tardis.tardis_portal.models.Location import force_initialize [as 别名]
 def setUp(self):
     self.user = generate_user('fred')
     Location.force_initialize()
开发者ID:crawley,项目名称:mytardis,代码行数:5,代码来源:test_utils.py


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