示例#1
0
    def test_remove_line(self):
      crontab = Crontab()
      linea = u'linea de prueba'
      not_erased_line = 'linea no borrada'

      crontab.add_line(linea)

      comando = ['sudo', 'grep', linea, crontab.get_crontab()]
      with open(os.devnull,'w') as fnull:
        self.assertEqual(0,subprocess.call(comando, stdout=fnull))

      crontab.add_line(not_erased_line)

      comando = ['sudo', 'grep', not_erased_line, crontab.get_crontab()]
      with open(os.devnull,'w') as fnull:
        self.assertEqual(0,subprocess.call(comando, stdout=fnull))

      crontab.remove_line(linea)

      comando = ['sudo', 'grep', linea, crontab.get_crontab()]
      with open(os.devnull,'w') as fnull:
        self.assertNotEqual(0,subprocess.call(comando, stdout=fnull))

      """
      Is verified that was not erased the line that has not to be deleted.
      """
      comando = ['sudo', 'grep', not_erased_line, crontab.get_crontab()]
      with open(os.devnull,'w') as fnull:
        self.assertEqual(0,subprocess.call(comando, stdout=fnull))

      crontab.remove_line(not_erased_line)
示例#2
0
    def test_remove_line(self):
        crontab = Crontab()
        linea = u'linea de prueba'
        not_erased_line = 'linea no borrada'

        crontab.add_line(linea)

        comando = ['sudo', 'grep', linea, crontab.get_crontab()]
        with open(os.devnull, 'w') as fnull:
            self.assertEqual(0, subprocess.call(comando, stdout=fnull))

        crontab.add_line(not_erased_line)

        comando = ['sudo', 'grep', not_erased_line, crontab.get_crontab()]
        with open(os.devnull, 'w') as fnull:
            self.assertEqual(0, subprocess.call(comando, stdout=fnull))

        crontab.remove_line(linea)

        comando = ['sudo', 'grep', linea, crontab.get_crontab()]
        with open(os.devnull, 'w') as fnull:
            self.assertNotEqual(0, subprocess.call(comando, stdout=fnull))
        """
      Is verified that was not erased the line that has not to be deleted.
      """
        comando = ['sudo', 'grep', not_erased_line, crontab.get_crontab()]
        with open(os.devnull, 'w') as fnull:
            self.assertEqual(0, subprocess.call(comando, stdout=fnull))

        crontab.remove_line(not_erased_line)
示例#3
0
 def add_domain_update_to_crontab(self,
                                  domain,
                                  user,
                                  ddns_log_file='/dev/null'):
     line = "*/30 * * * * wget -O - '%s?host=%s&api_key=%s' >> %s" % (
         self.__base_url_service, domain, self.__api_key, ddns_log_file)
     from iampacks.cross.crontab.models import Crontab
     crontab = Crontab(user=user)
     crontab.add_line(line)
示例#4
0
    def test_add_line(self):
      crontab = Crontab()
      linea = u'linea de prueba'
      crontab.add_line(linea)
      comando = ['sudo', 'grep', linea, crontab.get_crontab()]
      with open(os.devnull,'w') as fnull:
        self.assertEqual(0,subprocess.call(comando, stdout=fnull))

      crontab.remove_line(linea)
示例#5
0
    def test_add_line(self):
        crontab = Crontab()
        linea = u'linea de prueba'
        crontab.add_line(linea)
        comando = ['sudo', 'grep', linea, crontab.get_crontab()]
        with open(os.devnull, 'w') as fnull:
            self.assertEqual(0, subprocess.call(comando, stdout=fnull))

        crontab.remove_line(linea)
示例#6
0
 def add_domain_update_to_crontab(self,domain,user,ddns_log_file='/dev/null'):
   line = "*/30 * * * * wget -O - '%s?host=%s&api_key=%s' >> %s"%(self.__base_url_service, domain, self.__api_key, ddns_log_file)
   from iampacks.cross.crontab.models import Crontab
   crontab = Crontab(user=user)
   crontab.add_line(line)