[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-deployment] branch master updated: re-create dirs if
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-deployment] branch master updated: re-create dirs if necessary, formatting |
Date: |
Thu, 18 Jan 2018 15:47:59 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository deployment.
The following commit(s) were added to refs/heads/master by this push:
new 0e1693f re-create dirs if necessary, formatting
0e1693f is described below
commit 0e1693f4358ee02c733c3f24bf573f02a9cd4f67
Author: Florian Dold <address@hidden>
AuthorDate: Thu Jan 18 15:45:26 2018 +0100
re-create dirs if necessary, formatting
---
bin/taler-log-adapter | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/bin/taler-log-adapter b/bin/taler-log-adapter
index 4d28c1a..01faf73 100755
--- a/bin/taler-log-adapter
+++ b/bin/taler-log-adapter
@@ -15,6 +15,13 @@
#
# @author Florian Dold
+"""
+Wrapper for programs that log to stderr.
+
+Redirects logs to a file specified by a path with strfmt-style placeholders
+in them.
+"""
+
from subprocess import Popen, PIPE
import sys
import os
@@ -25,22 +32,33 @@ import time
def handler(signum, frame):
if p:
os.kill(p.pid, signal.SIGINT)
-p = None
+
+def touchp(path):
+ dir = os.path.dirname(path)
+ if dir:
+ os.makedirs(dir, exist_ok=True)
+
if len(sys.argv) < 3:
print("Usage: {} logfile prog_and_args...".format(sys.argv[0]),
file=sys.stderr)
sys.exit(-1)
+
+p = None
signal.signal(signal.SIGINT, handler)
p = Popen(sys.argv[2:], stderr=PIPE, shell=False)
+
log = sys.argv[1]
-dir = os.path.dirname(log)
-if dir:
- os.makedirs(os.path.dirname(log), exist_ok=True)
+last_name = None
+
while p.poll() is None:
full_name = time.strftime(log)
+ if full_name != last_name:
+ touchp(full_name)
+ last_name = full_name
last_read = p.stderr.readline()
if last_read == '':
break
with open(full_name, "ab") as f:
f.write(last_read)
+
status = p.wait()
sys.exit(status)
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-deployment] branch master updated: re-create dirs if necessary, formatting,
gnunet <=