예제 #1
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)
예제 #2
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)
예제 #3
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)
예제 #4
0
 def remove_domain_update_from_crontab(self, domain, user):
     line = '%s?host=%s&api_key=%s' % (self.__base_url_service, domain,
                                       self.__api_key)
     from iampacks.cross.crontab.models import Crontab
     crontab = Crontab(user=user)
     crontab.remove_line(line)
예제 #5
0
 def remove_domain_update_from_crontab(self,domain,user):
   line = '%s?host=%s&api_key=%s'%(self.__base_url_service, domain,self.__api_key)
   from iampacks.cross.crontab.models import Crontab
   crontab = Crontab(user=user)
   crontab.remove_line(line)
예제 #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)
예제 #7
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)
예제 #8
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)