diff options
author | Patrik Teivonen <patrik.teivonen@qt.io> | 2022-06-16 12:07:05 +0300 |
---|---|---|
committer | Patrik Teivonen <patrik.teivonen@qt.io> | 2022-07-11 07:43:46 +0000 |
commit | 45312f31b5439e99598a553d0fffd7c7060bfbaf (patch) | |
tree | 88207d30e9ac6f4195d9ec3f4d54c6124454b5e8 /packaging-tools | |
parent | c444074df00e88910bd1b0f8e257a1307419f715 (diff) |
Add pre-commit hook for flake8, PEP8 compliant comments
Change block and inline comments to be PEP8 compliant.
(Note: line lengths will be enforced in a separate patch)
Add pre-commit hook for flake8, and enable only checks relevant
to this patch:
- E265 Block comment should start with '# '
- E266 Too many leading '#' for block comment
- E261 At least two spaces before inline comment
- E262 Inline comment should start with '# '
- E115 expected an indented block (comment)
Change-Id: I0218772bfbea514b4a0d8ecc461845c4563396da
Reviewed-by: Akseli Salovaara <akseli.salovaara@qt.io>
Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
Diffstat (limited to 'packaging-tools')
-rwxr-xr-x | packaging-tools/bld_ifw_tools.py | 10 | ||||
-rwxr-xr-x | packaging-tools/bld_module.py | 6 | ||||
-rw-r--r-- | packaging-tools/bld_utils.py | 12 | ||||
-rw-r--r-- | packaging-tools/bldinstallercommon.py | 18 | ||||
-rw-r--r-- | packaging-tools/build_clang.py | 14 | ||||
-rw-r--r-- | packaging-tools/build_clang_qdoc.py | 4 | ||||
-rw-r--r-- | packaging-tools/build_wrapper.py | 50 | ||||
-rw-r--r-- | packaging-tools/create_installer.py | 6 | ||||
-rw-r--r-- | packaging-tools/dump_debug_infos.py | 2 | ||||
-rw-r--r-- | packaging-tools/environmentfrombatchfile.py | 22 | ||||
-rw-r--r-- | packaging-tools/install_qt.py | 2 | ||||
-rw-r--r-- | packaging-tools/libclang_training/libclangtimings2csv.py | 2 | ||||
-rw-r--r-- | packaging-tools/libclang_training/mergeCsvFiles.py | 4 | ||||
-rw-r--r-- | packaging-tools/libclang_training/runBatchFiles.py | 4 | ||||
-rw-r--r-- | packaging-tools/tests/test_runCommand.py | 24 | ||||
-rw-r--r-- | packaging-tools/threadedwork.py | 8 |
16 files changed, 94 insertions, 94 deletions
diff --git a/packaging-tools/bld_ifw_tools.py b/packaging-tools/bld_ifw_tools.py index dd00211a1..e17680421 100755 --- a/packaging-tools/bld_ifw_tools.py +++ b/packaging-tools/bld_ifw_tools.py @@ -287,9 +287,9 @@ class IfwOptions: def build_ifw(options, create_installer=False, build_ifw_examples=False): # verbose options.print_data() - #clean environment first + # clean environment first clean_build_environment(options) - #checkout sources + # checkout sources prepare_installer_framework(options) if options.qt_binaries_static: @@ -316,7 +316,7 @@ def build_ifw(options, create_installer=False, build_ifw_examples=False): build_qt(options, options.qt_build_dir_dynamic, configure_options, options.qt_build_modules_docs) build_ifw_docs(options) create_installer_package(options) - #archive + # archive archive_installerbase(options) archive_installer_framework(options.installer_framework_build_dir, options.installer_framework_archive_name, options, True) archive_binarycreator(options) @@ -408,7 +408,7 @@ def prepare_installer_framework(options): return print('--------------------------------------------------------------------') print('Prepare Installer Framework source') - #create dirs + # create dirs Path(options.installer_framework_build_dir).mkdir(parents=True, exist_ok=True) if options.qt_installer_framework_uri.endswith('.git'): # clone repos @@ -477,7 +477,7 @@ def build_installer_framework_examples(options): if is_windows(): target_filename += '.exe' ifw_example_binaries.append(target_filename) - #Breaking here as we don't want to go through sub directories + # Breaking here as we don't want to go through sub directories break diff --git a/packaging-tools/bld_module.py b/packaging-tools/bld_module.py index bbe77f55c..29b2714a9 100755 --- a/packaging-tools/bld_module.py +++ b/packaging-tools/bld_module.py @@ -30,7 +30,7 @@ ############################################################################# # built in imports -import argparse # commandline argument parser +import argparse # commandline argument parser import multiprocessing import os import sys @@ -201,7 +201,7 @@ if is_windows(): qtModuleInstallDirectory = qtModuleInstallDirectory.replace('\\','/').replace('/', '\\', 1) -### clean step +# clean step if callerArguments.clean: print("##### {0} #####".format("clean old builds")) bldinstallercommon.remove_tree(callerArguments.qt5path) @@ -229,7 +229,7 @@ if not os.path.lexists(callerArguments.qt5path): # "install" Qt bldinstallercommon.patch_qt(callerArguments.qt5path) -### lets start building +# lets start building # prepare the environment for example setting LD_LIBRARY_PATH # or adding qmake path into the Path environment variable (Qt deployment step) diff --git a/packaging-tools/bld_utils.py b/packaging-tools/bld_utils.py index ae5278b73..5ab421703 100644 --- a/packaging-tools/bld_utils.py +++ b/packaging-tools/bld_utils.py @@ -30,7 +30,7 @@ ############################################################################# # built in imports -from distutils.spawn import find_executable # runCommand method +from distutils.spawn import find_executable # runCommand method import os import sys from sys import platform @@ -202,10 +202,10 @@ def download(url, target, read_block_size = 1048576): else: if not os.path.lexists(target): raise Exception("Could not rename {0} to {1}{2}Error: {3}".format(savefile_tmp, target, os.linesep, e.message)) - finally: # this is done before the except code is called + finally: # this is done before the except code is called try: os.remove(savefile_tmp) - except: #swallow, do not shadow actual error + except: # swallow, do not shadow actual error pass def setValueOnEnvironmentDict(environment, key, value): @@ -321,9 +321,9 @@ def runCommand(command, currentWorkingDirectory, callerArguments = None, extra_e exitCode = process.returncode # lets keep that for debugging - #if environment: - # for key in sorted(environment): - # sys.stderr.write("set " + key + "=" + environment[key] + os.linesep) + # if environment: + # for key in sorted(environment): + # sys.stderr.write("set " + key + "=" + environment[key] + os.linesep) if exitCode not in expectedExitCodes: lastOutput = "" type = "" diff --git a/packaging-tools/bldinstallercommon.py b/packaging-tools/bldinstallercommon.py index 54a4abf5c..f3e9aab5f 100644 --- a/packaging-tools/bldinstallercommon.py +++ b/packaging-tools/bldinstallercommon.py @@ -113,7 +113,7 @@ def retrieve_url(url, savefile): print(exc) try: os.remove(savefile_tmp) - except: #swallow, do not shadow actual error + except: # swallow, do not shadow actual error pass raise exc @@ -193,7 +193,7 @@ def remove_one_tree_level(directory): full_dir_name = os.path.join(directory, dir_name) # avoid directory name collision by first moving to temporary dir tempdir_base = tempfile.mkdtemp() - tempdir = os.path.join(tempdir_base, 'a') # dummy name + tempdir = os.path.join(tempdir_base, 'a') # dummy name shutil.move(full_dir_name, tempdir) move_tree(tempdir, directory) remove_tree(tempdir_base) @@ -206,7 +206,7 @@ def remove_one_tree_level(directory): def handle_remove_readonly(func, path, exc): excvalue = exc[1] if func in (os.rmdir, os.remove) and excvalue.errno == errno.EACCES: - os.chmod(path, stat.S_IRWXU| stat.S_IRWXG| stat.S_IRWXO) # 0777 + os.chmod(path, stat.S_IRWXU| stat.S_IRWXG| stat.S_IRWXO) # 0777 func(path) else: raise @@ -215,14 +215,14 @@ def remove_tree(path): if os.path.isdir(path) and os.path.exists(path): if is_windows(): path = win32api.GetShortPathName(path.replace('/', '\\')) - #a funny thing is that rmdir does not set an exitcode it is just using the last set one + # a funny thing is that rmdir does not set an exitcode it is just using the last set one try: runCommand(['rmdir', path, '/S', '/Q'], os.getcwd(), onlyErrorCaseOutput=True) except: traceback.print_exc() pass else: - #shutil.rmtree(path) + # shutil.rmtree(path) runCommand(['rm', '-rf', path], os.getcwd(), onlyErrorCaseOutput=True) return not os.path.exists(path) @@ -477,9 +477,9 @@ def handle_component_rpath(component_root_path, destination_lib_paths): rp = ':'.join(rpaths) if sanity_check_rpath_max_length(file_full_path, rp): - #print ' RPath value: [' + rp + '] for file: [' + file_full_path + ']' + # print ' RPath value: [' + rp + '] for file: [' + file_full_path + ']' cmd_args = ['chrpath', '-r', rp, file_full_path] - #force silent operation + # force silent operation work_dir = os.path.dirname(os.path.realpath(__file__)) do_execute_sub_process(cmd_args, work_dir) @@ -629,9 +629,9 @@ def create_mac_disk_image(execution_path, file_directory, file_base_name, image_ ############################### def rename_android_soname_files(qt5_base_path): print ('---------- Renaming .so name files in ' + qt5_base_path + ' ----------------') - ## QTBUG-33793 + # QTBUG-33793 # temporary solution for Android on Windows compilations - ## rename the .so files for Android on Windows + # rename the .so files for Android on Windows # find the lib directory under the install directory for essentials try: print ('Trying to locate /lib from: ' + qt5_base_path) diff --git a/packaging-tools/build_clang.py b/packaging-tools/build_clang.py index d7f20eb77..29c33ac1d 100644 --- a/packaging-tools/build_clang.py +++ b/packaging-tools/build_clang.py @@ -123,7 +123,7 @@ def build_environment(toolchain, bitness): environment['CXX'] = 'cl' return environment else: - return None # == process environment + return None # == process environment def training_qt_version(): qt_ver = os.environ.get('TRAINING_QT_VERSION') @@ -362,11 +362,11 @@ def build_clang(toolchain, src_path, build_path, install_path, profile_data_path install_targets = ['install/strip'] if is_msvc_toolchain(toolchain): - install_targets = ['install'] # There is no 'install/strip' for nmake. + install_targets = ['install'] # There is no 'install/strip' for nmake. if profile_data_path and first_run: build_targets = ['libclang'] - install_targets = ['tools/clang/tools/libclang/install/strip'] # we only want to build / install libclang + install_targets = ['tools/clang/tools/libclang/install/strip'] # we only want to build / install libclang build_and_install(toolchain, build_path, environment, build_targets, install_targets) @@ -393,7 +393,7 @@ def build_clazy(toolchain, src_path, build_path, install_path, bitness=64, envir install_targets = ['install/strip'] if is_msvc_toolchain(toolchain): - install_targets = ['install'] # There is no 'install/strip' for nmake. + install_targets = ['install'] # There is no 'install/strip' for nmake. build_and_install(toolchain, build_path, environment, [], install_targets) def check_clang(toolchain, build_path, environment): @@ -471,7 +471,7 @@ def main(): remote_path = (get_pkg_value("PACKAGE_STORAGE_SERVER_USER") + '@' + get_pkg_value("PACKAGE_STORAGE_SERVER") + ':' + os.environ['PACKAGE_STORAGE_SERVER_BASE_DIR'] + '/' + os.environ['CLANG_UPLOAD_SERVER_PATH']) - ### Get, build and install LLVM/Clang + # Get, build and install LLVM/Clang get_clang(base_path, os.environ['LLVM_REPOSITORY_URL'], os.environ['LLVM_REVISION']) # TODO: put args in some struct to improve readability, add error checks @@ -500,7 +500,7 @@ def main(): build_clang(toolchain, src_path, build_path_training, install_path, profile_data_path, False, bitness, environment, build_type='Release') - ### Get, build and install clazy + # Get, build and install clazy git_clone_and_checkout(base_path, os.environ['CLAZY_REPOSITORY_URL'], 'clazy', @@ -512,7 +512,7 @@ def main(): bitness, environment) - ### Package and upload + # Package and upload result_file_path = os.path.join(base_path, 'libclang-' + branch + '-' + os.environ['CLANG_PLATFORM'] + '.7z') package_clang(install_path, result_file_path) upload_clang(result_file_path, remote_path) diff --git a/packaging-tools/build_clang_qdoc.py b/packaging-tools/build_clang_qdoc.py index 32fa9ad32..f3a636fea 100644 --- a/packaging-tools/build_clang_qdoc.py +++ b/packaging-tools/build_clang_qdoc.py @@ -116,7 +116,7 @@ def build_environment(toolchain, bitness): environment['CXX'] = 'cl' return environment else: - return None # == process environment + return None # == process environment def is_msvc_toolchain(toolchain): return 'msvc' in toolchain @@ -206,7 +206,7 @@ def build_clang(toolchain, src_path, build_path, install_path, bitness=64, envir do_execute_sub_process(cmake_cmd, build_path, extra_env=environment) build_targets = ['install/strip'] if is_msvc_toolchain(toolchain): - build_targets = ['install'] # There is no 'install/strip' for nmake. + build_targets = ['install'] # There is no 'install/strip' for nmake. build_and_install(toolchain, build_path, environment, ['libclang', 'clang', 'llvm-config'], build_targets) def check_clang(toolchain, build_path, environment): diff --git a/packaging-tools/build_wrapper.py b/packaging-tools/build_wrapper.py index 43af54f5a..dbbe63a26 100644 --- a/packaging-tools/build_wrapper.py +++ b/packaging-tools/build_wrapper.py @@ -57,7 +57,7 @@ from runner import do_execute_sub_process # ---------------------------------------------------------------------- SCRIPT_ROOT_DIR = os.path.dirname(os.path.realpath(__file__)) WORK_DIR = os.getenv('PKG_NODE_ROOT') if os.getenv("PKG_NODE_ROOT") else os.path.abspath(os.path.join(__file__, '../../../')) -LOCAL_MODE = os.getenv('LOCAL_MODE') # if set, installers will be copied to a local directory +LOCAL_MODE = os.getenv('LOCAL_MODE') # if set, installers will be copied to a local directory LOCAL_INSTALLER_DIR = os.getenv('LOCAL_INSTALLER_DIR', os.path.join(WORK_DIR, 'installers')) if LOCAL_MODE: @@ -131,7 +131,7 @@ def handle_qt_licheck_build(optionDict): cmd_args = ['rsync', '-r', 'licheck_mac', upload_path +'licheck_mac'] do_execute_sub_process(cmd_args, exe_dir, True) else: - #opensource, do nothing + # opensource, do nothing print('*** opensource build, nothing to build ...') @@ -549,27 +549,27 @@ def handle_qt_creator_build(optionDict, qtCreatorPlugins): scheme = "" if urlparse(pkg_base_path).scheme != "" else "file://" pkg_base_path = scheme + pkg_base_path pkg_storage_server = optionDict['PACKAGE_STORAGE_SERVER_ADDR'] - qtcreator_edition_name = optionDict.get('QT_CREATOR_EDITION_NAME') # optional + qtcreator_edition_name = optionDict.get('QT_CREATOR_EDITION_NAME') # optional unversioned_base_path = optionDict['PACKAGE_STORAGE_SERVER_BASE_DIR'] + '/' + optionDict['QTC_BASE_DIR'] base_path = unversioned_base_path + '/' + qtcreator_version if qtcreator_edition_name: base_path += '_' + qtcreator_edition_name - snapshot_server = optionDict.get('SNAPSHOT_SERVER') # optional - snapshot_path = optionDict['SNAPSHOT_SERVER_PATH'] # optional + snapshot_server = optionDict.get('SNAPSHOT_SERVER') # optional + snapshot_path = optionDict['SNAPSHOT_SERVER_PATH'] # optional qt_base_path = optionDict['QTC_QT_BASE_DIR'] - ide_branding_path = optionDict.get('IDE_BRANDING_PATH') # optional - installer_patch = optionDict.get('INSTALLER_PATCH') # optional - skip_cdb = optionDict.get('SKIP_CDB') # optional - skip_dmg = optionDict.get('SKIP_DMG') # optional + ide_branding_path = optionDict.get('IDE_BRANDING_PATH') # optional + installer_patch = optionDict.get('INSTALLER_PATCH') # optional + skip_cdb = optionDict.get('SKIP_CDB') # optional + skip_dmg = optionDict.get('SKIP_DMG') # optional build_id = optionDict['BUILD_NUMBER'] - icu_libs = optionDict.get('ICU_LIBS') # optional - openssl_libs = optionDict.get('OPENSSL_LIBS') # optional - openssl_local_url = None # optionally defined later - qt_extra_module_url = optionDict.get('QT_EXTRA_MODULE_URL') # optional + icu_libs = optionDict.get('ICU_LIBS') # optional + openssl_libs = optionDict.get('OPENSSL_LIBS') # optional + openssl_local_url = None # optionally defined later + qt_extra_module_url = optionDict.get('QT_EXTRA_MODULE_URL') # optional qt_postfix = os.environ['QT_POSTFIX'] - sdktool_base = optionDict.get('SDKTOOL_QTBASESRC_BASE') # optional - sdktool_ext = optionDict.get('SDKTOOL_QTBASESRC_EXT') # optional - sdktool_qtbase_src = sdktool_base + sdktool_ext if sdktool_base and sdktool_ext else None # optional + sdktool_base = optionDict.get('SDKTOOL_QTBASESRC_BASE') # optional + sdktool_ext = optionDict.get('SDKTOOL_QTBASESRC_EXT') # optional + sdktool_qtbase_src = sdktool_base + sdktool_ext if sdktool_base and sdktool_ext else None # optional download_temp = os.path.join(work_dir, 'downloads') has_unlock_keychain_script = os.path.exists(unlock_keychain_script()) # from 4.4 on we use external elfutil builds and also build on Windows @@ -578,8 +578,8 @@ def handle_qt_creator_build(optionDict, qtCreatorPlugins): notarize = optionDict.get('NOTARIZE') usp_server_url = optionDict.get('USP_SERVER_URL') usp_auth_key = optionDict.get('USP_AUTH_KEY') - qtc_additional_config = optionDict.get('QTC_ADDITIONAL_CONFIG') # optional - disable_docs = optionDict.get('DISABLE_DOCS') # optional + qtc_additional_config = optionDict.get('QTC_ADDITIONAL_CONFIG') # optional + disable_docs = optionDict.get('DISABLE_DOCS') # optional if qtc_additional_config: qtc_additional_config = qtc_additional_config.split() qt_temp = os.path.join(work_dir, 'qt_temp') @@ -615,7 +615,7 @@ def handle_qt_creator_build(optionDict, qtCreatorPlugins): clang_platform = optionDict.get('CLANG_PLATFORM') if clang_filebase and clang_platform: clang_extract_path = os.path.join(download_temp, 'libclang') - llvm_install_dir = os.path.join(clang_extract_path, 'libclang') # package contains libclang subdir + llvm_install_dir = os.path.join(clang_extract_path, 'libclang') # package contains libclang subdir clang_suffix = optionDict.get('CLANG_FILESUFFIX') clang_suffix = clang_suffix if clang_suffix is not None else '' clang_url = (pkg_base_path + '/' + optionDict['CLANG_FILEBASE'] + '-' + clang_platform + clang_suffix + '.7z') @@ -773,7 +773,7 @@ def handle_qt_creator_build(optionDict, qtCreatorPlugins): # Build Qt Creator plugins icu_local_url = bld_utils.file_url(os.path.join(qt_temp, os.path.basename(icu_libs))) if is_linux() else None - ## extract qtcreator bin and dev packages + # extract qtcreator bin and dev packages qtcreator_path = os.path.join(work_dir, 'qtc_build') check_call_log(['7z', 'x', '-y', os.path.join(work_dir, 'qt-creator_build', 'qtcreator.7z'), '-o' + qtcreator_path], work_dir, log_filepath=log_filepath) @@ -841,8 +841,8 @@ def handle_qt_creator_build(optionDict, qtCreatorPlugins): notarizeDmg(os.path.join(work_dir, 'qt-creator_build', 'qt-creator.dmg'), 'Qt Creator') # Upload - file_upload_list = [] # pairs (source, dest), source relative to WORK_DIR, dest relative to server + dir_path - snapshot_upload_list = [] # pairs (source, dest), source relative to server + dir_path, dest relative to snapshot server + snapshot_path + file_upload_list = [] # pairs (source, dest), source relative to WORK_DIR, dest relative to server + dir_path + snapshot_upload_list = [] # pairs (source, dest), source relative to server + dir_path, dest relative to snapshot server + snapshot_path # build log file_upload_list.append((log_filepath, target_env_dir + '/build_log.txt')) @@ -933,7 +933,7 @@ def handle_sdktool_build(optionDict): target_env_dir = optionDict['QTC_PLATFORM'] work_dir = optionDict['WORK_DIR'] qtcreator_version = get_qtcreator_version(os.path.join(work_dir, 'qt-creator'), optionDict) - qtcreator_edition_name = optionDict.get('QT_CREATOR_EDITION_NAME') # optional + qtcreator_edition_name = optionDict.get('QT_CREATOR_EDITION_NAME') # optional unversioned_base_path = (optionDict['PACKAGE_STORAGE_SERVER_BASE_DIR'] + '/' + optionDict['QTC_BASE_DIR']) base_path = unversioned_base_path + '/' + qtcreator_version @@ -952,7 +952,7 @@ def handle_sdktool_build(optionDict): 'nmake' if is_windows() else 'make') bld_sdktool.zip_sdktool(sdktool_target_path, os.path.join(work_dir, 'sdktool.7z')) file_upload_list = [('sdktool.7z', target_env_dir + '/sdktool.7z')] - if is_windows(): # wininterrupt & qtcreatorcdbext + if is_windows(): # wininterrupt & qtcreatorcdbext cmd_args = [sys.executable, '-u', os.path.join(qtcreator_src, 'scripts', 'build.py'), '--src', qtcreator_src, '--build', os.path.join(work_dir, 'build'), @@ -1072,7 +1072,7 @@ def initPkgOptions(args): if LOCAL_MODE: from getpass import getuser - optionDict['PACKAGE_STORAGE_SERVER_USER'] = getuser() # current user + optionDict['PACKAGE_STORAGE_SERVER_USER'] = getuser() # current user optionDict['PACKAGE_STORAGE_SERVER'] = "127.0.0.1" optionDict['PACKAGE_STORAGE_SERVER_ADDR'] = optionDict['PACKAGE_STORAGE_SERVER_USER'] + "@" + optionDict['PACKAGE_STORAGE_SERVER'] optionDict['PACKAGE_STORAGE_SERVER_BASE_DIR'] = LOCAL_INSTALLER_DIR diff --git a/packaging-tools/create_installer.py b/packaging-tools/create_installer.py index 6165e4edb..cfeaf0d20 100644 --- a/packaging-tools/create_installer.py +++ b/packaging-tools/create_installer.py @@ -38,7 +38,7 @@ import re import subprocess from time import gmtime, strftime import argparse -import multiprocessing # to get the cpu core count +import multiprocessing # to get the cpu core count from bld_utils import is_windows, is_macos, is_linux if is_windows(): import win32api @@ -422,7 +422,7 @@ def get_component_data(task, sdk_component, archive, install_dir, data_dir_dest, # lastly compress the component back to .7z archive content_list = os.listdir(compress_content_dir) - #adding compress_content_dir in front of every item + # adding compress_content_dir in front of every item content_list = [(compress_content_dir + os.sep + x) for x in content_list] saveas = os.path.normpath(data_dir_dest + os.sep + archive.archive_name) @@ -634,7 +634,7 @@ def qml_examples_only(examples_dir): log.error("Archive not cleaned!") return subdir_list = [] - regex = re.compile('^qml\S.*') # pylint: disable=W1401 + regex = re.compile('^qml\S.*') # pylint: disable=W1401 for root, dirs, _ in os.walk(examples_dir): for basename in dirs: if regex.search(basename): diff --git a/packaging-tools/dump_debug_infos.py b/packaging-tools/dump_debug_infos.py index bbde55875..f23de2564 100644 --- a/packaging-tools/dump_debug_infos.py +++ b/packaging-tools/dump_debug_infos.py @@ -161,5 +161,5 @@ def _main(): return if __name__ == '__main__': -# use everything capsulated in functions to make sure we are not using module globals + # use everything capsulated in functions to make sure we are not using module globals _main() diff --git a/packaging-tools/environmentfrombatchfile.py b/packaging-tools/environmentfrombatchfile.py index ddfeaa62e..cf857618b 100644 --- a/packaging-tools/environmentfrombatchfile.py +++ b/packaging-tools/environmentfrombatchfile.py @@ -34,14 +34,14 @@ import subprocess import os # http://stackoverflow.com/questions/1214496/how-to-get-environment-from-a-subprocess-in-python -#def validate_pair(ob): -# try: -# if not (len(ob) == 2): -# print("Unexpected result:", ob, file = sys.stderr) -# raise ValueError -# except: -# return False -# return True +# def validate_pair(ob): +# try: +# if not (len(ob) == 2): +# print("Unexpected result:", ob, file = sys.stderr) +# raise ValueError +# except: +# return False +# return True def consume(iterator): try: @@ -75,10 +75,10 @@ def get(env_cmd, initial = None, arguments = None): if not os.path.lexists(env_cmd): raise Exception("Can not find {0} to get an environment from it.".format(env_cmd)) - #if not isinstance(env_cmd, (list, tuple)): - # env_cmd = [env_cmd] + # if not isinstance(env_cmd, (list, tuple)): + # env_cmd = [env_cmd] # construct the command that will alter the environment - #env_cmd = subprocess.list2cmdline(env_cmd) + # env_cmd = subprocess.list2cmdline(env_cmd) # create a tag so we can tell in the output when the proc is done tag = 'Done running command' diff --git a/packaging-tools/install_qt.py b/packaging-tools/install_qt.py index 5397159f5..32f9545b4 100644 --- a/packaging-tools/install_qt.py +++ b/packaging-tools/install_qt.py @@ -66,7 +66,7 @@ def get_arguments(): print('either --qt-module or --base-url and module_name(s) are required') exit(1) - args.qt_modules = args.qt_modules if args.qt_modules else [] # ensure list + args.qt_modules = args.qt_modules if args.qt_modules else [] # ensure list args.qt_modules += [args.base_url + '/' + module + '/' + module + args.base_url_postfix for module in args.module_name] diff --git a/packaging-tools/libclang_training/libclangtimings2csv.py b/packaging-tools/libclang_training/libclangtimings2csv.py index 1b275eb54..d7ef915fe 100644 --- a/packaging-tools/libclang_training/libclangtimings2csv.py +++ b/packaging-tools/libclang_training/libclangtimings2csv.py @@ -90,7 +90,7 @@ def extractRecords(fileContent): record = [recordId, timeNeededInMs] records.append(record) - #for record in records: print record + # for record in records: print record return records def recordsToString(records): diff --git a/packaging-tools/libclang_training/mergeCsvFiles.py b/packaging-tools/libclang_training/mergeCsvFiles.py index 5680e4fdf..9cddb597b 100644 --- a/packaging-tools/libclang_training/mergeCsvFiles.py +++ b/packaging-tools/libclang_training/mergeCsvFiles.py @@ -70,8 +70,8 @@ def readCsvFiles(filePaths): for row in reader: values.append(row) - tag = values[0][0] # remember column label - values = values[1:] # skip header + tag = values[0][0] # remember column label + values = values[1:] # skip header myFile = FileWithValues(filePath, tag, values) files.append(myFile) diff --git a/packaging-tools/libclang_training/runBatchFiles.py b/packaging-tools/libclang_training/runBatchFiles.py index ec0122e94..370aa6d1e 100644 --- a/packaging-tools/libclang_training/runBatchFiles.py +++ b/packaging-tools/libclang_training/runBatchFiles.py @@ -80,7 +80,7 @@ def checkExitCodeOrDie(exitCode, args): class Config: Verbose = False - #Verbose = True + # Verbose = True LogDir = None QtCreatorSettingsDir = None @@ -131,7 +131,7 @@ class RunRecord: def __init__(self, libClangId, batchFilePath): self.libClangId = libClangId parts = os.path.basename(batchFilePath).split('.') - self.batchFileId = '.'.join(parts[0:-1]) # Remove suffix + self.batchFileId = '.'.join(parts[0:-1]) # Remove suffix self.logFilePath = self.batchFileId + '___' + libClangId + '.log' self.csvFilePath = None diff --git a/packaging-tools/tests/test_runCommand.py b/packaging-tools/tests/test_runCommand.py index f6412637e..a09f45944 100644 --- a/packaging-tools/tests/test_runCommand.py +++ b/packaging-tools/tests/test_runCommand.py @@ -32,7 +32,7 @@ import ctypes import time import sys import unittest -import argparse # commandline argument parser +import argparse # commandline argument parser import os if sys.platform.startswith("win"): @@ -41,9 +41,9 @@ if sys.platform.startswith("win"): # How to suppress crash notification dialog?, Jan 14,2004 - # Raymond Chen's response [1] - SEM_NOGPFAULTERRORBOX = 0x0002 # From MSDN + SEM_NOGPFAULTERRORBOX = 0x0002 # From MSDN ctypes.windll.kernel32.SetErrorMode(SEM_NOGPFAULTERRORBOX); - subprocess_flags = 0x8000000 #win32con.CREATE_NO_WINDOW? + subprocess_flags = 0x8000000 # win32con.CREATE_NO_WINDOW? def baseCommand(): return " ".join([sys.executable,os.path.abspath(__file__)]) @@ -85,13 +85,13 @@ class TestRunCommand(unittest.TestCase): def test_Crash_onlyErrorCaseOutput(self): with self.assertRaises(Exception) as contextManager: useRunCommand("--printLines 10 --crash", os.getcwd(), - #callerArguments= + # callerArguments= None, - #extra_environment= + # extra_environment= None, - #onlyErrorCaseOutput= + # onlyErrorCaseOutput= True, - #expectedExitCodes= + # expectedExitCodes= [0]) self.assertIsNotNone(contextManager) self.assertIsNotNone(contextManager.exception) @@ -104,13 +104,13 @@ class TestRunCommand(unittest.TestCase): def test_differentExitCode_onlyErrorCaseOutput(self): self.assertEqual(useRunCommand("--printLines 10 --exitCode 5", os.getcwd(), - #callerArguments= + # callerArguments= None, - #extra_environment= + # extra_environment= None, - #onlyErrorCaseOutput= + # onlyErrorCaseOutput= True, - #expectedExitCodes= + # expectedExitCodes= [0,5]), 5) def test_withThreadedWork(self): @@ -184,5 +184,5 @@ if __name__ == '__main__': if callerArguments.exitCode: os._exit(callerArguments.exitCode) if callerArguments.testMethod: - #python test_runCommand.py --testMethod test_Crash_onlyErrorCaseOutput + # python test_runCommand.py --testMethod test_Crash_onlyErrorCaseOutput TestRunCommand(methodName=callerArguments.testMethod).debug() diff --git a/packaging-tools/threadedwork.py b/packaging-tools/threadedwork.py index 659ef6f9f..ef2d156d6 100644 --- a/packaging-tools/threadedwork.py +++ b/packaging-tools/threadedwork.py @@ -123,7 +123,7 @@ class TaskFunction(): class Task(): def __init__(self, description, function = None, *arguments): - self.taskNumber = 0 # will be set from outside + self.taskNumber = 0 # will be set from outside self.description = description self.listOfFunctions = [] if function: @@ -198,10 +198,10 @@ class ThreadedWork(): for consumer in listOfConsumers: while consumer.is_alive(): try: - #wait 1 second, then go back and ask if thread is still alive + # wait 1 second, then go back and ask if thread is still alive time.sleep(1) - except KeyboardInterrupt: #if ctrl-C is pressed within that second, - #catch the KeyboardInterrupt exception + except KeyboardInterrupt: # if ctrl-C is pressed within that second, + # catch the KeyboardInterrupt exception sys.exit(0) # self.queue.join() <- this ignoring the KeyboardInterrupt if maxThreads > 1: |