def _create_temporary_destination_directory(destination, mode=0755):
        """
        Create the temporary destination directory as a peer of the target destination.
        This is so that the move is hopefully taking place on the same filesystem so it
        will be as fast as possible.

        :param destination: absolute path to the destination where modules should
                            be installed
        :type  destination: str
        :param mode: the directory permissions
        :type  mode: int
        :return: absolute path to temporary created directory
        :rtype: str
        """
        basedir = get_parent_directory(destination)
        try:
            os.makedirs(basedir, mode)
        except OSError, e:
            if e.errno == errno.EEXIST and os.path.isdir(basedir):
                pass  # ignored
            else:
                raise e
    def _create_temporary_destination_directory(destination, mode=0755):
        """
        Create the temporary destination directory as a peer of the target destination.
        This is so that the move is hopefully taking place on the same filesystem so it
        will be as fast as possible.

        :param destination: absolute path to the destination where modules should be installed
        :type destination: str
        :param mode: the directory permissions
        :type mode: int

        :return: absolute path to temporary created directory
        :rtype: str
        """
        basedir = get_parent_directory(destination)
        try:
            os.makedirs(basedir, mode)
        except OSError, e:
            if e.errno == errno.EEXIST and os.path.isdir(basedir):
                pass
            else:
                raise
Beispiel #3
0
 def test_absolute_path_does_not_end_in_slash(self):
     path = '/an/absolute/path'
     parent_dir = '/an/absolute'
     result = misc.get_parent_directory(path)
     self.assertEqual(result, parent_dir)
Beispiel #4
0
 def test_relative_path_does_not_end_in_slash(self):
     path = 'a/relative/path'
     parent_dir = 'a/relative'
     result = misc.get_parent_directory(path)
     self.assertEqual(result, parent_dir)
Beispiel #5
0
 def test_absolute_path_does_not_end_in_slash(self):
     path = "/an/absolute/path"
     parent_dir = "/an/absolute"
     result = misc.get_parent_directory(path)
     self.assertEqual(result, parent_dir)
Beispiel #6
0
 def test_relative_path_does_not_end_in_slash(self):
     path = "a/relative/path"
     parent_dir = "a/relative"
     result = misc.get_parent_directory(path)
     self.assertEqual(result, parent_dir)
Beispiel #7
0
 def test_absolute_path_ends_in_slash(self):
     path = '/an/absolute/path/'
     parent_dir = '/an/absolute'
     result = misc.get_parent_directory(path)
     self.assertEqual(result, parent_dir)
Beispiel #8
0
 def test_relative_path_ends_in_slash(self):
     path = 'a/relative/path/'
     parent_dir = 'a/relative'
     result = misc.get_parent_directory(path)
     self.assertEqual(result, parent_dir)