示例#1
0
    def test_method_get_instance(self):
        """Location instance get single location by primary key"""

        location = Location.get(TEST_LOCATION)

        # make sure one location is returned
        self.assertIsInstance(location, Location)
示例#2
0
    def test_method_get_instance(self):
        """Location instance get single location by primary key"""

        location = Location.get(TEST_LOCATION)

        # make sure one location is returned
        self.assertIsInstance(location, Location)
示例#3
0
    def validate(self):

        try:
            location = Location.get(self.code)
        except LocationError as e:
            raise ActionError(
                'Could not determine location from code: "{c}"'.\
                    format(c=self.code)
            )

        self._location = location
示例#4
0
文件: info.py 项目: chippey/dpa-pipe
    def validate(self):

        try:
            location = Location.get(self.code)
        except LocationError as e:
            raise ActionError(
                'Could not determine location from code: "{c}"'.\
                    format(c=self.code)
            )

        self._location = location
示例#5
0
    def test_method_list_all(self):
        """Location class list all dpa locations"""

        locations_list = Location.list()

        # returned object should be a list
        self.assertIsInstance(locations_list, list)

        # make sure items returned are not duplicated. 
        location_set = set(locations_list)
        self.assertEqual(len(locations_list), len(location_set))
        
        # ensure the types of the returned items are all 'Location'
        types = [type(location) for location in locations_list]
        self.assertEqual(len(set(types)), 1)
        self.assertEqual(types[0], Location)
示例#6
0
    def test_method_list_all(self):
        """Location class list all dpa locations"""

        locations_list = Location.list()

        # returned object should be a list
        self.assertIsInstance(locations_list, list)

        # make sure items returned are not duplicated.
        location_set = set(locations_list)
        self.assertEqual(len(locations_list), len(location_set))

        # ensure the types of the returned items are all 'Location'
        types = [type(location) for location in locations_list]
        self.assertEqual(len(set(types)), 1)
        self.assertEqual(types[0], Location)
示例#7
0
文件: init.py 项目: liudger/dpa-pipe
    def _validate_location(self):

        # ---- make sure code and server are valid

        # first, set the server value in the environment
        server_var = DpaVars.data_server() 
        server_var.value = self.server
        server_var.set()

        # now query the location code
        try:
            location = Location.get(self.code)
        except ActionError as e:
            raise ActionError(
                "Unable to verify location: " + self.code + "\n" + str(e)
            )

        return location
示例#8
0
 def setUp(self):
     """Get a new location object for each test."""
     self.location = Location.get(TEST_LOCATION)
示例#9
0
 def location(self):
     """:returns: Location that owns this version."""
     return Location.get(self.location_code)
示例#10
0
 def location(self):
     return Location.get(self.location_code)
示例#11
0
 def location(self):
     """:returns: Location that owns this version."""
     return Location.get(self.location_code)
示例#12
0
    def validate(self):

        # ---- make sure the supplied specs match actual ptasks,
        #      set the properties

        try:
            self._source = PTask.get(self.source)
        except PTaskError:
            raise ActionError(
                "Unable to retrieve ptask from source argument: " + \
                    str(self.source)
            )

        try:
            self._destination = PTask.get(self.destination)
        except PTaskError:
            raise ActinError(
                "Unable to retrieve ptask from destination argument: " + \
                    str(self.destination),
                self,
            )

        self._source_latest_version = self.source.latest_version
        self._destination_latest_version = self.destination.latest_version

        # ---- make sure the ptasks are of the same type

        #if self.source.type != self.destination.type:
        #    raise ActionError(
        #        "Source and destination ptasks must be of the same type. " + \
        #            self.source.type + " != " + self.destination.type
        #    )

        # ---- if the target_type is not ptask, then the calling code has
        #      overridden the target type. make sure the source and destination
        #      types match the target type.

        target_type = self.__class__.target_type
        if target_type != "ptask":
            if self.source.type.lower() != target_type:
                raise ActionError("Source type must be a " + target_type)
            elif self.destination.type.lower() != target_type:
                raise ActionError("Destination type must a " + target_type)

        # ---- determine the source and destination versions and their locations

        if self.source_version:
            try:
                self._source_version = _get_ptask_version(
                    self.source,
                    self.source_version,
                )
            except TypeError as e:
                raise ActionError(str(e))

            source_location_code = self.source_version.location_code
        else:
            source_location_code = self.source_latest_version.location_code

        if self.destination_version:
            try:
                self._destination_version = _get_ptask_version(
                    self.destination, 
                    self.destination_version,
                )
            except TypeError as e:
                raise ActionError(str(e))

            destination_location_code = self.destination_version.location_code
        else:
            destination_location_code = \
                self.destination_latest_version.location_code

        # one of source or dest must be the current loation, unless the source
        # and destination are the same ptask. In that case, we'll assume the
        # goal is to sync the ptask to the current location or to source 
        # directories/versions within the ptask

        cur_loc_code = current_location_code()

        if self.source == self.destination:
            location_override = Location.current()
        else:
            if (source_location_code != cur_loc_code and 
                destination_location_code != cur_loc_code):
                raise ActionError(
                    "One of source or destination must be this location.",
                )
            location_override = None

        # ---- determine the source and desination paths

        self._source_path = self._get_path(
            ptask=self.source, 
            version=self.source_version, 
            latest_version=self.source_latest_version,
            directory=self.source_directory,
        )

        self._destination_path = self._get_path(
            ptask=self.destination, 
            version=self.destination_version, 
            latest_version=self.destination_latest_version,
            directory=self.destination_directory,
            location_override=location_override,
        )

        # ---- get the includes/excludes based on filter rules

        (includes, excludes) = self._get_filter_rules(self.destination)

        # exclude child ptask directories from the source
        for child in self.source.children:
            child_dir = os.path.sep + child.name
            excludes.append(child_dir)

        self._includes = includes
        self._excludes = excludes
