(self, action, content)
The inside method used to modify the current crontab cronfile.
        This will write the content into current crontab cronfile.

        :param action: the action that is done, could be written, updated or
                       cleared.
        :param content: the content that is written to the crontab cronfile.
The inside method used to modify the current crontab cronfile.
        This will write the content into current crontab cronfile.
The inside method used to modify the current crontab cronfile . This will write the content into current crontab cronfile .
def _write_to_crontab(self, action, content):
        """The inside method used to modify the current crontab cronfile.
        This will write the content into current crontab cronfile.

        :param action: the action that is done, could be written, updated or
                       cleared.
        :param content: the content that is written to the crontab cronfile.
        """
        # make sure at most 3 '\n' in a row
        content = re.sub(r'\n{4,}', r'\n\n\n', content)
        # strip
        content = content.strip()
        if content:
            content += "\n"

        tmp_cronfile = tempfile.NamedTemporaryFile()
        tmp_cronfile.write(get_binary_content(content))
        tmp_cronfile.flush()

        # command used to write crontab
        # $ crontab -u username cronfile
        command = ['crontab']
        if self.user:
            command.extend(["-u", str(self.user)])
        command.append(tmp_cronfile.name)

        try:
            output, error, returncode = communicate_process(command)
            if returncode != 0:
                raise PlanError("couldn't write crontab; try running check to "
                                "ensure your cronfile is valid.")
        except OSError:
            raise PlanError("couldn't write crontab; please make sure you "
                            "have crontab installed")
        else:
            if action:
                Echo.write("crontab file %s" % action)
        finally:
            tmp_cronfile.close()
def _write_to_crontab ( self , action , content ) : # make sure at most 3 '\n' in a row content = re . sub ( r'\n{4,}' , r'\n\n\n' , content ) # strip content = content . strip ( ) if content : content += "\n" tmp_cronfile = tempfile . NamedTemporaryFile ( ) tmp_cronfile . write ( get_binary_content ( content ) ) tmp_cronfile . flush ( ) # command used to write crontab # $ crontab -u username cronfile command = [ 'crontab' ] if self . user : command . extend ( [ "-u" , str ( self . user ) ] ) command . append ( tmp_cronfile . name ) try : output , error , returncode = communicate_process ( command ) if returncode != 0 : raise PlanError ( "couldn't write crontab; try running check to " "ensure your cronfile is valid." ) except OSError : raise PlanError ( "couldn't write crontab; please make sure you " "have crontab installed" ) else : if action : Echo . write ( "crontab file %s" % action ) finally : tmp_cronfile . close ( )