#!/usr/bin/python

import sys
import os.path
import time

STAMP_FILE = "bd-timestamp.txt"
SCMID_FILE = "bd-scmid.txt"

configDir = sys.argv[1]

def readline(filename, fallback="unknown"):
    try:
        bdFile = open(filename)
        line = bdFile.readline()
        line = line.strip()
    except:
        line = ""

    if not line:
        line = fallback

    return line

curTime = str(int(time.time()))

details = {
  "timestamp": readline(os.path.join(configDir, STAMP_FILE), curTime),
  "scmID": readline(os.path.join(configDir, SCMID_FILE))
}

print """[BuildDetails]
timestamp=%(timestamp)s
scmID=%(scmID)s""" % details
