| 158 | |
| 159 | def JSLintWorker(command): |
| 160 | def format_file(command): |
| 161 | try: |
| 162 | file_name = command[-1] |
| 163 | with open(file_name, "r") as file_handle: |
| 164 | contents = file_handle.read() |
| 165 | |
| 166 | process = subprocess.Popen(command, stdout=PIPE, stderr=subprocess.PIPE) |
| 167 | output, err = process.communicate() |
| 168 | rc = process.returncode |
| 169 | if rc != 0: |
| 170 | sys.stdout.write("error code " + str(rc) + " running clang-format.\n") |
| 171 | return rc |
| 172 | |
| 173 | if decode(output) != contents: |
| 174 | return 1 |
| 175 | |
| 176 | return 0 |
| 177 | except KeyboardInterrupt: |
| 178 | process.kill() |
| 179 | except Exception: |
| 180 | print( |
| 181 | 'Error running clang-format. Please make sure you have depot_tools' + |
| 182 | ' in your third_party directory. Lint check skipped.') |
| 183 | process.kill() |
| 184 | |
| 185 | rc = format_file(command) |
| 186 | if rc == 1: |