#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of Cockpit. # # Copyright (C) 2017 Red Hat, Inc. # # Cockpit is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # Cockpit is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with Cockpit; If not, see . import os import subprocess import sys sys.dont_write_bytecode = True import task BOTS = os.path.abspath(os.path.dirname(__file__)) BASE = os.path.normpath(os.path.join(BOTS, "..")) def run(context, verbose=False, **kwargs): cwd = BASE def output(*args): if verbose: sys.stderr.write("+ " + " ".join(args) + "\n") return subprocess.check_output(args, cwd=cwd) def execute(*args): if verbose: sys.stderr.write("+ " + " ".join(args) + "\n") subprocess.check_call(args, cwd=cwd) # Make a tree with source ... outputs working directory cmd = [ "tools/make-source", "po/cockpit.pot" ] if verbose: sys.stderr.write("+ " + " ".join(cmd) + "\n") line = subprocess.check_output(cmd, cwd=BASE) cwd = os.path.abspath(line.strip()) # Do the various updates cmd = [ "make", "upload-pot", "download-po" ] if verbose: sys.stderr.write("+ " + " ".join(args) + "\n") subprocess.check_call(cmd, cwd=cwd) # Create a pull request from these changes branch = task.branch(context, "po: Update from Fedora Zanata", pathspec="po/", **kwargs) if branch: task.pull(branch, **kwargs) if __name__ == '__main__': task.main(function=run, title="Update translations from Fedora Zanata")