Ejemplo n.º 1
0
 def test14_remove_folder(self):
     # Create hierarchy
     vfs.make_folder('tests/folder')
     vfs.make_folder('tests/folder/a')
     vfs.make_file('tests/folder/a/hello.txt')
     # Remove and test
     vfs.remove('tests/folder')
     self.assertEqual(vfs.exists('tests/folder'), False)
Ejemplo n.º 2
0
 def test14_remove_folder(self):
     # Create hierarchy
     vfs.make_folder('tests/folder')
     vfs.make_folder('tests/folder/a')
     vfs.make_file('tests/folder/a/hello.txt')
     # Remove and test
     vfs.remove('tests/folder')
     self.assertEqual(vfs.exists('tests/folder'), False)
Ejemplo n.º 3
0
 def test20_append(self):
     # Initialize
     file = vfs.make_file('tests/toto.txt')
     try:
         file.write('hello\n')
     finally:
         file.close()
     # Test
     file = vfs.open('tests/toto.txt', APPEND)
     try:
         file.write('bye\n')
     finally:
         file.close()
     self.assertEqual(open('tests/toto.txt').read(), 'hello\nbye\n')
     # Remove temporary file
     vfs.remove('tests/toto.txt')
Ejemplo n.º 4
0
 def test21_write_and_truncate(self):
     # Initialize
     file = vfs.make_file('tests/toto.txt')
     try:
         file.write('hello\n')
     finally:
         file.close()
     # Test
     file = vfs.open('tests/toto.txt', WRITE)
     try:
         file.write('bye\n')
     finally:
         file.close()
     self.assertEqual(open('tests/toto.txt').read(), 'bye\n')
     # Remove temporary file
     vfs.remove('tests/toto.txt')
Ejemplo n.º 5
0
 def test20_append(self):
     # Initialize
     file = vfs.make_file('tests/toto.txt')
     try:
         file.write('hello\n')
     finally:
         file.close()
     # Test
     file = vfs.open('tests/toto.txt', APPEND)
     try:
         file.write('bye\n')
     finally:
         file.close()
     self.assertEqual(open('tests/toto.txt').read(), 'hello\nbye\n')
     # Remove temporary file
     vfs.remove('tests/toto.txt')
Ejemplo n.º 6
0
 def test21_write_and_truncate(self):
     # Initialize
     file = vfs.make_file('tests/toto.txt')
     try:
         file.write('hello\n')
     finally:
         file.close()
     # Test
     file = vfs.open('tests/toto.txt', WRITE)
     try:
         file.write('bye\n')
     finally:
         file.close()
     self.assertEqual(open('tests/toto.txt').read(), 'bye\n')
     # Remove temporary file
     vfs.remove('tests/toto.txt')
Ejemplo n.º 7
0
    def GET(self, resource, context):
        items = self.get_items(resource, context)
        issues = self.sort_and_batch(resource, context, items)
        # Get path of all attachment to add in zip
        dirname = '%s/zip' % mkdtemp('zip', 'ikaaro')
        zip = ZipFile(dirname, 'w')
        for issue in issues:
            attachment_name = issue.issue_last_attachment
            attachment = resource.get_resource('%s/%s' % (issue.name, attachment_name))
            attachment_uri = attachment.handler.uri[7:]
            # Get extension
            mimetype = attachment.get_content_type()
            ext = guess_extension(mimetype)[1:]
            #attachment_name = 'issue_%s_%s' % (issue.name, get_uri_name(attachment_uri))
            attachment_name = '%s_%s.%s' % (issue.name, issue.title, ext) 
            #print attachment_name, attachment_uri
            zip.write(attachment_uri, attachment_name)
        zip.close()
        # Create zip
        # Build zipname
        name = "LastAttachedImages"
        now = strftime("%y%d%m%H%M")
        #pprint("%s" % now)
        zipname = "%s_%s_%s.zip" % (resource.name, name, now)
        
        file = open(dirname)
        try:
            data = file.read()
        finally:
            file.close()
        
        vfs.remove(dirname)

        # Return the zip
        response = context.response
        response.set_header('Content-Type', 'application/zip')
        response.set_header('Content-Disposition',
                'attachment; filename=%s' % zipname)
        return data
Ejemplo n.º 8
0
 def test18_get_names(self):
     self.assertEqual('hello.txt.old' in vfs.get_names('tests'), True)
     # Remove temporary file
     vfs.remove('tests/hello.txt.old')
Ejemplo n.º 9
0
 def test13_remove_empty_folder(self):
     vfs.remove('tests/folder')
     self.assertEqual(vfs.exists('tests/folder'), False)
Ejemplo n.º 10
0
 def test12_remove_file(self):
     vfs.remove('tests/file')
     self.assertEqual(vfs.exists('tests/file'), False)
Ejemplo n.º 11
0
 def test13_remove_empty_folder(self):
     vfs.remove('tests/folder')
     self.assertEqual(vfs.exists('tests/folder'), False)
Ejemplo n.º 12
0
 def tearDown(self):
     if vfs.exists('tmp'):
         vfs.remove('tmp')
Ejemplo n.º 13
0
 def test12_remove_file(self):
     vfs.remove('tests/file')
     self.assertEqual(vfs.exists('tests/file'), False)
Ejemplo n.º 14
0
 def tearDown(self):
     if vfs.exists('tmp'):
         vfs.remove('tmp')
Ejemplo n.º 15
0
 def tearDown(self):
     if vfs.exists('tests/toto.txt'):
         vfs.remove('tests/toto.txt')
Ejemplo n.º 16
0
 def test18_get_names(self):
     self.assertEqual('hello.txt.old' in vfs.get_names('tests'), True)
     # Remove temporary file
     vfs.remove('tests/hello.txt.old')
Ejemplo n.º 17
0
 def tearDown(self):
     if vfs.exists('tests/toto.txt'):
         vfs.remove('tests/toto.txt')
Ejemplo n.º 18
0
    def safe_remove(self, reference):
        if self.database is None:
            return vfs.remove(reference)

        return self.database.safe_remove(reference)
Ejemplo n.º 19
0
 def tearDown(self):
     if vfs.exists('sandbox'):
         vfs.remove('sandbox')
Ejemplo n.º 20
0
 def tearDown(self):
     if vfs.exists('sandbox'):
         vfs.remove('sandbox')