Ejemplo n.º 1
0
 def synchronize(self, path):
     """
     compare files on didel with file in folder,
         and calling download add or reset files'user
         only if not exist or older
     """
     path = "%s/%s" % (path, self.ref)
     mkdir_p(path)
     for k, resource in self._resources.items():
         if isinstance(resource, CourseDocuments):
             resource.synchronize("%s/%s" % (path, k))
         else:
             no_file = not os.path.exists("%s/%s" % (path, k))
             didel_time = date2timestamp(resource.date)
             if no_file or didel_time > file_mtime("%s/%s" % (path, k)):
                 self.download(resource, path)
Ejemplo n.º 2
0
 def synchronize(self, path):
     """
     compare files on didel with file in folder,
         and calling download add or reset files'user
         only if not exist or older
     """
     path = "%s/%s" % (path, self.ref)
     mkdir_p(path)
     for k, resource in self._resources.items():
         if isinstance(resource, CourseDocuments):
             resource.synchronize("%s/%s" % (path, k))
         else:
             no_file = not os.path.exists("%s/%s" % (path, k))
             didel_time = date2timestamp(resource.date)
             if no_file or didel_time > file_mtime("%s/%s" % (path, k)):
                 self.download(resource, path)
Ejemplo n.º 3
0
 def test_date2timestamp_good_date(self):
     d1 = date2timestamp("29.01.2015", 43)
     d2 = date2timestamp("28.02.2015", 42)
     self.assertLess(d1, d2)
Ejemplo n.º 4
0
 def test_date2timestamp_good_format_bad_date_42(self):
     self.assertEquals(42, date2timestamp("31.02.2014", 42))
Ejemplo n.º 5
0
 def test_date2timestamp_good_format_bad_date(self):
     self.assertEquals(0, date2timestamp("31.02.2014", 0))
Ejemplo n.º 6
0
 def test_date2timestamp_wrong_format_default_0(self):
     self.assertEquals(0, date2timestamp("", 0))
     self.assertEquals(0, date2timestamp("some text", 0))
     self.assertEquals(0, date2timestamp("3.14", 0))
Ejemplo n.º 7
0
 def test_date2timestamp_good_date(self):
     d1 = date2timestamp("29.01.2015", 43)
     d2 = date2timestamp("28.02.2015", 42)
     self.assertLess(d1, d2)
Ejemplo n.º 8
0
 def test_date2timestamp_good_format_bad_date_42(self):
     self.assertEquals(42, date2timestamp("31.02.2014", 42))
Ejemplo n.º 9
0
 def test_date2timestamp_good_format_bad_date(self):
     self.assertEquals(0, date2timestamp("31.02.2014", 0))
Ejemplo n.º 10
0
 def test_date2timestamp_wrong_format_default_0(self):
     self.assertEquals(0, date2timestamp("", 0))
     self.assertEquals(0, date2timestamp("some text", 0))
     self.assertEquals(0, date2timestamp("3.14", 0))