From 1206082bdf0a25a2675296c01cf798e4da835d1b Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Wed, 29 Oct 2014 12:50:57 -0300 Subject: Add code to specify tuf stable/unstable. --- bundler/actions.py | 14 +++++++++++--- bundler/main.py | 37 +++++++++++++++++++++++++++---------- 2 files changed, 38 insertions(+), 13 deletions(-) (limited to 'bundler') diff --git a/bundler/actions.py b/bundler/actions.py index 883aaac..1f688e3 100644 --- a/bundler/actions.py +++ b/bundler/actions.py @@ -517,13 +517,15 @@ class CopyMisc(Action): updater_delay = 60 [Mirror.localhost] - url_prefix = http://dl.bitmask.net/tuf""") + url_prefix = {0}""") + TUF_STABLE = "https://dl.bitmask.net/tuf" + TUF_UNSTABLE = "https://dl.bitmask.net/tuf-unstable" def __init__(self, basedir, skip, do): Action.__init__(self, "copymisc", basedir, skip, do) @skippable - def run(self, binary_path): + def run(self, binary_path, tuf_repo): self.log("downloading thunderbird extension...") ext_path = platform_dir(self._basedir, "apps", "bitmask-thunderbird-latest.xpi") @@ -560,8 +562,14 @@ class CopyMisc(Action): _convert_path_for_win(os.path.join(self._basedir, "Bitmask"))) launcher_path = os.path.join(self._basedir, "Bitmask", "launcher.conf") + + if tuf_repo == 'stable': + tuf_config = self.TUF_CONFIG.format(self.TUF_STABLE) + elif tuf_repo == 'unstable': + tuf_config = self.TUF_CONFIG.format(self.TUF_UNSTABLE) + with open(launcher_path, "w") as f: - f.write(self.TUF_CONFIG) + f.write(tuf_config) metadata = os.path.join(self._basedir, "Bitmask", "repo", "metadata") mkdir("-p", os.path.join(metadata, "current")) diff --git a/bundler/main.py b/bundler/main.py index 234a1ba..733a241 100644 --- a/bundler/main.py +++ b/bundler/main.py @@ -41,6 +41,19 @@ def new_build_dir(default=None): dir_util.remove_tree(bd) +def _get_dict_from_json(json_file): + data = {} + + try: + with open(json_file, 'r') as f: + data = json.load(f) + except Exception as e: + print "Problem loading json: {0!r}".format(e) + pass + + return data + + def get_version(versions_file): """ Return the "version" data on the json file given as parameter. @@ -50,17 +63,21 @@ def get_version(versions_file): :rtype: str or None """ - version = None - try: - versions = None - with open(versions_file, 'r') as f: - versions = json.load(f) + versions = _get_dict_from_json(versions_file) + return versions.get('version') - version = versions.get("version") - except Exception as e: - print "Problem getting version: {0!r}".format(e) - return version +def get_tuf_repo(versions_file): + """ + Return the "tuf_repo" data on the json file given as parameter. + + :param versions_file: the file name of the json to parse. + :type versions_file: str + + :rtype: str or None + """ + versions = _get_dict_from_json(versions_file) + return versions.get('tuf_repo') def main(): @@ -132,7 +149,7 @@ def main(): fd.run() cm = init(CopyMisc) - cm.run(binaries_path) + cm.run(binaries_path, get_tuf_repo(versions_path)) pyc = init(PycRemover) pyc.run() -- cgit v1.2.3