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)
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)
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)
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)
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)
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)
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)
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)