diff options
-rwxr-xr-x | android/mobile-config.py | 37 | ||||
-rw-r--r-- | bin/update/config.py | 3 | ||||
-rwxr-xr-x | bin/update/create_build_config.py | 13 | ||||
-rwxr-xr-x | bin/update/create_full_mar.py | 26 | ||||
-rwxr-xr-x | bin/update/create_full_mar_for_languages.py | 13 | ||||
-rwxr-xr-x | bin/update/create_partial_update.py | 54 | ||||
-rwxr-xr-x | bin/update/get_update_channel.py | 2 | ||||
-rw-r--r-- | bin/update/path.py | 24 | ||||
-rw-r--r-- | bin/update/signing.py | 5 | ||||
-rw-r--r-- | bin/update/tools.py | 39 | ||||
-rwxr-xr-x | bin/update/uncompress_mar.py | 6 | ||||
-rwxr-xr-x | bin/update/upload_build_config.py | 18 | ||||
-rwxr-xr-x | bin/update/upload_builds.py | 9 |
13 files changed, 140 insertions, 109 deletions
diff --git a/android/mobile-config.py b/android/mobile-config.py index 5998e5d1f9b7..596f27f107a8 100755 --- a/android/mobile-config.py +++ b/android/mobile-config.py @@ -14,13 +14,13 @@ # already over-complicated by rampant conditionals. import sys -import xml.etree.ElementTree as ET +import xml.etree.ElementTree as ElementTree main_xcd_discard = [ - 'org.openoffice.Office/TableWizard', # huge + 'org.openoffice.Office/TableWizard', # huge - 'org.openoffice.Office.DataAccess/Drivers', # no database - 'org.openoffice.Office/Addons', # no addons + 'org.openoffice.Office.DataAccess/Drivers', # no database + 'org.openoffice.Office/Addons', # no addons # no conventional UI; reverse sorted by size 'org.openoffice.Office.UI/GenericCommands', @@ -46,15 +46,15 @@ main_xcd_discard = [ 'org.openoffice.Office.UI/GlobalSettings', 'org.openoffice.Office.UI/BibliographyWindowState', 'org.openoffice.Office.UI/Category', - ] +] if __name__ == '__main__': - tree = ET.parse(sys.argv[1]) + tree = ElementTree.parse(sys.argv[1]) root = tree.getroot() total = 0 for child in root: - total += len(ET.tostring(child)) + total += len(ElementTree.tostring(child)) saved = 0 to_remove = [] @@ -62,7 +62,7 @@ if __name__ == '__main__': for child in root: section = child.attrib['{http://openoffice.org/2001/registry}name'] package = child.attrib['{http://openoffice.org/2001/registry}package'] - size = len(ET.tostring(child)); + size = len(ElementTree.tostring(child)) key = '%s/%s' % (package, section) if key in main_xcd_discard: print('removed %s - saving %d' % (key, size)) @@ -72,7 +72,7 @@ if __name__ == '__main__': for child in to_remove: root.remove(child) - print("saved %d of %d bytes: %2.f%%" % (saved, total, saved*100.0/total)) + print("saved %d of %d bytes: %2.f%%" % (saved, total, saved * 100.0 / total)) # Don't do pointless Word -> Writer and similar conversions when we have no UI. nsDict = { @@ -80,28 +80,37 @@ if __name__ == '__main__': "component-data": "{http://openoffice.org/2001/registry}component-data", "name": "{http://openoffice.org/2001/registry}name", } - microsoftImport = '%(component-schema)s[@%(name)s="Common"]/component/group[@%(name)s="Filter"]/group[@%(name)s="Microsoft"]/group[@%(name)s="Import"]/prop' % nsDict + microsoftImport = '%(component-schema)s[@%(name)s="Common"]/component/group[@%(name)s="Filter"]/group[@%(' +\ + 'name)s="Microsoft"]/group[@%(name)s="Import"]/prop' % nsDict props = root.findall(microsoftImport) for prop in props: prop.findall("value")[0].text = "false" # Disable View -> Text Boundaries - for prop in root.findall('%(component-schema)s[@%(name)s="UI"]/templates/group[@%(name)s="ColorScheme"]/group[@%(name)s="DocBoundaries"]/prop' % nsDict): + for prop in root.findall( + '%(component-schema)s[@%(name)s="UI"]/templates/group[@%(name)s="ColorScheme"]/group[@%(' + + 'name)s="DocBoundaries"]/prop' % nsDict): for value in prop.findall("value"): value.text = "false" # Disable Table -> Table Boundaries - for prop in root.findall('%(component-schema)s[@%(name)s="UI"]/templates/group[@%(name)s="ColorScheme"]/group[@%(name)s="TableBoundaries"]/prop' % nsDict): + for prop in root.findall( + '%(component-schema)s[@%(name)s="UI"]/templates/group[@%(name)s="ColorScheme"]/group[@%(' + + 'name)s="TableBoundaries"]/prop' % nsDict): for value in prop.findall("value"): value.text = "false" # Disable follow link with Ctrl+Click, use Click only for mobile app. - for prop in root.findall('%(component-schema)s[@%(name)s="Common"]/component/group[@%(name)s="Security"]/group[@%(name)s="Scripting"]/prop[@%(name)s="HyperlinksWithCtrlClick"]' % nsDict): + for prop in root.findall( + '%(component-schema)s[@%(name)s="Common"]/component/group[@%(name)s="Security"]/group[@%(' + + 'name)s="Scripting"]/prop[@%(name)s="HyperlinksWithCtrlClick"]' % nsDict): for value in prop.findall("value"): value.text = "false" # Disable Impress View -> Slide Pane - for prop in root.findall('%(component-data)s[@%(name)s="Impress"]/node[@%(name)s="MultiPaneGUI"]/node[@%(name)s="SlideSorterBar"]/node[@%(name)s="Visible"]/prop[@%(name)s="ImpressView"]' % nsDict): + for prop in root.findall( + '%(component-data)s[@%(name)s="Impress"]/node[@%(name)s="MultiPaneGUI"]/node[@%(' + + 'name)s="SlideSorterBar"]/node[@%(name)s="Visible"]/prop[@%(name)s="ImpressView"]' % nsDict): for value in prop.findall("value"): value.text = "false" diff --git a/bin/update/config.py b/bin/update/config.py index 0bc60a07f53b..25857bde2e9a 100644 --- a/bin/update/config.py +++ b/bin/update/config.py @@ -1,7 +1,7 @@ - import configparser import os + class Config(object): def __init__(self): @@ -12,6 +12,7 @@ class Config(object): self.upload_url = None self.server_url = None + def parse_config(config_file): config = configparser.ConfigParser() config.read(os.path.expanduser(config_file)) diff --git a/bin/update/create_build_config.py b/bin/update/create_build_config.py index 7cc8ac4be15e..a8eb605997e6 100755 --- a/bin/update/create_build_config.py +++ b/bin/update/create_build_config.py @@ -8,6 +8,7 @@ from config import parse_config from tools import replace_variables_in_string + def update_all_url_entries(data, **kwargs): data['complete']['url'] = replace_variables_in_string(data['complete']['url'], **kwargs) @@ -25,6 +26,7 @@ def update_all_url_entries(data, **kwargs): for lang, lang_file in partial['languages'].items(): lang_file['url'] = replace_variables_in_string(lang_file['url'], **kwargs) + def main(argv): if len(argv) < 7: print("Usage: create_build_config.py $PRODUCTNAME $VERSION $BUILDID $PLATFORM $TARGETDIR $UPDATE_CONFIG") @@ -32,11 +34,11 @@ def main(argv): config = parse_config(argv[6]) - data = { 'productName' : argv[1], - 'version' : argv[2], - 'buildNumber' : argv[3], - 'updateChannel' : config.channel, - 'platform' : argv[4] + data = {'productName': argv[1], + 'version': argv[2], + 'buildNumber': argv[3], + 'updateChannel': config.channel, + 'platform': argv[4] } extra_data_files = ['complete_info.json', 'partial_update_info.json'] @@ -56,5 +58,6 @@ def main(argv): with open(os.path.join(argv[5], "build_config.json"), "w") as f: json.dump(data, f, indent=4) + if __name__ == "__main__": main(sys.argv) diff --git a/bin/update/create_full_mar.py b/bin/update/create_full_mar.py index 48686be21e45..39cb23f1f20e 100755 --- a/bin/update/create_full_mar.py +++ b/bin/update/create_full_mar.py @@ -4,6 +4,7 @@ import sys import os import subprocess import json +import argparse from tools import uncompress_file_to_dir, get_file_info, make_complete_mar_name from config import parse_config @@ -12,15 +13,19 @@ from path import UpdaterPath, convert_to_unix, convert_to_native current_dir_path = os.path.dirname(os.path.realpath(convert_to_unix(__file__))) -def main(): - if len(sys.argv) < 5: - print("Usage: create_full_mar_for_languages.py $PRODUCTNAME $WORKDIR $FILENAMEPREFIX $UPDATE_CONFIG") - sys.exit(1) - update_config = sys.argv[4] - filename_prefix = sys.argv[3] - workdir = sys.argv[2] - product_name = sys.argv[1] +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('product_name') + parser.add_argument('workdir') + parser.add_argument('filename_prefix') + parser.add_argument('update_config') + args = parser.parse_args() + + update_config = args.update_config + filename_prefix = args.filename_prefix + workdir = args.workdir + product_name = args.update_config if len(update_config) == 0: print("missing update config") @@ -45,10 +50,11 @@ def main(): sign_mar_file(target_dir, config, mar_file, filename_prefix) - file_info = { 'complete' : get_file_info(mar_file, config.base_url) } + file_info = {'complete': get_file_info(mar_file, config.base_url)} with open(os.path.join(target_dir, 'complete_info.json'), "w") as complete_info_file: - json.dump(file_info, complete_info_file, indent = 4) + json.dump(file_info, complete_info_file, indent=4) + if __name__ == '__main__': main() diff --git a/bin/update/create_full_mar_for_languages.py b/bin/update/create_full_mar_for_languages.py index 039521dd10af..610bbc061003 100755 --- a/bin/update/create_full_mar_for_languages.py +++ b/bin/update/create_full_mar_for_languages.py @@ -13,19 +13,23 @@ from signing import sign_mar_file current_dir_path = os.path.dirname(os.path.realpath(__file__)) + def make_complete_mar_name(target_dir, filename_prefix, language): filename = filename_prefix + "_" + language + "_complete_langpack.mar" return os.path.join(target_dir, filename) + def create_lang_infos(mar_file_name, language, url): - data = {'lang' : language, - 'complete' : get_file_info(mar_file_name, url) + data = {'lang': language, + 'complete': get_file_info(mar_file_name, url) } return data + def main(): if len(sys.argv) < 5: - print("Usage: create_full_mar_for_languages.py $PRODUCTNAME $WORKDIR $TARGETDIR $TEMPDIR $FILENAMEPREFIX $UPDATE_CONFIG") + print( + "Usage: create_full_mar_for_languages.py $PRODUCTNAME $WORKDIR $TARGETDIR $TEMPDIR $FILENAMEPREFIX $UPDATE_CONFIG") sys.exit(1) update_config = sys.argv[4] @@ -60,7 +64,8 @@ def main(): lang_infos.append(create_lang_infos(mar_file_name, language, config.base_url)) with open(os.path.join(target_dir, "complete_lang_info.json"), "w") as language_info_file: - json.dump({'languages' : lang_infos}, language_info_file, indent=4) + json.dump({'languages': lang_infos}, language_info_file, indent=4) + if __name__ == '__main__': main() diff --git a/bin/update/create_partial_update.py b/bin/update/create_partial_update.py index 9412bcd6e962..83ac3a35fae5 100755 --- a/bin/update/create_partial_update.py +++ b/bin/update/create_partial_update.py @@ -1,28 +1,27 @@ #!/usr/bin/env python3 -import requests import json -import sys -import hashlib import os import subprocess -import errno -import json +import sys -from config import parse_config -from uncompress_mar import extract_mar -from tools import get_file_info, get_hash -from signing import sign_mar_file +import requests +from config import parse_config from path import UpdaterPath, mkdir_p, convert_to_unix, convert_to_native +from signing import sign_mar_file +from tools import get_file_info, get_hash +from uncompress_mar import extract_mar BUF_SIZE = 1024 current_dir_path = os.path.dirname(os.path.realpath(convert_to_unix(__file__))) + class InvalidFileException(Exception): def __init__(self, *args, **kwargs): super().__init__(self, *args, **kwargs) + def download_file(filepath, url, hash_string): with open(filepath, "wb") as f: response = requests.get(url, stream=True) @@ -36,16 +35,17 @@ def download_file(filepath, url, hash_string): file_hash = get_hash(filepath) if file_hash != hash_string: - raise InvalidFileException("file hash does not match for file %s: Expected %s, Got: %s" % (url, hash_string, file_hash)) + raise InvalidFileException( + "file hash does not match for file %s: Expected %s, Got: %s" % (url, hash_string, file_hash)) + def handle_language(lang_entries, filedir): - mar = os.environ.get('MAR', 'mar') langs = {} for lang, data in lang_entries.items(): lang_dir = os.path.join(filedir, lang) lang_file = os.path.join(lang_dir, "lang.mar") mkdir_p(lang_dir) - download_file(lang_file , data["url"], data["hash"]) + download_file(lang_file, data["url"], data["hash"]) dir_path = os.path.join(lang_dir, "lang") mkdir_p(dir_path) extract_mar(lang_file, dir_path) @@ -53,8 +53,8 @@ def handle_language(lang_entries, filedir): return langs + def download_mar_for_update_channel_and_platform(config, platform, temp_dir): - mar = os.environ.get('MAR', 'mar') base_url = config.server_url + "update/partial-targets/1/" url = base_url + platform + "/" + config.channel r = requests.get(url) @@ -87,18 +87,22 @@ def download_mar_for_update_channel_and_platform(config, platform, temp_dir): return downloaded_updates -def generate_file_name(current_build_id, old_build_id, mar_name_prefix): - name = "%s_from_%s_partial.mar" %(mar_name_prefix, old_build_id) + +def generate_file_name(old_build_id, mar_name_prefix): + name = "%s_from_%s_partial.mar" % (mar_name_prefix, old_build_id) return name -def generate_lang_file_name(current_build_id, old_build_id, mar_name_prefix, lang): - name = "%s_%s_from_%s_partial.mar" %(mar_name_prefix, lang, old_build_id) + +def generate_lang_file_name(old_build_id, mar_name_prefix, lang): + name = "%s_%s_from_%s_partial.mar" % (mar_name_prefix, lang, old_build_id) return name + def add_single_dir(path): - dir_name = [os.path.join(path, name) for name in os.listdir(path) if os.path.isdir(os.path.join(path, name))] + dir_name = [os.path.join(path, name) for name in os.listdir(path) if os.path.isdir(os.path.join(path, name))] return dir_name[0] + def main(): workdir = sys.argv[1] @@ -126,17 +130,19 @@ def main(): data = {"partials": []} for build, update in updates.items(): - file_name = generate_file_name(build_id, build, mar_name_prefix) + file_name = generate_file_name(build, mar_name_prefix) mar_file = os.path.join(update_dir, file_name) - subprocess.call([os.path.join(current_dir_path, 'make_incremental_update.sh'), convert_to_native(mar_file), convert_to_native(update["complete"]), convert_to_native(current_build_path)]) + subprocess.call([os.path.join(current_dir_path, 'make_incremental_update.sh'), convert_to_native(mar_file), + convert_to_native(update["complete"]), convert_to_native(current_build_path)]) sign_mar_file(update_dir, config, mar_file, mar_name_prefix) - partial_info = {"file":get_file_info(mar_file, config.base_url), "from": build, "to": build_id, "languages": {}} + partial_info = {"file": get_file_info(mar_file, config.base_url), "from": build, "to": build_id, + "languages": {}} # on Windows we don't use language packs if sys.platform != "cygwin": for lang, lang_info in update["languages"].items(): - lang_name = generate_lang_file_name(build_id, build, mar_name_prefix, lang) + lang_name = generate_lang_file_name(build, mar_name_prefix, lang) # write the file into the final directory lang_mar_file = os.path.join(update_dir, lang_name) @@ -144,7 +150,9 @@ def main(): # the directory of the old language file is of the form # workdir/mar/language/en-US/LibreOffice_<version>_<os>_archive_langpack_<lang>/ language_dir = add_single_dir(os.path.join(mar_dir, "language", lang)) - subprocess.call([os.path.join(current_dir_path, 'make_incremental_update.sh'), convert_to_native(lang_mar_file), convert_to_native(lang_info), convert_to_native(language_dir)]) + subprocess.call( + [os.path.join(current_dir_path, 'make_incremental_update.sh'), convert_to_native(lang_mar_file), + convert_to_native(lang_info), convert_to_native(language_dir)]) sign_mar_file(update_dir, config, lang_mar_file, mar_name_prefix) # add the partial language info diff --git a/bin/update/get_update_channel.py b/bin/update/get_update_channel.py index f94507d64587..4215f8054b10 100755 --- a/bin/update/get_update_channel.py +++ b/bin/update/get_update_channel.py @@ -9,6 +9,7 @@ import sys from config import parse_config + def main(): if len(sys.argv) < 2: sys.exit(1) @@ -17,6 +18,7 @@ def main(): config = parse_config(update_config) print(config.channel) + if __name__ == "__main__": main() diff --git a/bin/update/path.py b/bin/update/path.py index 0fe0fd5eb04f..0420fa3784a0 100644 --- a/bin/update/path.py +++ b/bin/update/path.py @@ -8,18 +8,9 @@ # import os -import errno import subprocess from sys import platform -def mkdir_p(path): - try: - os.makedirs(path) - except OSError as exc: # Python >2.5 - if exc.errno == errno.EEXIST and os.path.isdir(path): - pass - else: - raise def convert_to_unix(path): if platform == "cygwin": @@ -27,12 +18,14 @@ def convert_to_unix(path): else: return path + def convert_to_native(path): if platform == "cygwin": return subprocess.check_output(["cygpath", "-m", path]).decode("utf-8", "strict").rstrip() else: return path + class UpdaterPath(object): def __init__(self, workdir): @@ -56,14 +49,11 @@ class UpdaterPath(object): def get_language_dir(self): return os.path.join(self.get_mar_dir(), "language") - def get_workdir(self): - return self._workdir - def ensure_dir_exist(self): - mkdir_p(self.get_update_dir()) - mkdir_p(self.get_current_build_dir()) - mkdir_p(self.get_mar_dir()) - mkdir_p(self.get_previous_build_dir()) - mkdir_p(self.get_language_dir()) + os.makedirs(self.get_update_dir(), exist_ok=True) + os.makedirs(self.get_current_build_dir(), exist_ok=True) + os.makedirs(self.get_mar_dir(), exist_ok=True) + os.makedirs(self.get_previous_build_dir(), exist_ok=True) + os.makedirs(self.get_language_dir(), exist_ok=True) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/bin/update/signing.py b/bin/update/signing.py index c0b43ce91536..65b482fe31aa 100644 --- a/bin/update/signing.py +++ b/bin/update/signing.py @@ -4,9 +4,12 @@ import os import subprocess import path + def sign_mar_file(target_dir, config, mar_file, filename_prefix): signed_mar_file = make_complete_mar_name(target_dir, filename_prefix + '_signed') mar_executable = os.environ.get('MAR', 'mar') - subprocess.check_call([mar_executable, '-C', path.convert_to_native(target_dir), '-d', path.convert_to_native(config.certificate_path), '-n', config.certificate_name, '-s', path.convert_to_native(mar_file), path.convert_to_native(signed_mar_file)]) + subprocess.check_call([mar_executable, '-C', path.convert_to_native(target_dir), '-d', + path.convert_to_native(config.certificate_path), '-n', config.certificate_name, '-s', + path.convert_to_native(mar_file), path.convert_to_native(signed_mar_file)]) os.rename(signed_mar_file, mar_file) diff --git a/bin/update/tools.py b/bin/update/tools.py index 8cd786635f0d..35e635cf8336 100644 --- a/bin/update/tools.py +++ b/bin/update/tools.py @@ -3,62 +3,59 @@ import hashlib import zipfile import tarfile + def uncompress_file_to_dir(compressed_file, uncompress_dir): - command = None extension = os.path.splitext(compressed_file)[1] - try: - os.mkdir(uncompress_dir) - except FileExistsError as e: - pass + os.makedirs(uncompress_dir, exist_ok=True) if extension == '.gz': - tar = tarfile.open(compressed_file) - tar.extractall(uncompress_dir) - tar.close() + with tarfile.open(compressed_file) as tar: + tar.extractall(uncompress_dir) elif extension == '.zip': - zip_file = zipfile.ZipFile(compressed_file) - zip_file.extractall(uncompress_dir) - zip_file.close() + with zipfile.ZipFile(compressed_file) as zip_file: + zip_file.extractall(uncompress_dir) uncompress_dir = os.path.join(uncompress_dir, os.listdir(uncompress_dir)[0]) if " " in os.listdir(uncompress_dir)[0]: print("replacing whitespace in directory name") os.rename(os.path.join(uncompress_dir, os.listdir(uncompress_dir)[0]), - os.path.join(uncompress_dir, os.listdir(uncompress_dir)[0].replace(" ", "_"))) + os.path.join(uncompress_dir, os.listdir(uncompress_dir)[0].replace(" ", "_"))) else: print("Error: unknown extension " + extension) return os.path.join(uncompress_dir, os.listdir(uncompress_dir)[0]) + BUF_SIZE = 1048576 + def get_hash(file_path): sha512 = hashlib.sha512() with open(file_path, 'rb') as f: - while True: - data = f.read(BUF_SIZE) - if not data: - break + while data := f.read(BUF_SIZE): sha512.update(data) return sha512.hexdigest() + def get_file_info(mar_file, url): filesize = os.path.getsize(mar_file) - data = { 'hash' : get_hash(mar_file), - 'hashFunction' : 'sha512', - 'size' : filesize, - 'url' : url + os.path.basename(mar_file)} + data = {'hash': get_hash(mar_file), + 'hashFunction': 'sha512', + 'size': filesize, + 'url': url + os.path.basename(mar_file)} return data + def replace_variables_in_string(string, **kwargs): new_string = string for key, val in kwargs.items(): - new_string = new_string.replace('$(%s)'%key, val) + new_string = new_string.replace('$(%s)' % key, val) return new_string + def make_complete_mar_name(target_dir, filename_prefix): filename = filename_prefix + "_complete.mar" return os.path.join(target_dir, filename) diff --git a/bin/update/uncompress_mar.py b/bin/update/uncompress_mar.py index 02dafbaff30b..14726dd96178 100755 --- a/bin/update/uncompress_mar.py +++ b/bin/update/uncompress_mar.py @@ -16,11 +16,13 @@ import sys import subprocess from path import convert_to_native + def uncompress_content(file_path): bzip2 = os.environ.get('BZIP2', 'bzip2') file_path_compressed = file_path + ".bz2" os.rename(file_path, file_path_compressed) - subprocess.check_call(["bzip2", "-d", convert_to_native(file_path_compressed)]) + subprocess.check_call([bzip2, "-d", convert_to_native(file_path_compressed)]) + def extract_mar(mar_file, target_dir): mar = os.environ.get('MAR', 'mar') @@ -39,6 +41,7 @@ def extract_mar(mar_file, target_dir): uncompress_content(os.path.join(target_dir, info)) + def main(): if len(sys.argv) != 3: print("Help: This program takes exactly two arguments pointing to a mar file and a target location") @@ -48,6 +51,7 @@ def main(): target_dir = sys.argv[2] extract_mar(mar_file, target_dir) + if __name__ == "__main__": main() diff --git a/bin/update/upload_build_config.py b/bin/update/upload_build_config.py index 9a87661eee73..ec5a94bf3eff 100755 --- a/bin/update/upload_build_config.py +++ b/bin/update/upload_build_config.py @@ -7,9 +7,9 @@ import requests dir_path = os.path.dirname(os.path.realpath(__file__)) -def main(argv): - updater_config = sys.argv[2] +def main(argv): + updater_config = argv[2] config = configparser.ConfigParser() config.read(os.path.expanduser(updater_config)) @@ -21,22 +21,22 @@ def main(argv): login_url = base_address + "accounts/login/" session = requests.session() - r1 = session.get(login_url) + session.get(login_url) csrftoken = session.cookies['csrftoken'] - login_data = { 'username': user,'password': password, - 'csrfmiddlewaretoken': csrftoken } - r1 = session.post(login_url, data=login_data, headers={"Referer": login_url}) + login_data = {'username': user, 'password': password, + 'csrfmiddlewaretoken': csrftoken} + session.post(login_url, data=login_data, headers={"Referer": login_url}) url = base_address + "update/upload/release" - data = {} - data['csrfmiddlewaretoken'] = csrftoken + data = {'csrfmiddlewaretoken': csrftoken} - build_config = os.path.join(sys.argv[1], "build_config.json") + build_config = os.path.join(argv[1], "build_config.json") r = session.post(url, files={'release_config': open(build_config, "r")}, data=data) print(r.content) if r.status_code != 200: sys.exit(1) + if __name__ == "__main__": main(sys.argv) diff --git a/bin/update/upload_builds.py b/bin/update/upload_builds.py index 210668e0d07c..1be1b2fe837e 100755 --- a/bin/update/upload_builds.py +++ b/bin/update/upload_builds.py @@ -9,24 +9,27 @@ from path import convert_to_unix from tools import replace_variables_in_string + def main(): - product_name = sys.argv[1] + # product_name = sys.argv[1] buildid = sys.argv[2] platform = sys.argv[3] update_dir = sys.argv[4] update_config = sys.argv[5] config = parse_config(update_config) - upload_url = replace_variables_in_string(config.upload_url, channel=config.channel, buildid=buildid, platform=platform) + upload_url = replace_variables_in_string(config.upload_url, channel=config.channel, buildid=buildid, + platform=platform) target_url, target_dir = upload_url.split(':') - command = "ssh %s 'mkdir -p %s'"%(target_url, target_dir) + command = "ssh %s 'mkdir -p %s'" % (target_url, target_dir) print(command) subprocess.call(command, shell=True) for file in os.listdir(update_dir): if file.endswith('.mar'): subprocess.call(['scp', convert_to_unix(os.path.join(update_dir, file)), upload_url]) + if __name__ == '__main__': main() |