Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Narvaez <dwnarvaez@gmail.com>2012-12-03 19:30:41 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2012-12-03 19:30:41 (GMT)
commit96d10a665b90a0ca0419cc4e074aa55aac4a54e2 (patch)
treef0c1cd377b6f96b23ec893b3652b0813e8cb2cfd
parent6f323c4988558ed05f1425a736d4145bb154ad69 (diff)
Use progressive logs numbering
-rwxr-xr-xcommands/test-ui2
-rw-r--r--devbot/build.py4
-rw-r--r--devbot/config.py15
-rw-r--r--devbot/run.py18
-rwxr-xr-xtools/log-command5
5 files changed, 32 insertions, 12 deletions
diff --git a/commands/test-ui b/commands/test-ui
index 0570cf5..5686ebd 100755
--- a/commands/test-ui
+++ b/commands/test-ui
@@ -23,7 +23,7 @@ test_path = os.path.join(common.tests_dir, "sugar", "shell.py")
result = run.run_test("sugar-runner", test_path, virtual)
logs_path = os.path.join(profile_path, "logs")
-run.merge_logs(logs_path, "test.log")
+run.collect_logs(logs_path, "test")
if not result:
sys.exit(1)
diff --git a/devbot/build.py b/devbot/build.py
index 98cf368..91397e6 100644
--- a/devbot/build.py
+++ b/devbot/build.py
@@ -3,7 +3,6 @@ import os
import multiprocessing
import shutil
import subprocess
-import time
from devbot import command
from devbot import config
@@ -64,8 +63,7 @@ def build():
state.remove_built_commit_id(module)
for module in modules:
- log = "build-%s" % time.strftime("%Y%m%d-%H%M%S")
- if not _build_module(module, log):
+ if not _build_module(module, config.get_log_path("build")):
return False
return True
diff --git a/devbot/config.py b/devbot/config.py
index 284e9a8..9cce430 100644
--- a/devbot/config.py
+++ b/devbot/config.py
@@ -202,6 +202,21 @@ def _save_prefs(prefs):
for pref in prefs.items():
f.write("%s\n" % "=".join(pref))
+def get_log_path(prefix):
+ logfile_path = None
+ number = 0
+
+ while logfile_path is None:
+ name = "%s-%d.log" % (prefix, number)
+ path = os.path.join(logs_dir, name)
+
+ if not os.path.exists(path):
+ logfile_path = path
+
+ number = number + 1
+
+ return logfile_path
+
def get_pref(name):
prefs = _read_prefs()
return prefs.get(name, None)
diff --git a/devbot/run.py b/devbot/run.py
index 8733c10..930cd42 100644
--- a/devbot/run.py
+++ b/devbot/run.py
@@ -62,18 +62,28 @@ def run_test(command, test_path, virtual=False):
return result
-def merge_logs(logs_path, log_name):
+def collect_logs(source_path, log_name):
logs = {}
- for filename in os.listdir(logs_path):
+ for filename in os.listdir(source_path):
if filename.endswith(".log"):
- path = os.path.join(logs_path, filename)
+ path = os.path.join(source_path, filename)
with open(path) as f:
logs[filename] = f.read()
- with open(os.path.join(config.logs_dir, log_name), "w") as f:
+ log_path = config.get_log_path(log_name)
+ with open(log_path, "w") as f:
for filename, log in logs.items():
f.write("===== %s =====\n\n%s" % (filename, log))
+ last_log_path = os.path.join(config.logs_dir, "%s.log" % log_name)
+
+ try:
+ os.unlink(last_log_path)
+ except OSError:
+ pass
+
+ os.symlink(log_path, last_log_path)
+
def _get_random_id():
return ''.join(random.choice(string.letters) for i in xrange(8))
diff --git a/tools/log-command b/tools/log-command
index 3def5f9..59a043f 100755
--- a/tools/log-command
+++ b/tools/log-command
@@ -2,10 +2,7 @@
toolsdir=`dirname "$0"`
rootdir=`dirname "$toolsdir"`
-logsdir=$rootdir/logs
-mkdir -p $logsdir
-
-${@:(-$#):($#-1)} | tee -a $logsdir/${@: -1:1}.log
+${@:(-$#):($#-1)} | tee -a ${@: -1:1}
exit ${PIPESTATUS[0]}