Esempio n. 1
0
    def _run_task(self):
        # Check that path exists
        if not os.path.isdir(self.options['path']):
            raise TaskOptionsError(
                'The path {} does not exist or is not a directory'.format(
                    self.options['path'], ))

        # Check that revert_path does not exist
        if os.path.exists(self.options['revert_path']):
            raise TaskOptionsError(
                'The revert_path {} already exists.  Delete it and try again'.
                format(self.options['revert_path'], ))

        # Copy path to revert_path
        copy_tree(self.options['path'], self.options['revert_path'])

        # Edit metadata in path
        self.logger.info(
            'Removing the string {0} from {1}/classes and {1}/triggers'.format(
                self.managed_token,
                self.options['path'],
            ))
        findReplace(self.managed_token, '',
                    os.path.join(self.options['path'], 'classes'), '*.cls',
                    self.logger)
        findReplace(self.managed_token, '',
                    os.path.join(self.options['path'], 'triggers'),
                    '*.trigger', self.logger)

        self.logger.info(
            '{} has been stripped from all classes and triggers in {}'.format(
                self.managed_token,
                self.options['path'],
            ))
Esempio n. 2
0
 def _set_record_type(self, name, default):
     rt = rt_visibility_template.format(default, name)
     findReplace(
         '<tabVisibilities>',
         '{}<tabVisibilities>'.format(rt),
         os.path.join(self.tempdir, 'profiles'),
         'Admin.profile',
         max=1,
     )
Esempio n. 3
0
 def _set_record_type(self, name, default):
     rt = rt_visibility_template.format(default, name)
     findReplace(
         "<tabVisibilities>",
         "{}<tabVisibilities>".format(rt),
         Path(self.retrieve_dir, "profiles"),
         "Admin.profile",
         max=1,
     )
Esempio n. 4
0
 def _set_record_type(self, name, default):
     rt = rt_visibility_template.format(default, name)
     findReplace(
         '<tabVisibilities>',
         '{}<tabVisibilities>'.format(rt),
         os.path.join(self.tempdir, 'profiles'),
         'Admin.profile',
         max=1,
     )
Esempio n. 5
0
 def _run_task(self):
     kwargs = {}
     if "max" in self.options:
         kwargs["max"] = self.options["max"]
     findReplace(find=self.options["find"],
                 replace=self.options["replace"],
                 directory=self.options["path"],
                 filePattern=self.options["file_pattern"],
                 logger=self.logger,
                 **kwargs)
Esempio n. 6
0
 def _run_task(self):
     kwargs = {}
     if 'max' in self.options:
         kwargs['max'] = self.options['max']
     findReplace(
         find=self.options['find'],
         replace=self.options['replace'],
         directory=self.options['path'],
         filePattern=self.options['file_pattern'],
         logger=self.logger,
         **kwargs
     )
    def test_findReplace_max(self):
        with utils.temporary_dir() as d:
            path = os.path.join(d, "test")
            with open(path, "w") as f:
                f.write("aa")

            logger = mock.Mock()
            utils.findReplace("a", "b", d, "*", logger, max=1)

            logger.info.assert_called_once()
            with open(path, "r") as f:
                result = f.read()
            self.assertEqual(result, "ba")
Esempio n. 8
0
    def test_findReplace_max(self):
        with utils.temporary_dir() as d:
            path = os.path.join(d, "test")
            with open(path, "w") as f:
                f.write("aa")

            logger = mock.Mock()
            utils.findReplace("a", "b", d, "*", logger, max=1)

            logger.info.assert_called_once()
            with open(path, "r") as f:
                result = f.read()
            self.assertEqual(result, "ba")
Esempio n. 9
0
    def test_findReplace_max(self):
        with temporary_dir() as d:
            path = os.path.join(d, 'test')
            with open(path, 'w') as f:
                f.write('aa')

            logger = mock.Mock()
            utils.findReplace('a', 'b', d, '*', logger, max=1)

            logger.info.assert_called_once()
            with open(path, 'r') as f:
                result = f.read()
            self.assertEqual(result, 'ba')
Esempio n. 10
0
    def _process_metadata(self):
        self.logger.info('Processing retrieved metadata in {}'.format(
            self.tempdir))

        findReplace(
            '<editable>false</editable>',
            '<editable>true</editable>',
            os.path.join(self.tempdir, 'profiles'),
            'Admin.profile',
        )
        findReplace(
            '<readable>false</readable>',
            '<readable>true</readable>',
            os.path.join(self.tempdir, 'profiles'),
            'Admin.profile',
        )
Esempio n. 11
0
    def _process_metadata(self):
        self.logger.info("Processing retrieved metadata in {}".format(
            self.tempdir))

        findReplace(
            "<editable>false</editable>",
            "<editable>true</editable>",
            os.path.join(self.tempdir, "profiles"),
            "Admin.profile",
        )
        findReplace(
            "<readable>false</readable>",
            "<readable>true</readable>",
            os.path.join(self.tempdir, "profiles"),
            "Admin.profile",
        )
Esempio n. 12
0
    def _run_task(self):
        # Check that path exists
        if not os.path.isdir(self.options['path']):
            raise TaskOptionsError(
                'The path {} does not exist or is not a directory'.format(
                    self.options['path'],
                )
            )

        # Check that revert_path does not exist
        if os.path.exists(self.options['revert_path']):
            raise TaskOptionsError(
                'The revert_path {} already exists.  Delete it and try again'.format(
                    self.options['revert_path'],
                )
            )

        # Copy path to revert_path
        copy_tree(self.options['path'], self.options['revert_path'])

        # Edit metadata in path
        self.logger.info('Removing the string {0} from {1}/classes and {1}/triggers'.format(
            self.managed_token,
            self.options['path'],
        ))
        findReplace(
            self.managed_token,
            '',
            os.path.join(self.options['path'], 'classes'),
            '*.cls',
            self.logger
        )
        findReplace(
            self.managed_token,
            '',
            os.path.join(self.options['path'], 'triggers'),
            '*.trigger',
            self.logger
        )
    
        self.logger.info('{} has been stripped from all classes and triggers in {}'.format(
            self.managed_token,
            self.options['path'],
        ))
Esempio n. 13
0
    def _run_task(self):
        # Check that path exists
        if not os.path.isdir(self.options["path"]):
            raise TaskOptionsError(
                "The path {} does not exist or is not a directory".format(
                    self.options["path"]))

        # Check that revert_path does not exist
        if os.path.exists(self.options["revert_path"]):
            raise TaskOptionsError(
                "The revert_path {} already exists.  Delete it and try again".
                format(self.options["revert_path"]))

        # Copy path to revert_path
        copy_tree(self.options["path"], self.options["revert_path"])

        # Edit metadata in path
        self.logger.info(
            "Removing the string {0} from {1}/classes and {1}/triggers".format(
                self.managed_token, self.options["path"]))
        findReplace(
            self.managed_token,
            "",
            os.path.join(self.options["path"], "classes"),
            "*.cls",
            self.logger,
        )
        findReplace(
            self.managed_token,
            "",
            os.path.join(self.options["path"], "triggers"),
            "*.trigger",
            self.logger,
        )

        self.logger.info(
            "{} has been stripped from all classes and triggers in {}".format(
                self.managed_token, self.options["path"]))