Skip to content

Instantly share code, notes, and snippets.

@ajdavis
Created November 14, 2019 21:38
Show Gist options
  • Save ajdavis/2e4c22263a62bbd64362e643a1dde692 to your computer and use it in GitHub Desktop.
Save ajdavis/2e4c22263a62bbd64362e643a1dde692 to your computer and use it in GitHub Desktop.
Script for use with CLion to make a custom build tool's path outputs absolute, so they are clickable in CLion's output window.
#!/usr/bin/env python3
import re
import subprocess
import sys
proc = subprocess.Popen(sys.argv[1:], stdout=subprocess.PIPE)
for line in iter(proc.stdout.readline, b''):
match = re.match(rb'src/[\w_/.]+:\d+.*', line)
if match:
# Use sys.stdout.buffer for bytes.
sys.stdout.buffer.write(b'/mirror/co/mongo/')
sys.stdout.buffer.write(line)
sys.stdout.buffer.flush()
proc.stdout.close()
proc.wait()
sys.exit(proc.returncode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment