From b4ea329bf29b4e4d101d85a68dcc04305d8cb97e Mon Sep 17 00:00:00 2001 From: Valerie R Young Date: Fri, 1 Jul 2016 10:41:02 -0400 Subject: reproducible debian: add common function for creating temporary files Signed-off-by: Mattia Rizzolo Signed-off-by: Holger Levsen --- bin/reproducible_common.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py index 2340644f..f7a2a7d6 100755 --- a/bin/reproducible_common.py +++ b/bin/reproducible_common.py @@ -26,8 +26,10 @@ import html as HTML from string import Template from subprocess import call from traceback import print_exception +from tempfile import NamedTemporaryFile from datetime import datetime, timedelta + DEBUG = False QUIET = False @@ -47,6 +49,7 @@ BIN_PATH = '/srv/jenkins/bin' BASE = '/var/lib/jenkins/userContent/reproducible' DEBIAN_BASE = '/var/lib/jenkins/userContent/reproducible/debian' TEMPLATE_PATH = BIN_PATH + '/templates' +TEMP_PATH="/tmp/reproducible" REPRODUCIBLE_JSON = BASE + '/reproducible.json' REPRODUCIBLE_TRACKER_JSON = BASE + '/reproducible-tracker.json' @@ -166,6 +169,8 @@ html_header = Template(""" try: JOB_URL = os.environ['JOB_URL'] except KeyError: + JOB_URL = '' + JOB_NAME = '' JOB_FOOTER = '' else: JOB_NAME = os.path.basename(JOB_URL[:-1]) @@ -218,6 +223,11 @@ def percent(part, whole): return round(100 * float(part)/float(whole), 1) +def create_temp_file(mode='w+b'): + os.makedirs(TEMP_PATH, exist_ok=True) + return NamedTemporaryFile(suffix=JOB_NAME, dir=TEMP_PATH, mode=mode) + + class bcolors: BOLD = '\033[1m' UNDERLINE = '\033[4m' -- cgit v1.2.3-70-g09d2