示例#13
0
 def setUp(self):
     """Get a new location object for each test."""
     self.location = Location.get(TEST_LOCATION)
示例#14
0
 def location(self):
     return Location.get(self.location_code)
示例#15
0
 def creation_location(self):
     return Location.get(self.creation_location_code)
示例#16
0
文件: sync.py 项目: liudger/dpa-pipe
    def validate(self):

        # ---- make sure the supplied specs match actual ptasks,
        #      set the properties

        try:
            self._source = PTask.get(self.source)
        except PTaskError:
            raise ActionError(
                "Unable to retrieve ptask from source argument: " + \
                    str(self.source)
            )

        try:
            self._destination = PTask.get(self.destination)
        except PTaskError:
            raise ActinError(
                "Unable to retrieve ptask from destination argument: " + \
                    str(self.destination),
                self,
            )

        self._source_latest_version = self.source.latest_version
        self._destination_latest_version = self.destination.latest_version

        # ---- make sure the ptasks are of the same type

        #if self.source.type != self.destination.type:
        #    raise ActionError(
        #        "Source and destination ptasks must be of the same type. " + \
        #            self.source.type + " != " + self.destination.type
        #    )

        # ---- if the target_type is not ptask, then the calling code has
        #      overridden the target type. make sure the source and destination
        #      types match the target type.

        target_type = self.__class__.target_type
        if target_type != "ptask":
            if self.source.type.lower() != target_type:
                raise ActionError("Source type must be a " + target_type)
            elif self.destination.type.lower() != target_type:
                raise ActionError("Destination type must a " + target_type)

        # ---- determine the source and destination versions and their locations

        if self.source_version:
            try:
                self._source_version = _get_ptask_version(
                    self.source,
                    self.source_version,
                )
            except TypeError as e:
                raise ActionError(str(e))

            source_location_code = self.source_version.location_code
        else:
            source_location_code = self.source_latest_version.location_code

        if self.destination_version:
            try:
                self._destination_version = _get_ptask_version(
                    self.destination, 
                    self.destination_version,
                )
            except TypeError as e:
                raise ActionError(str(e))

            destination_location_code = self.destination_version.location_code
        else:
            destination_location_code = \
                self.destination_latest_version.location_code

        # one of source or dest must be the current loation, unless the source
        # and destination are the same ptask. In that case, we'll assume the
        # goal is to sync the ptask to the current location or to source 
        # directories/versions within the ptask

        cur_loc_code = current_location_code()

        if self.source == self.destination:
            location_override = Location.current()
        else:
            if (source_location_code != cur_loc_code and 
                destination_location_code != cur_loc_code):
                raise ActionError(
                    "One of source or destination must be this location.",
                )
            location_override = None

        # ---- determine the source and desination paths

        self._source_path = self._get_path(
            ptask=self.source, 
            version=self.source_version, 
            latest_version=self.source_latest_version,
            directory=self.source_directory,
        )

        self._destination_path = self._get_path(
            ptask=self.destination, 
            version=self.destination_version, 
            latest_version=self.destination_latest_version,
            directory=self.destination_directory,
            location_override=location_override,
        )

        # ---- get the includes/excludes based on filter rules

        (includes, excludes) = self._get_filter_rules(self.destination)

        # exclude child ptask directories from the source
        for child in self.source.children:
            child_dir = os.path.sep + child.name
            excludes.append(child_dir)

        self._includes = includes
        self._excludes = excludes