Index: build/landmines.py |
diff --git a/build/landmines.py b/build/landmines.py |
index 2b3d7753c0db9fe26b1b9e659a0b8600bbadc287..fb8246f212f6cc7b483b8dcd2626dd7032bf32f6 100755 |
--- a/build/landmines.py |
+++ b/build/landmines.py |
@@ -58,21 +58,26 @@ def set_up_landmines(target, new_landmines): |
if not os.path.exists(out_dir): |
return |
- if os.path.exists(landmines_path): |
- triggered = os.path.join(out_dir, '.landmines_triggered') |
- with open(landmines_path, 'r') as f: |
- old_landmines = f.readlines() |
- if old_landmines != new_landmines: |
- old_date = time.ctime(os.stat(landmines_path).st_ctime) |
- diff = difflib.unified_diff(old_landmines, new_landmines, |
- fromfile='old_landmines', tofile='new_landmines', |
- fromfiledate=old_date, tofiledate=time.ctime(), n=0) |
- |
- with open(triggered, 'w') as f: |
- f.writelines(diff) |
- elif os.path.exists(triggered): |
- # Remove false triggered landmines. |
- os.remove(triggered) |
+ # Make sure the landmines tracker exists. |
+ open(landmines_path, 'a').close() |
+ |
+ triggered = os.path.join(out_dir, '.landmines_triggered') |
+ with open(landmines_path, 'r') as f: |
+ old_landmines = f.readlines() |
+ if old_landmines != new_landmines: |
+ old_date = time.ctime(os.stat(landmines_path).st_ctime) |
+ diff = difflib.unified_diff(old_landmines, new_landmines, |
+ fromfile='old_landmines', tofile='new_landmines', |
+ fromfiledate=old_date, tofiledate=time.ctime(), n=0) |
+ |
+ with open(triggered, 'w') as f: |
+ f.writelines(diff) |
+ print "Setting landmine: %s" % triggered |
Jakob Kummerow
2014/07/23 11:05:48
are you keeping these print statements intentional
|
+ print "Reason:\n%s" % diff |
+ elif os.path.exists(triggered): |
+ # Remove false triggered landmines. |
+ os.remove(triggered) |
+ print "Removing landmine: %s" % triggered |
with open(landmines_path, 'w') as f: |
f.writelines(new_landmines) |