<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_permissions( self, owner, file_perms=PERMS_FILE_DEFAULT, dir_perms=PERMS_DIR_DEFAULT, use_sudo=True):
 """Set the owner and permissions of the code deploy. The owner will be set recursively for the entire code deploy. The directory permissions will be set on only the base of the code deploy and the releases directory. The file permissions will be set recursively for the entire code deploy. If not specified default values will be used for file or directory permissions. By default the Fabric ``sudo`` function will be used for changing the owner and permissions of the code deploy. Optionally, you can pass the ``use_sudo=False`` argument to skip trying to change the owner of the code deploy and to use the ``run`` function to change permissions. This method performs between three and four network operations depending on if ``use_sudo`` is false or true, respectively. :param str owner: User and group in the form 'owner:group' to set for the code deploy. :param str file_perms: Permissions to set for all files in the code deploy in the form 'u+perms,g+perms,o+perms'. Default is ``u+rw,g+rw,o+r``. :param str dir_perms: Permissions to set for the base and releases directories in the form 'u+perms,g+perms,o+perms'. Default is ``u+rwx,g+rws,o+rx``. :param bool use_sudo: If ``True``, use ``sudo()`` to change ownership and permissions of the code deploy. If ``False`` try to change permissions using the ``run()`` command, do not change ownership. .. versionchanged:: 0.2.0 ``use_sudo=False`` will no longer attempt to change ownership of the code deploy since this will just be a no-op or fail. """

        runner = self._runner.sudo if use_sudo else self._runner.run

        if use_sudo:
            runner("chown -R '{0}' '{1}'".format(owner, self._base))

        for path in (self._base, self._releases):
            runner("chmod '{0}' '{1}'".format(dir_perms, path))

        runner("chmod -R '{0}' '{1}'".format(file_perms, self._base))