summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorValerie R Young <spectranaut@riseup.net>2016-07-01 10:41:02 -0400
committerHolger Levsen <holger@layer-acht.org>2016-07-05 17:24:56 +0200
commitb4ea329bf29b4e4d101d85a68dcc04305d8cb97e (patch)
tree84c46428904a7d9a0072463bba531e3e119084f6
parent55af141af8e0e504bdf8489070861f061095448b (diff)
downloadjenkins.debian.net-b4ea329bf29b4e4d101d85a68dcc04305d8cb97e.tar.xz
reproducible debian: add common function for creating temporary files
Signed-off-by: Mattia Rizzolo <mattia@debian.org> Signed-off-by: Holger Levsen <holger@layer-acht.org>
-rwxr-xr-xbin/reproducible_common.py10
1 files changed, 10 insertions, 0 deletions
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("""<!DOCTYPE html>
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'