(args)
| 22 | |
| 23 | |
| 24 | def main(args): |
| 25 | root_path = os.path.abspath(args.path) |
| 26 | cmd = args.cmd.split(' ') |
| 27 | if not os.path.exists(root_path): |
| 28 | print('Nonexistent path: %s' % root_path) |
| 29 | sys.exit(2) |
| 30 | err = False |
| 31 | for cur, dirnames, filenames in os.walk(root_path): |
| 32 | parts = cur.replace('\\', '/').split('/') |
| 33 | if '.git' in parts or 'depends' in parts: |
| 34 | continue |
| 35 | for filename in filenames: |
| 36 | if not filename.endswith('.' + args.ext): |
| 37 | continue |
| 38 | full_path = os.path.join(cur, filename) |
| 39 | try: |
| 40 | p = subprocess.Popen(cmd + [full_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 41 | _, stderr = p.communicate() |
| 42 | stderr = stderr.decode('utf-8', errors='ignore') |
| 43 | if stderr: |
| 44 | print_stderr(stderr, args) |
| 45 | if p.returncode != 0: |
| 46 | err = True |
| 47 | except subprocess.CalledProcessError: |
| 48 | err = True |
| 49 | except IOError: |
| 50 | if not err: |
| 51 | print('Warning: cannot check %s script syntax' % args.ext) |
| 52 | err = True |
| 53 | sys.exit(int(err)) |
| 54 | |
| 55 | |
| 56 | if __name__ == '__main__': |
no test coverage detected