diff options
| -rw-r--r-- | CHANGELOG | 7 | ||||
| -rw-r--r-- | RELEASE | 6 | ||||
| -rw-r--r-- | TODO | 12 | ||||
| -rwxr-xr-x | mat-cli | 4 | ||||
| -rw-r--r-- | mat/mat.py | 16 | ||||
| -rw-r--r-- | test/clitest.py | 25 | ||||
| -rw-r--r-- | test/libtest.py | 16 |
7 files changed, 72 insertions, 14 deletions
| @@ -1,2 +1,9 @@ | |||
| 1 | 0.2 - 21dec2011 | ||
| 2 | * Improvements for testsuites | ||
| 3 | * Improve log system | ||
| 4 | * Handle file with weird rights | ||
| 5 | * Drag'n'drop support | ||
| 6 | * Various bugfixes | ||
| 7 | |||
| 1 | 0.1 - 30oct2011 | 8 | 0.1 - 30oct2011 |
| 2 | * initial version | 9 | * initial version |
| @@ -1,3 +1,9 @@ | |||
| 1 | update changelog: | ||
| 2 | git log | ||
| 3 | |||
| 4 | create a tag | ||
| 5 | git tag -s $VERSION | ||
| 6 | |||
| 1 | archive's creation : | 7 | archive's creation : |
| 2 | git archive --format=tar.gz --prefix=mat-$VERSION/ $VERSION > mat-$VERSION.tar.gz | 8 | git archive --format=tar.gz --prefix=mat-$VERSION/ $VERSION > mat-$VERSION.tar.gz |
| 3 | 9 | ||
| @@ -5,18 +5,14 @@ GENERAL: | |||
| 5 | - Fix the ugly function get_sharedir | 5 | - Fix the ugly function get_sharedir |
| 6 | - Modify creation/modification date | 6 | - Modify creation/modification date |
| 7 | (except for stupid formats like zip) | 7 | (except for stupid formats like zip) |
| 8 | - better log management | ||
| 9 | - cleaning a file (mat-gui) in a directory where you have no write | ||
| 10 | permission : pretend a cleaned file was created which is wrong ! | ||
| 11 | |||
| 12 | TESTSUITE: | ||
| 13 | - return code ? | ||
| 14 | 8 | ||
| 15 | GUI: | 9 | GUI: |
| 16 | - display harmrful meta per file | 10 | - display harmrful meta per file |
| 17 | - drag'n'drop does not work with filenames containing spaces | ||
| 18 | 11 | ||
| 19 | FORMATS | 12 | FORMATS: |
| 20 | - microsoft office < 2007 (ugly and insane) | 13 | - microsoft office < 2007 (ugly and insane) |
| 21 | - fix zip (fix python's ziplib) | 14 | - fix zip (fix python's ziplib) |
| 22 | - videos format ? | 15 | - videos format ? |
| 16 | |||
| 17 | MISC: | ||
| 18 | - a nautilus extension (right-clic -> clean with MAT) | ||
| @@ -149,8 +149,10 @@ def main(): | |||
| 149 | for filename in filenames: | 149 | for filename in filenames: |
| 150 | class_file = mat.create_class_file(filename, args.backup, | 150 | class_file = mat.create_class_file(filename, args.backup, |
| 151 | args.add2archive) | 151 | args.add2archive) |
| 152 | if class_file is not None: | 152 | if class_file is not False: |
| 153 | func(class_file, filename, args.force) | 153 | func(class_file, filename, args.force) |
| 154 | else: | ||
| 155 | print('Unable to process %s' % filename) | ||
| 154 | 156 | ||
| 155 | if __name__ == '__main__': | 157 | if __name__ == '__main__': |
| 156 | main() | 158 | main() |
| @@ -108,7 +108,17 @@ def create_class_file(name, backup, add2archive): | |||
| 108 | if not os.path.isfile(name): | 108 | if not os.path.isfile(name): |
| 109 | # check if the file exists | 109 | # check if the file exists |
| 110 | logging.error('%s is not a valid file' % name) | 110 | logging.error('%s is not a valid file' % name) |
| 111 | return | 111 | return False |
| 112 | |||
| 113 | if not os.access(name, os.R_OK): | ||
| 114 | #check read permissions | ||
| 115 | logging.error('%s is is not readable' % name) | ||
| 116 | return False | ||
| 117 | |||
| 118 | if not os.access(name, os.W_OK): | ||
| 119 | #check write permission | ||
| 120 | logging.error('%s is not writtable' % name) | ||
| 121 | return False | ||
| 112 | 122 | ||
| 113 | filename = '' | 123 | filename = '' |
| 114 | try: | 124 | try: |
| @@ -119,7 +129,7 @@ def create_class_file(name, backup, add2archive): | |||
| 119 | parser = hachoir_parser.createParser(filename) | 129 | parser = hachoir_parser.createParser(filename) |
| 120 | if not parser: | 130 | if not parser: |
| 121 | logging.info('Unable to parse %s' % filename) | 131 | logging.info('Unable to parse %s' % filename) |
| 122 | return | 132 | return False |
| 123 | 133 | ||
| 124 | mime = parser.mime_type | 134 | mime = parser.mime_type |
| 125 | 135 | ||
| @@ -135,6 +145,6 @@ def create_class_file(name, backup, add2archive): | |||
| 135 | stripper_class = strippers.STRIPPERS[mime] | 145 | stripper_class = strippers.STRIPPERS[mime] |
| 136 | except KeyError: | 146 | except KeyError: |
| 137 | logging.info('Don\'t have stripper for %s format' % mime) | 147 | logging.info('Don\'t have stripper for %s format' % mime) |
| 138 | return | 148 | return False |
| 139 | 149 | ||
| 140 | return stripper_class(filename, parser, mime, backup, add2archive) | 150 | return stripper_class(filename, parser, mime, backup, add2archive) |
diff --git a/test/clitest.py b/test/clitest.py index cb615ce..4155d45 100644 --- a/test/clitest.py +++ b/test/clitest.py | |||
| @@ -72,10 +72,33 @@ class TestisCleancli(test.MATTest): | |||
| 72 | stdout, _ = proc.communicate() | 72 | stdout, _ = proc.communicate() |
| 73 | self.assertEqual(stdout.strip('\n'), '[+] %s is not clean' % dirty) | 73 | self.assertEqual(stdout.strip('\n'), '[+] %s is not clean' % dirty) |
| 74 | 74 | ||
| 75 | class TestFileAttributes(unittest.TestCase): | ||
| 76 | ''' | ||
| 77 | test various stuffs about files (readable, writable, exist, ...) | ||
| 78 | ''' | ||
| 79 | def test_not_readable(self): | ||
| 80 | proc = subprocess.Popen(['../mat-cli', 'not_readable'], | ||
| 81 | stdout=subprocess.PIPE) | ||
| 82 | stdout, _ = proc.communicate() | ||
| 83 | self.assertEqual(stdout.strip('\n'), 'Unable to pocess %s' % 'not_readable') | ||
| 84 | |||
| 85 | def test_not_writtable(self): | ||
| 86 | proc = subprocess.Popen(['../mat-cli', 'not_writtable'], | ||
| 87 | stdout=subprocess.PIPE) | ||
| 88 | stdout, _ = proc.communicate() | ||
| 89 | self.assertEqual(stdout.strip('\n'), 'Unable to pocess %s' % 'not_writtable') | ||
| 90 | |||
| 91 | def test_not_exist(self): | ||
| 92 | proc = subprocess.Popen(['../mat-cli', 'ilikecookies'], | ||
| 93 | stdout=subprocess.PIPE) | ||
| 94 | stdout, _ = proc.communicate() | ||
| 95 | self.assertEqual(stdout.strip('\n'), 'Unable to pocess %s' % 'ilikecookies') | ||
| 75 | 96 | ||
| 76 | if __name__ == '__main__': | 97 | if __name__ == '__main__': |
| 77 | suite = unittest.TestSuite() | 98 | suite = unittest.TestSuite() |
| 78 | suite.addTest(unittest.makeSuite(TestRemovecli)) | 99 | suite.addTest(unittest.makeSuite(TestRemovecli)) |
| 79 | suite.addTest(unittest.makeSuite(TestListcli)) | 100 | suite.addTest(unittest.makeSuite(TestListcli)) |
| 80 | suite.addTest(unittest.makeSuite(TestisCleancli)) | 101 | suite.addTest(unittest.makeSuite(TestisCleancli)) |
| 81 | unittest.TextTestRunner(verbosity=test.VERBOSITY).run(suite) | 102 | test_result = unittest.TextTestRunner(verbosity=test.VERBOSITY).run(suite) |
| 103 | sys.exit(len(test_result.failures)) | ||
| 104 | |||
diff --git a/test/libtest.py b/test/libtest.py index ecbc03e..bfeb548 100644 --- a/test/libtest.py +++ b/test/libtest.py | |||
| @@ -64,11 +64,25 @@ class TestisCleanlib(test.MATTest): | |||
| 64 | current_file = mat.create_class_file(clean, False, True) | 64 | current_file = mat.create_class_file(clean, False, True) |
| 65 | self.assertTrue(current_file.is_clean()) | 65 | self.assertTrue(current_file.is_clean()) |
| 66 | 66 | ||
| 67 | class TestFileAttributes(unittest.TestCase): | ||
| 68 | ''' | ||
| 69 | test various stuffs about files (readable, writable, exist, ...) | ||
| 70 | ''' | ||
| 71 | def test_not_readable(self): | ||
| 72 | self.assertFalse(mat.create_class_file('not_readable', False, True)) | ||
| 73 | |||
| 74 | def test_not_writtable(self): | ||
| 75 | self.assertFalse(mat.create_class_file('not_writtable', False, True)) | ||
| 76 | |||
| 77 | def test_not_exist(self): | ||
| 78 | self.assertFalse(mat.create_class_file('ilikecookies', False, True)) | ||
| 67 | 79 | ||
| 68 | if __name__ == '__main__': | 80 | if __name__ == '__main__': |
| 69 | Suite = unittest.TestSuite() | 81 | Suite = unittest.TestSuite() |
| 70 | Suite.addTest(unittest.makeSuite(TestRemovelib)) | 82 | Suite.addTest(unittest.makeSuite(TestRemovelib)) |
| 71 | Suite.addTest(unittest.makeSuite(TestListlib)) | 83 | Suite.addTest(unittest.makeSuite(TestListlib)) |
| 72 | Suite.addTest(unittest.makeSuite(TestisCleanlib)) | 84 | Suite.addTest(unittest.makeSuite(TestisCleanlib)) |
| 73 | unittest.TextTestRunner(verbosity=test.VERBOSITY).run(Suite) | 85 | Suite.addTest(unittest.makeSuite(TestFileAttributes)) |
| 86 | test_result = unittest.TextTestRunner(verbosity=test.VERBOSITY).run(Suite) | ||
| 87 | sys.exit(len(test_result.failures)) | ||
| 74 | 88 | ||
