autobuild-run: check-requirements does not need to know the login details
PATCH 1/8 autobuild-run: check-requirements does not need to know the login details
From: Thomas De Schampheleire <[email protected]>
check-requirements simply has to know if the results have to be sent, so it can check on some extra requirements. The username and password are irrelevant here.
This commit introduces a boolean variable do_send_results to hide these details.
--- scripts/autobuild-run | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
scripts/autobuild-run +5 -4
@@ -85,12 +85,12 @@ def check_version(): print "ERROR: script version too old, please upgrade." sys.exit(1) -def check_requirements(http_login, http_password): +def check_requirements(do_send_results=False): devnull = open(os.devnull, "w") needed_progs = ["make", "git", "gcc", "timeout"] missing_requirements = False - if http_login and http_password: + if do_send_results: needed_progs.append("curl") for prog in needed_progs:
@@ -553,8 +553,9 @@ if __name__ == '__main__': check_version() sysinfo = SystemInfo() (ninstances, njobs, http_login, http_password, submitter) = config_get() - check_requirements(http_login, http_password) - if http_login is None or http_password is None: + do_send_results = http_login and http_password + check_requirements(do_send_results) + if not do_send_results: print "WARN: due to the lack of http login/password details, results will not be submitted" print "WARN: tarballs of results will be kept locally only" def sigterm_handler(signum, frame):
Signature · 1 line
1.8.5.1
PATCH 2/8 scripts: add python module docopt
From: Thomas De Schampheleire <[email protected]>
This commit adds the 'docopt' python module, version 0.6.1. Original source is: https://github.com/docopt/docopt
Since docopt stands on its own, only the .py file and the license is added, other files from github are skipped.
The __init__.py file is added to allow treating docopt as a package (and thus keep the files in a separate directory).
--- scripts/docopt/LICENSE-MIT | 23 ++ scripts/docopt/__init__.py | 0 scripts/docopt/docopt.py | 581 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 604 insertions(+) create mode 100644 scripts/docopt/LICENSE-MIT create mode 100644 scripts/docopt/__init__.py create mode 100644 scripts/docopt/docopt.py
scripts/docopt/LICENSE-MIT new file +23 -0
@@ -0,0 +1,23 @@ +Copyright (c) 2012 Vladimir Keleshev, <[email protected]> + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to +whom the Software is furnished to do so, subject to the +following conditions: + +The above copyright notice and this permission notice shall +be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
scripts/docopt/__init__.py new file +0 -0
scripts/docopt/docopt.py new file +581 -0
581 lines not on this page · raw message
Signature · 1 line
1.8.5.1
PATCH 3/8 autobuild-run: use docopt for argument parsing
In reply to Thomas De SchampheleireFrom: Thomas De Schampheleire <[email protected]>
Using docopt, argument parsing becomes trivial. Adding a new argument is a matter of updating the usage text.
This commit removes the original cumbersome argument handling and uses docopt instead. A method is added to import the settings from the configuration file in a similar dictionary as the one created by docopt, so that both can be merged (giving priority to the configuration file, as before).
With these changes, each option can be passed as argument and in the configuration file. This means that http-user and http-password can now also be added as argument (even though passing the password on the command-line is not recommended).
--- scripts/autobuild-run | 131 ++++++++++++++++++++++++++------------------------ 1 file changed, 69 insertions(+), 62 deletions(-)
scripts/autobuild-run +69 -62
@@ -57,6 +57,37 @@ # BR2_PACKAGE_CLASSPATH=y, improve the script to detect whether the # necessary host machine requirements are there to build classpath. +"""autobuild-run - run Buildroot autobuilder + +Usage: autobuild-run [options] + +Options: + -h, --help show this help message and exit + -V, --version show version + -n, --ninstances NINSTANCES number of parallel instances [default: 1] + -j, --njobs NJOBS number of parallel jobs [default: 1] + -s, --submitter SUBMITTER name/machine of submitter [default: N/A] + --http-login LOGIN username to send results with + --http-password PASSWORD password to send results with (for security + reasons it is recommended to define this in the + config file instead, with user-read permissions + only) + -c, --config CONFIG path to configuration file + +Format of the configuration file: + + All arguments can also be specified in the configuration file specified with + --config, using 'key = value' format (not including the leading -- + characters). For example: + + [main] + ninstances = <value> + njobs = <value> + http-login = <value> + http-password = <value> + submitter = <value> +""" + import urllib2 import csv from random import randint
@@ -70,6 +101,7 @@ import sys import hashlib import argparse import ConfigParser +from docopt import docopt MAX_DURATION = 60 * 60 * 4 VERSION = 1
@@ -488,72 +520,45 @@ def run_instance(instance, njobs, http_login, http_password, submitter, sysinfo) ret = do_build(instance, njobs, instance_log) send_results(instance, http_login, http_password, submitter, instance_log, ret) -# Function to get the configuration parameters, either from the -# command line, or through a configuration file. -def config_get(): - epilog_text = """ -Format of the configuration file: +# args / config file merging inspired by: +# https://github.com/docopt/docopt/blob/master/examples/config_file_example.py +def load_ini_config(configfile): + if not os.path.exists(configfile): + print "ERROR: configuration file %s does not exist" % configfile + sys.exit(1) - [main] - ninstances = <value> - njobs = <value> - http-login = <value> - http-password = <value> - submitter = <value> -""" + config = ConfigParser.RawConfigParser() + if not config.read(configfile): + print "ERROR: cannot parse configuration file %s" % configfile + sys.exit(1) - parser = argparse.ArgumentParser(description='Run Buildroot autobuilder', - formatter_class=argparse.RawDescriptionHelpFormatter, - epilog=epilog_text) - parser.add_argument("--ninstances", '-n', metavar="NINSTANCES", - help="Number of parallel instances", default=None) - parser.add_argument("--njobs", '-j', metavar="NJOBS", - help="Number of parallel jobs", default=None) - parser.add_argument("--submitter", '-s', metavar="SUBMITTER", - help="Name/machine of submitter") - parser.add_argument("--config", '-c', metavar="CONFIG", - help="Path to configuration file") - args = parser.parse_args() - - ninstances = 1 - njobs = 1 - http_login = None - http_password = None - submitter = "N/A" - - if args.config: - if not os.path.exists(args.config): - print "ERROR: configuration file %s does not exist" % args.config - sys.exit(1) - parser = ConfigParser.RawConfigParser() - if not parser.read([args.config]): - print "ERROR: cannot parse configuration file %s" % args.config - sys.exit(1) - if parser.has_option('main', 'ninstances'): - ninstances = parser.getint('main', 'ninstances') - if parser.has_option('main', 'njobs'): - njobs = parser.getint('main', 'njobs') - if parser.has_option('main', 'http-login'): - http_login = parser.get('main', 'http-login') - if parser.has_option('main', 'http-password'): - http_password = parser.get('main', 'http-password') - if parser.has_option('main', 'submitter'): - submitter = parser.get('main', 'submitter') - - if args.njobs: - njobs = int(args.njobs) - if args.ninstances: - ninstances = int(args.ninstances) - if args.submitter: - submitter = args.submitter - - return (ninstances, njobs, http_login, http_password, submitter) + # Prepend '--' to options specified in the config file, so they can be + # merged with those given on the command-line + return dict(('--%s' % key, value) for key, value in config.items('main')) + + +def merge(dict_1, dict_2): + """Merge two dictionaries. + + Values that evaluate to true take priority over falsy values. + `dict_1` takes priority over `dict_2`. + + """ + return dict((str(key), dict_1.get(key) or dict_2.get(key)) + for key in set(dict_2) | set(dict_1)) if __name__ == '__main__': check_version() sysinfo = SystemInfo() - (ninstances, njobs, http_login, http_password, submitter) = config_get() - do_send_results = http_login and http_password + + args = docopt.docopt(__doc__, version=VERSION) + + if args['--config']: + ini_config = load_ini_config(args['--config']) + # merge config/args, priority given to config + args = merge(ini_config, args) + + do_send_results = args['--http-login'] and args['--http-password'] check_requirements(do_send_results) if not do_send_results: print "WARN: due to the lack of http login/password details, results will not be submitted"
@@ -562,8 +567,10 @@ if __name__ == '__main__': os.killpg(os.getpgid(os.getpid()), signal.SIGTERM) sys.exit(1) processes = [] - for i in range(0, ninstances): - p = Process(target=run_instance, args=(i, njobs, http_login, http_password, submitter, sysinfo)) + for i in range(0, int(args['--ninstances'])): + p = Process(target=run_instance, args=(i, int(args['--njobs']), + args['--http-login'], args['--http-password'], + args['--submitter'], sysinfo)) p.start() processes.append(p) signal.signal(signal.SIGTERM, sigterm_handler)
Signature · 1 line
1.8.5.1
PATCH 4/8 autobuild-run: convert regular function comments into docstrings
In reply to Thomas De SchampheleireFrom: Thomas De Schampheleire <[email protected]>
Documenting a function in Python is done with docstrings, rather than with comments above the function. The conventions are described in
PEP257: http://legacy.python.org/dev/peps/pep-0257/
--- scripts/autobuild-run | 75 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 26 deletions(-)
scripts/autobuild-run +49 -26
@@ -156,13 +156,16 @@ class SystemInfo: self.has_jar = \ subprocess.call(["which", "jar"], stdout=devnull, stderr=devnull) == 0 -# This function fetches the possible toolchain configurations, and -# returns an array of dictionaries, with for each toolchain: -# - url: the URL of the toolchain defconfig -# - libc: the C library used by the toolchain -# - hostarch: the host architecture for which the toolchain is built -# - contents: an array of lines of the defconfig def get_toolchain_configs(): + """Fetch and return the possible toolchain configurations + + This function returns an array of dictionaries, with for each toolchain: + - url: the URL of the toolchain defconfig + - libc: the C library used by the toolchain + - hostarch: the host architecture for which the toolchain is built + - contents: an array of lines of the defconfig + """ + r = urllib2.urlopen('http://autobuild.buildroot.org/toolchains/configs/toolchain-configs.csv') l = r.readlines() configs = []
@@ -183,10 +186,14 @@ def get_toolchain_configs(): configs.append(config) return configs -# This function prepares the build by making sure all the needed -# directories are created, cloning or updating the Buildroot source -# code, and cleaning up remaining stuff from previous builds. def prepare_build(instance, log): + """Prepare for the next build of the specified instance + + This function prepares the build by making sure all the needed + directories are created, cloning or updating the Buildroot source + code, and cleaning up remaining stuff from previous builds. + """ + idir = "instance-%d" % instance log_write(log, "INFO: preparing a new build")
@@ -236,14 +243,15 @@ def prepare_build(instance, log): return 0 -# This function makes adjustments to the configuration, as well as -# additional validation to avoid cases that are known not to work. -# -# This function returns 'True' when the configuration has been -# accepted, and 'False' when the configuration has not been accepted -# (in which case another random configuration will be generated). - def fixup_config(instance, sysinfo): + """Finalize the configuration and reject any problematic combinations + + This function returns 'True' when the configuration has been + accepted, and 'False' when the configuration has not been accepted because + it is known to fail (in which case another random configuration will be + generated). + """ + idir = "instance-%d" % instance outputdir = os.path.join(idir, "output")
@@ -322,10 +330,14 @@ def fixup_config(instance, sysinfo): return True -# This function generates the configuration, by choosing a random -# toolchain configuration and then generating a random selection of -# packages. def gen_config(instance, log, sysinfo): + """Generate a new random configuration + + This function generates the configuration, by choosing a random + toolchain configuration and then generating a random selection of + packages. + """ + idir = "instance-%d" % instance dldir = os.path.join(idir, "dl") # We need the absolute path to use with O=, because the relative
@@ -394,8 +406,9 @@ def gen_config(instance, log, sysinfo): return 0 -# Run the build itself def do_build(instance, njobs, log): + """Run the build itself""" + idir = "instance-%d" % instance # We need the absolute path to use with O=, because the relative # path to the output directory here is not relative to the
@@ -423,10 +436,14 @@ def do_build(instance, njobs, log): log_write(log, "INFO: build successful") return 0 -# This function prepares the tarball with the results, and either -# submits them to the official server (if the appropriate credentials -# are available) or stores them locally as tarballs. def send_results(instance, http_login, http_password, submitter, log, result): + """Prepare and store/send tarball with results + + This function prepares the tarball with the results, and either + submits them to the official server (if the appropriate credentials + are available) or stores them locally as tarballs. + """ + idir = "instance-%d" % instance outputdir = os.path.abspath(os.path.join(idir, "output")) srcdir = os.path.join(idir, "buildroot")
@@ -494,10 +511,13 @@ def send_results(instance, http_login, http_password, submitter, log, result): os.rename(os.path.join(outputdir, "results.tar.bz2"), resultfilename) log_write(log, "INFO: results saved as %s" % resultfilename) -# This function implements the main per-instance loop, which prepares -# the build, generate a configuration, runs the build, and submits the -# results. def run_instance(instance, njobs, http_login, http_password, submitter, sysinfo): + """Main per-instance loop + + Prepare the build, generate a configuration, run the build, and submit the + results. + """ + idir = "instance-%d" % instance # If it doesn't exist, create the instance directory
@@ -522,7 +542,10 @@ def run_instance(instance, njobs, http_login, http_password, submitter, sysinfo) # args / config file merging inspired by: # https://github.com/docopt/docopt/blob/master/examples/config_file_example.py + def load_ini_config(configfile): + """Load configuration from file, returning a docopt-like dictionary""" + if not os.path.exists(configfile): print "ERROR: configuration file %s does not exist" % configfile sys.exit(1)
Signature · 1 line
1.8.5.1
PATCH 5/8 autobuild-run: add option --make-opts for custom Buildroot options
In reply to Thomas De SchampheleireFrom: Thomas De Schampheleire <[email protected]>
In some environments, the Buildroot configuration may need minor tweaking. For example, in corporate environments behind a firewall, direct git access (as required by some packages) may not be possible. A git wrapper may be needed, which is normally configured through the BR2_GIT configuration option.
Since these tweaks are very environment-specific, they should not be part of the configuration file itself. Otherwise, other people trying to reproduce the build in another environment will see builds failing due to other reasons, for example the git wrapper not being found.
This commit provides a new configuration option 'make-opts', passable as argument or in the config file, that accepts a string of make options to pass to the Buildroot make command. For example:
--make-opts="BR2_GIT=git-wrapper BR2_svn=svn-wrapper"
--- scripts/autobuild-run | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
scripts/autobuild-run +11 -6
@@ -72,6 +72,8 @@ Options: reasons it is recommended to define this in the config file instead, with user-read permissions only) + --make-opts OPTSTRING string of extra options to pass to Buildroot + make, such as specific command wrappers -c, --config CONFIG path to configuration file Format of the configuration file:
@@ -406,7 +408,7 @@ def gen_config(instance, log, sysinfo): return 0 -def do_build(instance, njobs, log): +def do_build(instance, njobs, log, make_opts): """Run the build itself""" idir = "instance-%d" % instance
@@ -419,8 +421,10 @@ def do_build(instance, njobs, log): srcdir = os.path.join(idir, "buildroot") f = open(os.path.join(outputdir, "logfile"), "w+") log_write(log, "INFO: build started") - ret = subprocess.call(["timeout", str(MAX_DURATION), "make", "O=%s" % outputdir, "-C", srcdir, - "BR2_DL_DIR=%s" % dldir, "BR2_JLEVEL=%s" % njobs], stdout=f, stderr=f) + cmd = ["timeout", str(MAX_DURATION), "make", "O=%s" % outputdir, + "-C", srcdir, "BR2_DL_DIR=%s" % dldir, "BR2_JLEVEL=%s" % njobs] \ + + make_opts.split() + ret = subprocess.call(cmd, stdout=f, stderr=f) # 124 is a special error code that indicates we have reached the # timeout if ret == 124:
@@ -511,7 +515,8 @@ def send_results(instance, http_login, http_password, submitter, log, result): os.rename(os.path.join(outputdir, "results.tar.bz2"), resultfilename) log_write(log, "INFO: results saved as %s" % resultfilename) -def run_instance(instance, njobs, http_login, http_password, submitter, sysinfo): +def run_instance(instance, njobs, http_login, http_password, submitter, + make_opts, sysinfo): """Main per-instance loop Prepare the build, generate a configuration, run the build, and submit the
@@ -537,7 +542,7 @@ def run_instance(instance, njobs, http_login, http_password, submitter, sysinfo) if ret != 0: continue - ret = do_build(instance, njobs, instance_log) + ret = do_build(instance, njobs, instance_log, make_opts) send_results(instance, http_login, http_password, submitter, instance_log, ret) # args / config file merging inspired by:
@@ -593,7 +598,7 @@ if __name__ == '__main__': for i in range(0, int(args['--ninstances'])): p = Process(target=run_instance, args=(i, int(args['--njobs']), args['--http-login'], args['--http-password'], - args['--submitter'], sysinfo)) + args['--submitter'], args['--make-opts'], sysinfo)) p.start() processes.append(p) signal.signal(signal.SIGTERM, sigterm_handler)
Signature · 1 line
1.8.5.1
PATCH 5/8 autobuild-run: add option --make-opts for custom Buildroot options
Quoted 46 lines · Thomas De Schampheleire
From: Thomas De Schampheleire <[email protected]>
In some environments, the Buildroot configuration may need minor tweaking. For example, in corporate environments behind a firewall, direct git access (as required by some packages) may not be possible. A git wrapper may be needed, which is normally configured through the
BR2_GITconfiguration option.Since these tweaks are very environment-specific, they should not be part of the configuration file itself. Otherwise, other people trying to reproduce the build in another environment will see builds failing due to other reasons, for example the git wrapper not being found.
This commit provides a new configuration option 'make-opts', passable as argument or in the config file, that accepts a string of make options to pass to the Buildroot make command. For example:
--make-opts="BR2_GIT=git-wrapper BR2_svn=svn-wrapper"Signed-off-by Thomas De Schampheleire <[email protected]>--- scripts/autobuild-run | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)scripts/autobuild-run +3
-1@@ -72,6 +72,8 @@ Options: reasons it is recommended to define this in the config file instead, with user-read permissions only) + --make-opts OPTSTRING string of extra options to pass to Buildroot + make, such as specific command wrappers -c, --config CONFIG path to configuration file Format of the configuration file:@@ -406,7 +408,7 @@ def gen_config(instance, log, sysinfo): return 0 -def do_build(instance, njobs, log): +def do_build(instance, njobs, log, make_opts): """Run the build itself""" idir = "instance-%d" % instance
scripts/autobuild-run def do_build(instance, njobs, log): · line 426
Quoted 8 lines
scripts/autobuild-run +3
-2@@ -419,8 +421,10 @@ def do_build(instance, njobs, log): srcdir = os.path.join(idir, "buildroot") f = open(os.path.join(outputdir, "logfile"), "w+") log_write(log, "INFO: build started") - ret = subprocess.call(["timeout", str(MAX_DURATION), "make", "O=%s" % outputdir, "-C", srcdir, - "BR2_DL_DIR=%s" % dldir, "BR2_JLEVEL=%s" % njobs], stdout=f, stderr=f) + cmd = ["timeout", str(MAX_DURATION), "make", "O=%s" % outputdir, + "-C", srcdir, "BR2_DL_DIR=%s" % dldir, "BR2_JLEVEL=%s" % njobs] \ + + make_opts.split()
This line currently fails if no make opts are provided, will fix.
Best regards,
Thomas
PATCH 6/8 autobuild-run: create main method to locally-scope all variables
In reply to Thomas De SchampheleireFrom: Thomas De Schampheleire <[email protected]>
In the current autobuild-run script, all variables created in the 'main' part are in fact global, even though the script does not intend them to be. For example, sysinfo is global, even though it is passed as function argument to run_instance.
To avoid this accidental globalization, create a main method instead. All variables created therein are now local to that method.
--- scripts/autobuild-run | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/autobuild-run +4 -1
@@ -575,7 +575,7 @@ def merge(dict_1, dict_2): return dict((str(key), dict_1.get(key) or dict_2.get(key)) for key in set(dict_2) | set(dict_1)) -if __name__ == '__main__': +def main(): check_version() sysinfo = SystemInfo()
@@ -604,3 +604,6 @@ if __name__ == '__main__': signal.signal(signal.SIGTERM, sigterm_handler) for p in processes: p.join() + +if __name__ == '__main__': + main()
Signature · 1 line
1.8.5.1
PATCH 6/8 autobuild-run: create main method to locally-scope all variables
Thomas, All,
On 2014-10-16 21:16 +0200, Thomas De Schampheleire spake thusly:
Quoted 11 lines
From: Thomas De Schampheleire <[email protected]>
In the current autobuild-run script, all variables created in the 'main' part are in fact global, even though the script does not intend them to be. For example, sysinfo is global, even though it is passed as function argument to
run_instance.To avoid this accidental globalization, create a main method instead. All variables created therein are now local to that method.
Signed-off-by Thomas De Schampheleire <[email protected]>
For what it's worth:
;-)
Regards,
Yann E. MORIN.
Quoted 31 lines
--- scripts/autobuild-run | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)scripts/autobuild-run +4
-1@@ -575,7 +575,7 @@ def merge(dict_1, dict_2): return dict((str(key), dict_1.get(key) or dict_2.get(key)) for key in set(dict_2) | set(dict_1)) -if __name__ == '__main__': +def main(): check_version() sysinfo = SystemInfo()@@ -604,3 +604,6 @@ if __name__ == '__main__': signal.signal(signal.SIGTERM, sigterm_handler) for p in processes: p.join() + +if __name__ == '__main__': + main()Signature · 6 lines
1.8.5.1 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 6/8 autobuild-run: create main method to locally-scope all variables
Hi Yann, Thomas, all
Quoted 67 lines · Yann E. MORIN
Thomas, All,
On 2014-10-16 21:16 +0200, Thomas De Schampheleire spake thusly:
Quoted 11 lines
From: Thomas De Schampheleire <[email protected]>
In the current autobuild-run script, all variables created in the 'main' part are in fact global, even though the script does not intend them to be. For example, sysinfo is global, even though it is passed as function argument to
run_instance.To avoid this accidental globalization, create a main method instead. All variables created therein are now local to that method.
Signed-off-by Thomas De Schampheleire <[email protected]>For what it's worth:
Reviewed-by "Yann E. MORIN" <[email protected]>;-)
Regards,
Yann E. MORIN.Quoted 27 lines
--- scripts/autobuild-run | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)scripts/autobuild-run +4
-2@@ -575,7 +575,7 @@ def merge(dict_1, dict_2): return dict((str(key), dict_1.get(key) or dict_2.get(key)) for key in set(dict_2) | set(dict_1)) -if __name__ == '__main__': +def main(): check_version() sysinfo = SystemInfo()@@ -604,3 +604,6 @@ if __name__ == '__main__': signal.signal(signal.SIGTERM, sigterm_handler) for p in processes: p.join() + +if __name__ == '__main__': + main() --1.8.5.1
Quoted 4 lines
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot--
.-----------------.--------------------.------------------.--------------------.| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
PATCH 7/8 autobuild-run: use **kwargs to avoid explicit parameter passthroughs
In reply to Thomas De SchampheleireFrom: Thomas De Schampheleire <[email protected]>
The current version of autobuild-run has some extensive explicit parameter passing, for example:
- fixup_config needs sysinfo, passed via gen_config, in turn via run_instance, in turn via main.
- send_results needs username/password settings, passed via run_instance, in turn via main.
Everytime a leaf function needs an extra parameter (for example coming from the arguments or config file), the entire call chain needs to be adapted to pass along that parameter.
This patch introduces the **kwargs dictionary principle, that allows implicit parameter passing. A function can accept this dictionary and extract parameters from it by name. The dictionary can be passed as a whole to a child function, without explicitly enumerating which entries in the dictionary are needed in the child.
--- scripts/autobuild-run | 71 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 29 deletions(-)
scripts/autobuild-run +42 -29
@@ -188,7 +188,7 @@ def get_toolchain_configs(): configs.append(config) return configs -def prepare_build(instance, log): +def prepare_build(**kwargs): """Prepare for the next build of the specified instance This function prepares the build by making sure all the needed
@@ -196,7 +196,8 @@ def prepare_build(instance, log): code, and cleaning up remaining stuff from previous builds. """ - idir = "instance-%d" % instance + idir = "instance-%d" % kwargs['instance'] + log = kwargs['log'] log_write(log, "INFO: preparing a new build")
@@ -245,7 +246,7 @@ def prepare_build(instance, log): return 0 -def fixup_config(instance, sysinfo): +def fixup_config(**kwargs): """Finalize the configuration and reject any problematic combinations This function returns 'True' when the configuration has been
@@ -254,9 +255,10 @@ def fixup_config(instance, sysinfo): generated). """ - idir = "instance-%d" % instance - outputdir = os.path.join(idir, "output") + idir = "instance-%d" % kwargs['instance'] + sysinfo = kwargs['sysinfo'] + outputdir = os.path.join(idir, "output") with open(os.path.join(outputdir, ".config")) as configf: configlines = configf.readlines()
@@ -332,7 +334,7 @@ def fixup_config(instance, sysinfo): return True -def gen_config(instance, log, sysinfo): +def gen_config(**kwargs): """Generate a new random configuration This function generates the configuration, by choosing a random
@@ -340,7 +342,9 @@ def gen_config(instance, log, sysinfo): packages. """ - idir = "instance-%d" % instance + idir = "instance-%d" % kwargs['instance'] + log = kwargs['log'] + dldir = os.path.join(idir, "dl") # We need the absolute path to use with O=, because the relative # path to the output directory here is not relative to the
@@ -391,7 +395,7 @@ def gen_config(instance, log, sysinfo): if ret != 0: log_write(log, "ERROR: cannot generate random configuration") return -1 - if fixup_config(instance, sysinfo): + if fixup_config(**kwargs): break ret = subprocess.call(["yes '' 2>/dev/null| make O=%s -C %s oldconfig" % \
@@ -408,10 +412,12 @@ def gen_config(instance, log, sysinfo): return 0 -def do_build(instance, njobs, log, make_opts): +def do_build(**kwargs): """Run the build itself""" - idir = "instance-%d" % instance + idir = "instance-%d" % kwargs['instance'] + log = kwargs['log'] + # We need the absolute path to use with O=, because the relative # path to the output directory here is not relative to the # Buildroot sources, but to the location of the autobuilder
@@ -422,8 +428,9 @@ def do_build(instance, njobs, log, make_opts): f = open(os.path.join(outputdir, "logfile"), "w+") log_write(log, "INFO: build started") cmd = ["timeout", str(MAX_DURATION), "make", "O=%s" % outputdir, - "-C", srcdir, "BR2_DL_DIR=%s" % dldir, "BR2_JLEVEL=%s" % njobs] \ - + make_opts.split() + "-C", srcdir, "BR2_DL_DIR=%s" % dldir, + "BR2_JLEVEL=%s" % kwargs['njobs']] \ + + kwargs['make_opts'].split() ret = subprocess.call(cmd, stdout=f, stderr=f) # 124 is a special error code that indicates we have reached the # timeout
@@ -440,7 +447,7 @@ def do_build(instance, njobs, log, make_opts): log_write(log, "INFO: build successful") return 0 -def send_results(instance, http_login, http_password, submitter, log, result): +def send_results(result, **kwargs): """Prepare and store/send tarball with results This function prepares the tarball with the results, and either
@@ -448,7 +455,9 @@ def send_results(instance, http_login, http_password, submitter, log, result): are available) or stores them locally as tarballs. """ - idir = "instance-%d" % instance + idir = "instance-%d" % kwargs['instance'] + log = kwargs['log'] + outputdir = os.path.abspath(os.path.join(idir, "output")) srcdir = os.path.join(idir, "buildroot") resultdir = os.path.join(outputdir, "results")
@@ -483,7 +492,7 @@ def send_results(instance, http_login, http_password, submitter, log, result): resultf.close() with open(os.path.join(resultdir, "submitter"), "w+") as submitterf: - submitterf.write(submitter) + submitterf.write(kwargs['submitter']) # Yes, shutil.make_archive() would be nice, but it doesn't exist # in Python 2.6.
@@ -493,11 +502,12 @@ def send_results(instance, http_login, http_password, submitter, log, result): log_write(log, "ERROR: could not make results tarball") sys.exit(1) - if http_login and http_password: + if kwargs['http_login'] and kwargs['http_password']: # Submit results. Yes, Python has some HTTP libraries, but # none of the ones that are part of the standard library can # upload a file without writing dozens of lines of code. - ret = subprocess.call(["curl", "-u", "%s:%s" % (http_login, http_password), + ret = subprocess.call(["curl", "-u", + "%s:%s" % (kwargs['http_login'], kwargs['http_password']), "-H", "Expect:", "-F", "uploadedfile=@%s" % os.path.join(outputdir, "results.tar.bz2"), "-F", "uploadsubmit=1",
@@ -515,35 +525,36 @@ def send_results(instance, http_login, http_password, submitter, log, result): os.rename(os.path.join(outputdir, "results.tar.bz2"), resultfilename) log_write(log, "INFO: results saved as %s" % resultfilename) -def run_instance(instance, njobs, http_login, http_password, submitter, - make_opts, sysinfo): +def run_instance(**kwargs): """Main per-instance loop Prepare the build, generate a configuration, run the build, and submit the results. """ - idir = "instance-%d" % instance + idir = "instance-%d" % kwargs['instance'] # If it doesn't exist, create the instance directory if not os.path.exists(idir): os.mkdir(idir) - instance_log = open(os.path.join(idir, "instance.log"), "a+") - log_write(instance_log, "INFO: instance started") + kwargs['log'] = open(os.path.join(idir, "instance.log"), "a+") + log_write(kwargs['log'], "INFO: instance started") + while True: check_version() - ret = prepare_build(instance, instance_log) + ret = prepare_build(**kwargs) if ret != 0: continue - ret = gen_config(instance, instance_log, sysinfo) + ret = gen_config(**kwargs) if ret != 0: continue - ret = do_build(instance, njobs, instance_log, make_opts) - send_results(instance, http_login, http_password, submitter, instance_log, ret) + ret = do_build(**kwargs) + + send_results(ret, **kwargs) # args / config file merging inspired by: # https://github.com/docopt/docopt/blob/master/examples/config_file_example.py
@@ -596,9 +607,11 @@ def main(): sys.exit(1) processes = [] for i in range(0, int(args['--ninstances'])): - p = Process(target=run_instance, args=(i, int(args['--njobs']), - args['--http-login'], args['--http-password'], - args['--submitter'], args['--make-opts'], sysinfo)) + p = Process(target=run_instance, kwargs={ + 'instance': i, 'njobs': args['--njobs'], 'sysinfo': sysinfo, + 'http_login': args['--http-login'], + 'http_password': args['--http-password'], + 'submitter': args['--submitter'], 'make_opts': args['--make-opts']}) p.start() processes.append(p) signal.signal(signal.SIGTERM, sigterm_handler)
Signature · 1 line
1.8.5.1
PATCH 7/8 autobuild-run: use **kwargs to avoid explicit parameter passthroughs
Quoted 232 lines · Thomas De Schampheleire
From: Thomas De Schampheleire <[email protected]>
The current version of autobuild-run has some extensive explicit parameter passing, for example:
-
fixup_configneeds sysinfo, passed viagen_config, in turn viarun_instance, in turn via main.
-send_resultsneeds username/password settings, passed viarun_instance, in turn via main.Everytime a leaf function needs an extra parameter (for example coming from the arguments or config file), the entire call chain needs to be adapted to pass along that parameter.
This patch introduces the **kwargs dictionary principle, that allows implicit parameter passing. A function can accept this dictionary and extract parameters from it by name. The dictionary can be passed as a whole to a child function, without explicitly enumerating which entries in the dictionary are needed in the child.
Signed-off-by Thomas De Schampheleire <[email protected]>--- scripts/autobuild-run | 71 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 29 deletions(-)scripts/autobuild-run +42
-30@@ -188,7 +188,7 @@ def get_toolchain_configs(): configs.append(config) return configs -def prepare_build(instance, log): +def prepare_build(**kwargs): """Prepare for the next build of the specified instance This function prepares the build by making sure all the needed@@ -196,7 +196,8 @@ def prepare_build(instance, log): code, and cleaning up remaining stuff from previous builds. """ - idir = "instance-%d" % instance + idir = "instance-%d" % kwargs['instance'] + log = kwargs['log'] log_write(log, "INFO: preparing a new build")@@ -245,7 +246,7 @@ def prepare_build(instance, log): return 0 -def fixup_config(instance, sysinfo): +def fixup_config(**kwargs): """Finalize the configuration and reject any problematic combinations This function returns 'True' when the configuration has been@@ -254,9 +255,10 @@ def fixup_config(instance, sysinfo): generated). """ - idir = "instance-%d" % instance - outputdir = os.path.join(idir, "output") + idir = "instance-%d" % kwargs['instance'] + sysinfo = kwargs['sysinfo'] + outputdir = os.path.join(idir, "output") with open(os.path.join(outputdir, ".config")) as configf: configlines = configf.readlines()@@ -332,7 +334,7 @@ def fixup_config(instance, sysinfo): return True -def gen_config(instance, log, sysinfo): +def gen_config(**kwargs): """Generate a new random configuration This function generates the configuration, by choosing a random@@ -340,7 +342,9 @@ def gen_config(instance, log, sysinfo): packages. """ - idir = "instance-%d" % instance + idir = "instance-%d" % kwargs['instance'] + log = kwargs['log'] + dldir = os.path.join(idir, "dl") # We need the absolute path to use with O=, because the relative # path to the output directory here is not relative to the@@ -391,7 +395,7 @@ def gen_config(instance, log, sysinfo): if ret != 0: log_write(log, "ERROR: cannot generate random configuration") return -1 - if fixup_config(instance, sysinfo): + if fixup_config(**kwargs): break ret = subprocess.call(["yes '' 2>/dev/null| make O=%s -C %s oldconfig" % \@@ -408,10 +412,12 @@ def gen_config(instance, log, sysinfo): return 0 -def do_build(instance, njobs, log, make_opts): +def do_build(**kwargs): """Run the build itself""" - idir = "instance-%d" % instance + idir = "instance-%d" % kwargs['instance'] + log = kwargs['log'] + # We need the absolute path to use with O=, because the relative # path to the output directory here is not relative to the # Buildroot sources, but to the location of the autobuilder@@ -422,8 +428,9 @@ def do_build(instance, njobs, log, make_opts): f = open(os.path.join(outputdir, "logfile"), "w+") log_write(log, "INFO: build started") cmd = ["timeout", str(MAX_DURATION), "make", "O=%s" % outputdir, - "-C", srcdir, "BR2_DL_DIR=%s" % dldir, "BR2_JLEVEL=%s" % njobs] \ - + make_opts.split() + "-C", srcdir, "BR2_DL_DIR=%s" % dldir, + "BR2_JLEVEL=%s" % kwargs['njobs']] \ + + kwargs['make_opts'].split() ret = subprocess.call(cmd, stdout=f, stderr=f) # 124 is a special error code that indicates we have reached the # timeout@@ -440,7 +447,7 @@ def do_build(instance, njobs, log, make_opts): log_write(log, "INFO: build successful") return 0 -def send_results(instance, http_login, http_password, submitter, log, result): +def send_results(result, **kwargs): """Prepare and store/send tarball with results This function prepares the tarball with the results, and either@@ -448,7 +455,9 @@ def send_results(instance, http_login, http_password, submitter, log, result): are available) or stores them locally as tarballs. """ - idir = "instance-%d" % instance + idir = "instance-%d" % kwargs['instance'] + log = kwargs['log'] + outputdir = os.path.abspath(os.path.join(idir, "output")) srcdir = os.path.join(idir, "buildroot") resultdir = os.path.join(outputdir, "results")@@ -483,7 +492,7 @@ def send_results(instance, http_login, http_password, submitter, log, result): resultf.close() with open(os.path.join(resultdir, "submitter"), "w+") as submitterf: - submitterf.write(submitter) + submitterf.write(kwargs['submitter']) # Yes, shutil.make_archive() would be nice, but it doesn't exist # in Python 2.6.@@ -493,11 +502,12 @@ def send_results(instance, http_login, http_password, submitter, log, result): log_write(log, "ERROR: could not make results tarball") sys.exit(1) - if http_login and http_password: + if kwargs['http_login'] and kwargs['http_password']: # Submit results. Yes, Python has some HTTP libraries, but # none of the ones that are part of the standard library can # upload a file without writing dozens of lines of code. - ret = subprocess.call(["curl", "-u", "%s:%s" % (http_login, http_password), + ret = subprocess.call(["curl", "-u", + "%s:%s" % (kwargs['http_login'], kwargs['http_password']), "-H", "Expect:", "-F", "uploadedfile=@%s" % os.path.join(outputdir, "results.tar.bz2"), "-F", "uploadsubmit=1",@@ -515,35 +525,36 @@ def send_results(instance, http_login, http_password, submitter, log, result): os.rename(os.path.join(outputdir, "results.tar.bz2"), resultfilename) log_write(log, "INFO: results saved as %s" % resultfilename) -def run_instance(instance, njobs, http_login, http_password, submitter, - make_opts, sysinfo): +def run_instance(**kwargs): """Main per-instance loop Prepare the build, generate a configuration, run the build, and submit the results. """ - idir = "instance-%d" % instance + idir = "instance-%d" % kwargs['instance'] # If it doesn't exist, create the instance directory if not os.path.exists(idir): os.mkdir(idir) - instance_log = open(os.path.join(idir, "instance.log"), "a+") - log_write(instance_log, "INFO: instance started") + kwargs['log'] = open(os.path.join(idir, "instance.log"), "a+") + log_write(kwargs['log'], "INFO: instance started") + while True: check_version() - ret = prepare_build(instance, instance_log) + ret = prepare_build(**kwargs) if ret != 0: continue - ret = gen_config(instance, instance_log, sysinfo) + ret = gen_config(**kwargs) if ret != 0: continue - ret = do_build(instance, njobs, instance_log, make_opts) - send_results(instance, http_login, http_password, submitter, instance_log, ret) + ret = do_build(**kwargs) + + send_results(ret, **kwargs) # args / config file merging inspired by: # https://github.com/docopt/docopt/blob/master/examples/config_file_example.py@@ -596,9 +607,11 @@ def main(): sys.exit(1) processes = [] for i in range(0, int(args['--ninstances'])): - p = Process(target=run_instance, args=(i, int(args['--njobs']), - args['--http-login'], args['--http-password'], - args['--submitter'], args['--make-opts'], sysinfo)) + p = Process(target=run_instance, kwargs={ + 'instance': i, 'njobs': args['--njobs'], 'sysinfo': sysinfo, + 'http_login': args['--http-login'], + 'http_password': args['--http-password'], + 'submitter': args['--submitter'], 'make_opts': args['--make-opts']}) p.start() processes.append(p) signal.signal(signal.SIGTERM, sigterm_handler) --
Quoted 1 line
1.8.5.1
In this patch, one occurrence of 'instance' is not correctly substituted with kwargs['instance']. I will fix this.
Clearly, some longer testing is needed with this patch set, but getting your feedback on the principles already is good.
PATCH 8/8 autobuild-run: add support for custom git wrapper
In reply to Thomas De SchampheleireFrom: Thomas De Schampheleire <[email protected]>
In corporate environments, there may be no direct git access, and a wrapper program that sets a proxy may be needed. See [1] for an example solution.
This patch to autobuild-run provides a --git argument that can be used to set the path to such a git wrapper. By default, the argument is plain 'git'.
[1] http://gitolite.com/git-over-proxy.html
--- scripts/autobuild-run | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
scripts/autobuild-run +8 -5
@@ -74,6 +74,9 @@ Options: only) --make-opts OPTSTRING string of extra options to pass to Buildroot make, such as specific command wrappers + --git GITCMD path to git program (possibly a wrapper) used + to clone the Buildroot repository + [default: git] -c, --config CONFIG path to configuration file Format of the configuration file:
@@ -224,7 +227,7 @@ def prepare_build(**kwargs): # didn't exist already. srcdir = os.path.join(idir, "buildroot") if not os.path.exists(srcdir): - ret = subprocess.call(["git", "clone", "git://git.busybox.net/buildroot", srcdir], + ret = subprocess.call([kwargs['git'], "clone", "git://git.busybox.net/buildroot", srcdir], stdout=log, stderr=log) if ret != 0: log_write(log, "ERROR: could not clone Buildroot sources")
@@ -232,7 +235,7 @@ def prepare_build(**kwargs): # Update the Buildroot sources. abssrcdir = os.path.abspath(srcdir) - ret = subprocess.call(["git", "pull"], cwd=srcdir, stdout=log, stderr=log) + ret = subprocess.call([kwargs['git'], "pull"], cwd=srcdir, stdout=log, stderr=log) if ret != 0: log_write(log, "ERROR: could not pull Buildroot sources") return -1
@@ -475,8 +478,8 @@ def send_results(result, **kwargs): shutil.copyfile(os.path.join(outputdir, "legal-info", "manifest.csv"), os.path.join(resultdir, "licenses-manifest.csv")) - subprocess.call(["git log master -n 1 --pretty=format:%%H > %s" % \ - os.path.join(resultdir, "gitid")], + subprocess.call(["%s log master -n 1 --pretty=format:%%H > %s" % \ + (kwargs['git'], os.path.join(resultdir, "gitid"))], shell=True, cwd=srcdir) subprocess.call(["tail -500 %s > %s" % \ (os.path.join(outputdir, "logfile"), os.path.join(resultdir, "build-end.log"))],
@@ -610,7 +613,7 @@ def main(): p = Process(target=run_instance, kwargs={ 'instance': i, 'njobs': args['--njobs'], 'sysinfo': sysinfo, 'http_login': args['--http-login'], - 'http_password': args['--http-password'], + 'http_password': args['--http-password'], 'git': args['--git'], 'submitter': args['--submitter'], 'make_opts': args['--make-opts']}) p.start() processes.append(p)
Signature · 1 line
1.8.5.1
PATCH 8/8 autobuild-run: add support for custom git wrapper
Thomas, All,
On 2014-10-16 21:16 +0200, Thomas De Schampheleire spake thusly:
Quoted 11 lines
From: Thomas De Schampheleire <[email protected]>
In corporate environments, there may be no direct git access, and a wrapper program that sets a proxy may be needed. See [1] for an example solution.
This patch to autobuild-run provides a --git argument that can be used to set the path to such a git wrapper. By default, the argument is plain 'git'.
You know you can make this stick, right?
git config --global --add core.gitproxy /path/to/git-proxy-command
And then you're done once and for all. ;-)
Regards,
Yann E. MORIN.
Quoted 64 lines
Signed-off-by Thomas De Schampheleire <[email protected]>--- scripts/autobuild-run | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)scripts/autobuild-run +8
-5@@ -74,6 +74,9 @@ Options: only) --make-opts OPTSTRING string of extra options to pass to Buildroot make, such as specific command wrappers + --git GITCMD path to git program (possibly a wrapper) used + to clone the Buildroot repository + [default: git] -c, --config CONFIG path to configuration file Format of the configuration file:@@ -224,7 +227,7 @@ def prepare_build(**kwargs): # didn't exist already. srcdir = os.path.join(idir, "buildroot") if not os.path.exists(srcdir): - ret = subprocess.call(["git", "clone", "git://git.busybox.net/buildroot", srcdir], + ret = subprocess.call([kwargs['git'], "clone", "git://git.busybox.net/buildroot", srcdir], stdout=log, stderr=log) if ret != 0: log_write(log, "ERROR: could not clone Buildroot sources")@@ -232,7 +235,7 @@ def prepare_build(**kwargs): # Update the Buildroot sources. abssrcdir = os.path.abspath(srcdir) - ret = subprocess.call(["git", "pull"], cwd=srcdir, stdout=log, stderr=log) + ret = subprocess.call([kwargs['git'], "pull"], cwd=srcdir, stdout=log, stderr=log) if ret != 0: log_write(log, "ERROR: could not pull Buildroot sources") return -1@@ -475,8 +478,8 @@ def send_results(result, **kwargs): shutil.copyfile(os.path.join(outputdir, "legal-info", "manifest.csv"), os.path.join(resultdir, "licenses-manifest.csv")) - subprocess.call(["git log master -n 1 --pretty=format:%%H > %s" % \ - os.path.join(resultdir, "gitid")], + subprocess.call(["%s log master -n 1 --pretty=format:%%H > %s" % \ + (kwargs['git'], os.path.join(resultdir, "gitid"))], shell=True, cwd=srcdir) subprocess.call(["tail -500 %s > %s" % \ (os.path.join(outputdir, "logfile"), os.path.join(resultdir, "build-end.log"))],@@ -610,7 +613,7 @@ def main(): p = Process(target=run_instance, kwargs={ 'instance': i, 'njobs': args['--njobs'], 'sysinfo': sysinfo, 'http_login': args['--http-login'], - 'http_password': args['--http-password'], + 'http_password': args['--http-password'], 'git': args['--git'], 'submitter': args['--submitter'], 'make_opts': args['--make-opts']}) p.start() processes.append(p)Signature · 6 lines
1.8.5.1 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 8/8 autobuild-run: add support for custom git wrapper
Dear Yann E. MORIN,
Quoted 5 lines · Yann E. MORIN
You know you can make this stick, right?
git config --global --add core.gitproxy /path/to/git-proxy-commandAnd then you're done once and for all. ;-)
Yes, I was also wondering why a change to each and every git invocation was needed: surely like wget there should be a way to configure git to use a proxy.
With what Yann has given, Thomas, do you still need this patch?
Thanks,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 8/8 autobuild-run: add support for custom git wrapper
Hi,
Quoted 8 lines · Thomas Petazzoni
Dear Yann E. MORIN,
Quoted 4 lines · Yann E. MORIN
You know you can make this stick, right?
git config --global --add core.gitproxy /path/to/git-proxy-command
Quoted 8 lines
Quoted 1 line
And then you're done once and for all. ;-)
Yes, I was also wondering why a change to each and every git invocation was needed: surely like wget there should be a way to configure git to use a proxy.
With what Yann has given, Thomas, do you still need this patch?
Hmm, yes indeed.
On my laptop, I don't want to do that as I need/don't need the proxy depending on if I'm connected to the company network or not. But in case of an autobuilder it's not the case.
So yes, I will drop this patch.
Thanks,
Thomas
PATCH 1/8 autobuild-run: check-requirements does not need to know the login details
In reply to Thomas De SchampheleireThomas, All,
On 2014-10-16 21:15 +0200, Thomas De Schampheleire spake thusly:
Quoted 33 lines
From: Thomas De Schampheleire <[email protected]>
check-requirements simply has to know if the results have to be sent, so it can check on some extra requirements. The username and password are irrelevant here.
This commit introduces a boolean variabledo_send_resultsto hide these details.Signed-off-by Thomas De Schampheleire <[email protected]>--- scripts/autobuild-run | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)scripts/autobuild-run +2
-2@@ -85,12 +85,12 @@ def check_version(): print "ERROR: script version too old, please upgrade." sys.exit(1) -def check_requirements(http_login, http_password): +def check_requirements(do_send_results=False): devnull = open(os.devnull, "w") needed_progs = ["make", "git", "gcc", "timeout"] missing_requirements = False - if http_login and http_password: + if do_send_results: needed_progs.append("curl") for prog in needed_progs:
scripts/autobuild-run if __name__ == '__main__': · line 556
Quoted 6 lines
scripts/autobuild-run +1
-2@@ -553,8 +553,9 @@ if __name__ == '__main__': check_version() sysinfo = SystemInfo() (ninstances, njobs, http_login, http_password, submitter) = config_get() - check_requirements(http_login, http_password) - if http_login is None or http_password is None: + do_send_results = http_login and http_password
I was told that we should no treat 'None' as 'False', or a non-empty string as 'True'. This should be something like:
do_send_results = (not http_login is None) and (not http_password is None)
Regards,
Yann E. MORIN.
Quoted 12 lines
scripts/autobuild-run +2
-0+ check_requirements(do_send_results) + if not do_send_results: print "WARN: due to the lack of http login/password details, results will not be submitted" print "WARN: tarballs of results will be kept locally only" def sigterm_handler(signum, frame):Signature · 6 lines
1.8.5.1 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 1/8 autobuild-run: check-requirements does not need to know the login details
Hi Yann, Thomas, All
Quoted 34 lines · Yann E. MORIN
Thomas, All,
On 2014-10-16 21:15 +0200, Thomas De Schampheleire spake thusly:
Quoted 31 lines
From: Thomas De Schampheleire <[email protected]>
check-requirements simply has to know if the results have to be sent, so it can check on some extra requirements. The username and password are irrelevant here.
This commit introduces a boolean variabledo_send_resultsto hide these details.Signed-off-by Thomas De Schampheleire <[email protected]>--- scripts/autobuild-run | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)scripts/autobuild-run +2
-2@@ -85,12 +85,12 @@ def check_version(): print "ERROR: script version too old, please upgrade." sys.exit(1) -def check_requirements(http_login, http_password): +def check_requirements(do_send_results=False): devnull = open(os.devnull, "w") needed_progs = ["make", "git", "gcc", "timeout"] missing_requirements = False - if http_login and http_password: + if do_send_results: needed_progs.append("curl")
Quoted 11 lines
scripts/autobuild-run if __name__ == '__main__': · line 556
Quoted 8 lines
scripts/autobuild-run +1
-2for prog in needed_progs:@@ -553,8 +553,9 @@ if __name__ == '__main__': check_version() sysinfo = SystemInfo() (ninstances, njobs, http_login, http_password, submitter) = config_get() - check_requirements(http_login, http_password) - if http_login is None or http_password is None: + do_send_results = http_login and http_passwordI was told that we should no treat 'None' as 'False', or a non-empty string as 'True'. This should be something like:'
You can treat 'None' as 'False' and also a non empty string will value a logical 'True'.
In a python interpreter, do bool(None) and bool('blabla'), you'll respectively get 'False' and 'True'.
I hope I am not the one you told you that in the first place...
Quoted 30 lines
do_send_results= (nothttp_loginis None) and (nothttp_passwordis None)Regards,
Yann E. MORIN.Quoted 8 lines
scripts/autobuild-run +2
-1+ check_requirements(do_send_results) + if not do_send_results: print "WARN: due to the lack of http login/password details, results will not be submitted" print "WARN: tarballs of results will be kept locally only" def sigterm_handler(signum, frame): --1.8.5.1
Quoted 4 lines
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot--
.-----------------.--------------------.------------------.--------------------.| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
PATCH 1/8 autobuild-run: check-requirements does not need to know the login details
Maxime, All,
On 2014-10-18 12:15 +0200, Maxime Hadjinlian spake thusly:
Quoted 46 lines · Yann E. MORIN
Quoted 34 lines
Thomas, All,
On 2014-10-16 21:15 +0200, Thomas De Schampheleire spake thusly:
Quoted 31 lines
From: Thomas De Schampheleire <[email protected]>
check-requirements simply has to know if the results have to be sent, so it can check on some extra requirements. The username and password are irrelevant here.
This commit introduces a boolean variabledo_send_resultsto hide these details.Signed-off-by Thomas De Schampheleire <[email protected]>--- scripts/autobuild-run | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)scripts/autobuild-run +2
-2@@ -85,12 +85,12 @@ def check_version(): print "ERROR: script version too old, please upgrade." sys.exit(1) -def check_requirements(http_login, http_password): +def check_requirements(do_send_results=False): devnull = open(os.devnull, "w") needed_progs = ["make", "git", "gcc", "timeout"] missing_requirements = False - if http_login and http_password: + if do_send_results: needed_progs.append("curl")Quoted 11 lines
scripts/autobuild-run if __name__ == '__main__': · line 556
Quoted 8 lines
scripts/autobuild-run +1
-2for prog in needed_progs:@@ -553,8 +553,9 @@ if __name__ == '__main__': check_version() sysinfo = SystemInfo() (ninstances, njobs, http_login, http_password, submitter) = config_get() - check_requirements(http_login, http_password) - if http_login is None or http_password is None: + do_send_results = http_login and http_passwordI was told that we should no treat 'None' as 'False', or a non-empty string as 'True'. This should be something like:'
Quoted 6 lines
You can treat 'None' as 'False' and also a non empty string will value a logical 'True'.
In a python interpreter, do bool(None) and bool('blabla'), you'll respectively get 'False' and 'True'.I hope I am not the one you told you that in the first place...
Not sure it was Samuel or you, but I just looked at PEP8:
http://legacy.python.org/dev/peps/pep-0008/#programming-recommendations
Comparisons to singletons like None should always be done with is or is not, never the equality operators.
Also, beware of writing if x when you really mean if x is not None -- e.g. when testing whether a variable or argument that defaults to None was set to some other value. The other value might have a type (such as a container) that could be false in a boolean context!
Regards,
Yann E. MORIN.
Quoted 29 lines
Quoted 29 lines
do_send_results= (nothttp_loginis None) and (nothttp_passwordis None)Regards,
Yann E. MORIN.Quoted 8 lines
scripts/autobuild-run +2
-1+ check_requirements(do_send_results) + if not do_send_results: print "WARN: due to the lack of http login/password details, results will not be submitted" print "WARN: tarballs of results will be kept locally only" def sigterm_handler(signum, frame): --1.8.5.1
Quoted 4 lines
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot--
.-----------------.--------------------.------------------.--------------------.| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 1/8 autobuild-run: check-requirements does not need to know the login details
Quoted 60 lines · Yann E. MORIN
Maxime, All,
On 2014-10-18 12:15 +0200, Maxime Hadjinlian spake thusly:
Quoted 46 lines · Yann E. MORIN
Quoted 34 lines
Thomas, All,
On 2014-10-16 21:15 +0200, Thomas De Schampheleire spake thusly:
Quoted 31 lines
From: Thomas De Schampheleire <[email protected]>
check-requirements simply has to know if the results have to be sent, so it can check on some extra requirements. The username and password are irrelevant here.
This commit introduces a boolean variabledo_send_resultsto hide these details.Signed-off-by Thomas De Schampheleire <[email protected]>--- scripts/autobuild-run | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)scripts/autobuild-run +2
-2@@ -85,12 +85,12 @@ def check_version(): print "ERROR: script version too old, please upgrade." sys.exit(1) -def check_requirements(http_login, http_password): +def check_requirements(do_send_results=False): devnull = open(os.devnull, "w") needed_progs = ["make", "git", "gcc", "timeout"] missing_requirements = False - if http_login and http_password: + if do_send_results: needed_progs.append("curl")Quoted 11 lines
scripts/autobuild-run if __name__ == '__main__': · line 556
Quoted 8 lines
scripts/autobuild-run +1
-2for prog in needed_progs:@@ -553,8 +553,9 @@ if __name__ == '__main__': check_version() sysinfo = SystemInfo() (ninstances, njobs, http_login, http_password, submitter) = config_get() - check_requirements(http_login, http_password) - if http_login is None or http_password is None: + do_send_results = http_login and http_passwordI was told that we should no treat 'None' as 'False', or a non-empty string as 'True'. This should be something like:'
Quoted 6 lines
You can treat 'None' as 'False' and also a non empty string will value a logical 'True'.
In a python interpreter, do bool(None) and bool('blabla'), you'll respectively get 'False' and 'True'.I hope I am not the one you told you that in the first place...
Not sure it was Samuel or you, but I just looked at PEP8:
http://legacy.python.org/dev/peps/pep-0008/#programming-recommendations
Quoted 8 lines
Comparisons to singletons like None should always be done with is or is not, never the equality operators.
Also, beware of writing if x when you really mean if x is not None -- e.g. when testing whether a variable or argument that defaults to None was set to some other value. The other value might have a type (such as a container) that could be false in a boolean context!
Here it's fine since we only deal with basic type.
Quoted 15 lines
Regards,
Yann E. MORIN.Quoted 12 lines
Quoted 12 lines
do_send_results= (nothttp_loginis None) and (nothttp_passwordis None)Regards,
Yann E. MORIN.Quoted 7 lines
scripts/autobuild-run +2
-1+ check_requirements(do_send_results) + if not do_send_results: print "WARN: due to the lack of http login/password details, results will not be submitted" print "WARN: tarballs of results will be kept locally only" def sigterm_handler(signum, frame): --1.8.5.1
PATCH 1/8 autobuild-run: check-requirements does not need to know the login details
In reply to Yann E. MORINQuoted 3 lines · Yann E. MORIN
Thomas, All,
On 2014-10-16 21:15 +0200, Thomas De Schampheleire spake thusly:
[snip]
Quoted 11 lines
scripts/autobuild-run if __name__ == '__main__': · line 556
Quoted 7 lines
scripts/autobuild-run +1
-2@@ -553,8 +553,9 @@ if __name__ == '__main__': check_version() sysinfo = SystemInfo() (ninstances, njobs, http_login, http_password, submitter) = config_get() - check_requirements(http_login, http_password) - if http_login is None or http_password is None: + do_send_results = http_login and http_passwordI was told that we should no treat 'None' as 'False', or a non-empty string as 'True'. This should be something like:
Quoted 1 line
do_send_results= (nothttp_loginis None) and (nothttp_passwordis None)
I'm with Yann (not Maxime) on this one: if you would have an autobuild server
that doesn't need a username or password, then there would be no distinction between sending or not sending results. with 'http_login is not None and http_password is not None' you can set them to the empty string to force sending.
In practice, of course, it doesn't matter because we have only one autobuild
server and it does require a non-empty username and password.
Regards,
Arnout
Quoted 17 lines
Regards,
Yann E. MORIN.Quoted 12 lines
scripts/autobuild-run +2
-0+ check_requirements(do_send_results) + if not do_send_results: print "WARN: due to the lack of http login/password details, results will not be submitted" print "WARN: tarballs of results will be kept locally only" def sigterm_handler(signum, frame):Signature · 6 lines
1.8.5.1 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
PATCH 1/8 autobuild-run: check-requirements does not need to know the login details
Quoted 16 lines · Arnout Vandecappelle
Quoted 3 lines · Yann E. MORIN
Thomas, All,
On 2014-10-16 21:15 +0200, Thomas De Schampheleire spake thusly:
[snip]
Quoted 11 lines
scripts/autobuild-run if __name__ == '__main__': · line 556
Quoted 7 lines
scripts/autobuild-run +1
-2@@ -553,8 +553,9 @@ if __name__ == '__main__': check_version() sysinfo = SystemInfo() (ninstances, njobs, http_login, http_password, submitter) = config_get() - check_requirements(http_login, http_password) - if http_login is None or http_password is None: + do_send_results = http_login and http_passwordI was told that we should no treat 'None' as 'False', or a non-empty string as 'True'. This should be something like:
Quoted 1 line
Quoted 1 line
do_send_results= (nothttp_loginis None) and (nothttp_passwordis None)
Just for the sake of it:do_send_results = (http_login is not None) and (http_password is not None)
Quoted 5 lines
I'm with Yann (not Maxime) on this one: if you would have an autobuild server
that doesn't need a username or password, then there would be no distinction between sending or not sending results. with 'http_loginis not None andhttp_passwordis not None' you can set them to the empty string to force sending.
Very true, I did not think about that case.
And as bonus point, like Yann said previously, it's more explicit.
Quoted 38 lines
In practice, of course, it doesn't matter because we have only one autobuild
server and it does require a non-empty username and password.Regards,
ArnoutQuoted 17 lines
Regards,
Yann E. MORIN.Quoted 12 lines
scripts/autobuild-run +2
-1+ check_requirements(do_send_results) + if not do_send_results: print "WARN: due to the lack of http login/password details, results will not be submitted" print "WARN: tarballs of results will be kept locally only" def sigterm_handler(signum, frame): --1.8.5.1
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot--
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
PATCH 1/8 autobuild-run: check-requirements does not need to know the login details
All,
On 2014-10-18 15:52 +0200, Maxime Hadjinlian spake thusly:
Quoted 17 lines · Arnout Vandecappelle
Quoted 16 lines · Yann E. MORIN
Quoted 3 lines
Thomas, All,
On 2014-10-16 21:15 +0200, Thomas De Schampheleire spake thusly:
[snip]
Quoted 11 lines
scripts/autobuild-run if __name__ == '__main__': · line 556
Quoted 7 lines
scripts/autobuild-run +1
-2@@ -553,8 +553,9 @@ if __name__ == '__main__': check_version() sysinfo = SystemInfo() (ninstances, njobs, http_login, http_password, submitter) = config_get() - check_requirements(http_login, http_password) - if http_login is None or http_password is None: + do_send_results = http_login and http_passwordI was told that we should no treat 'None' as 'False', or a non-empty string as 'True'. This should be something like:
Quoted 3 lines
Quoted 1 line
Quoted 1 line
do_send_results= (nothttp_loginis None) and (nothttp_passwordis None)Just for the sake of it:
do_send_results= (http_loginis not None) and (http_passwordis not None)
Yup, I forgot that '... is not ...' is preferred over 'not ... is ...'
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 1/8 autobuild-run: check-requirements does not need to know the login details
[sorry, sent from non-subscribed account first, will bounce on the list]
All,
Quoted 20 lines · Yann E. MORIN
All,
On 2014-10-18 15:52 +0200, Maxime Hadjinlian spake thusly:
Quoted 17 lines · Arnout Vandecappelle
Quoted 16 lines · Yann E. MORIN
Quoted 3 lines
Thomas, All,
On 2014-10-16 21:15 +0200, Thomas De Schampheleire spake thusly:
[snip]
Quoted 11 lines
scripts/autobuild-run if __name__ == '__main__': · line 556
Quoted 7 lines
scripts/autobuild-run +1
-2@@ -553,8 +553,9 @@ if __name__ == '__main__': check_version() sysinfo = SystemInfo() (ninstances, njobs, http_login, http_password, submitter) = config_get() - check_requirements(http_login, http_password) - if http_login is None or http_password is None: + do_send_results = http_login and http_passwordI was told that we should no treat 'None' as 'False', or a non-empty string as 'True'. This should be something like:
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
do_send_results= (nothttp_loginis None) and (nothttp_passwordis None)Just for the sake of it:
do_send_results= (http_loginis not None) and (http_passwordis not None)Yup, I forgot that '... is not ...' is preferred over 'not ... is ...'
Extensive debate on just one line :)
First of all, the construct 'http_login and http_password' was already in the original code, I just placed the result in a variable to allow for reuse.
Secondly, regarding the quote Yann made of PEP8:
Comparisons to singletons like None should always be done with is or is not, never the equality operators.
--> This is not relevant in this case, according to me, since we are not using equality operators (==, !=).
Also, beware of writing if x when you really mean if x is not None -- e.g. when testing whether a variable or argument that defaults to None was set to some other value. The other value might have a type (such as a container) that could be false in a boolean context!
--> This part can be discussed. Arnout suggested that there may be a hypothetical server that accepts empty http logins or password. Yes, if you want to allow that, you cannot simply convert http_login in a boolean as the empty string would render False, but it's not a case I was coding for.
If I see code like:
do_send_results = (http_login is not None) and (http_password is not None)
my first reaction would be to change it into
do_send_results = http_login and http_password
although indeed it's not exactly the same. So a comment should be written to make it explicit that the empty string is accepted as a valid login/password.
All in all, I wonder if the empty string as login/password is a valid use case to consider, and whether the uglier code is worth that.
But I'm not a difficult person, so if the consensus is to change that line, no problem!
Best regards,
Thomas