Message ID | 1431556137-8426-10-git-send-email-joe.hershberger@ni.com |
---|---|
State | Superseded |
Delegated to: | Masahiro Yamada |
Headers | show |
2015-05-14 7:28 GMT+09:00 Joe Hershberger <joe.hershberger@ni.com>: > In some case you may want to only cleanup the headers. Make it possible > without waiting for all boards to compile. > > Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> > > --- > > Changes in v3: > -New for version 3 > > Changes in v2: None > > tools/moveconfig.py | 83 ++++++++++++++++++++++++++++------------------------- > 1 file changed, 44 insertions(+), 39 deletions(-) > > diff --git a/tools/moveconfig.py b/tools/moveconfig.py > index bb087d4..d63f47f 100755 > --- a/tools/moveconfig.py > +++ b/tools/moveconfig.py > @@ -412,48 +412,50 @@ class Slots: > def move_config(config_attrs, options): > check_top_directory() > > - for config_attr in config_attrs: > - print 'Moving %s (type: %s, default: %s, no_spl: %s)' % ( > - config_attr['config'], > - config_attr['type'], > - config_attr['default'], > - config_attr['no_spl_support']) > - print '%d jobs...' % options.jobs > - > - if options.defconfigs: > - defconfigs = [line.strip() for line in open(options.defconfigs, 'r')] > - else: > - # All the defconfig files to be processed > - defconfigs = [] > - for (dirpath, dirnames, filenames) in os.walk('configs'): > - dirpath = dirpath[len('configs') + 1:] > - for filename in fnmatch.filter(filenames, '*_defconfig'): > - if fnmatch.fnmatch(filename, '.*'): > - continue > - defconfigs.append(os.path.join(dirpath, filename)) > - > - """Clean up any previous log of failed moves""" > - if os.path.exists('moveconfig.failed'): > - os.remove('moveconfig.failed') > - > - slots = Slots(config_attrs, options) > - > - # Main loop to process defconfig files: > - # Add a new subprocess into a vacant slot. > - # Sleep if there is no available slot. > - for i, defconfig in enumerate(defconfigs): > - while not slots.add(defconfig, i, len(defconfigs)): > - while not slots.available(): > - # No available slot: sleep for a while > - time.sleep(SLEEP_TIME) > - > - # wait until all the subprocesses finish > - while not slots.empty(): > - time.sleep(SLEEP_TIME) > + if not options.clean_only: > + for config_attr in config_attrs: > + print 'Moving %s (type: %s, default: %s, no_spl: %s)' % ( > + config_attr['config'], > + config_attr['type'], > + config_attr['default'], > + config_attr['no_spl_support']) > + print '%d jobs...' % options.jobs > + > + if options.defconfigs: > + defconfigs = [line.strip() for line in > + open(options.defconfigs, 'r')] > + else: > + # All the defconfig files to be processed > + defconfigs = [] > + for (dirpath, dirnames, filenames) in os.walk('configs'): > + dirpath = dirpath[len('configs') + 1:] > + for filename in fnmatch.filter(filenames, '*_defconfig'): > + if fnmatch.fnmatch(filename, '.*'): > + continue > + defconfigs.append(os.path.join(dirpath, filename)) > + > + """Clean up any previous log of failed moves""" > + if os.path.exists('moveconfig.failed'): > + os.remove('moveconfig.failed') > + > + slots = Slots(config_attrs, options) > + > + # Main loop to process defconfig files: > + # Add a new subprocess into a vacant slot. > + # Sleep if there is no available slot. > + for i, defconfig in enumerate(defconfigs): > + while not slots.add(defconfig, i, len(defconfigs)): > + while not slots.available(): > + # No available slot: sleep for a while > + time.sleep(SLEEP_TIME) > + > + # wait until all the subprocesses finish > + while not slots.empty(): > + time.sleep(SLEEP_TIME) > > cleanup_headers(config_attrs) > > - if os.path.exists('moveconfig.failed'): > + if (not options.clean_only) & os.path.exists('moveconfig.failed'): > print '!!! Some boards were not processed; move the config manually.' > print '!!! The list of failed boards are saved in moveconfig.failed' > print I am OK with this feature, but this 'if' statement ranges over many code lines. Perhaps, moving the cleanup_headers to the main function is simpler? def main(): [snip] if not options.clean_only: move_config(config_attrs, options) cleanup_headers(config_attrs)
Hi Masahiro-san, On Thu, May 14, 2015 at 9:51 AM, Masahiro Yamada <yamada.masahiro@socionext.com> wrote: > 2015-05-14 7:28 GMT+09:00 Joe Hershberger <joe.hershberger@ni.com>: >> In some case you may want to only cleanup the headers. Make it possible >> without waiting for all boards to compile. >> >> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> >> >> --- >> >> Changes in v3: >> -New for version 3 >> >> Changes in v2: None >> >> tools/moveconfig.py | 83 ++++++++++++++++++++++++++++------------------------- >> 1 file changed, 44 insertions(+), 39 deletions(-) >> >> diff --git a/tools/moveconfig.py b/tools/moveconfig.py >> index bb087d4..d63f47f 100755 >> --- a/tools/moveconfig.py >> +++ b/tools/moveconfig.py >> @@ -412,48 +412,50 @@ class Slots: >> def move_config(config_attrs, options): >> check_top_directory() >> >> - for config_attr in config_attrs: >> - print 'Moving %s (type: %s, default: %s, no_spl: %s)' % ( >> - config_attr['config'], >> - config_attr['type'], >> - config_attr['default'], >> - config_attr['no_spl_support']) >> - print '%d jobs...' % options.jobs >> - >> - if options.defconfigs: >> - defconfigs = [line.strip() for line in open(options.defconfigs, 'r')] >> - else: >> - # All the defconfig files to be processed >> - defconfigs = [] >> - for (dirpath, dirnames, filenames) in os.walk('configs'): >> - dirpath = dirpath[len('configs') + 1:] >> - for filename in fnmatch.filter(filenames, '*_defconfig'): >> - if fnmatch.fnmatch(filename, '.*'): >> - continue >> - defconfigs.append(os.path.join(dirpath, filename)) >> - >> - """Clean up any previous log of failed moves""" >> - if os.path.exists('moveconfig.failed'): >> - os.remove('moveconfig.failed') >> - >> - slots = Slots(config_attrs, options) >> - >> - # Main loop to process defconfig files: >> - # Add a new subprocess into a vacant slot. >> - # Sleep if there is no available slot. >> - for i, defconfig in enumerate(defconfigs): >> - while not slots.add(defconfig, i, len(defconfigs)): >> - while not slots.available(): >> - # No available slot: sleep for a while >> - time.sleep(SLEEP_TIME) >> - >> - # wait until all the subprocesses finish >> - while not slots.empty(): >> - time.sleep(SLEEP_TIME) >> + if not options.clean_only: >> + for config_attr in config_attrs: >> + print 'Moving %s (type: %s, default: %s, no_spl: %s)' % ( >> + config_attr['config'], >> + config_attr['type'], >> + config_attr['default'], >> + config_attr['no_spl_support']) >> + print '%d jobs...' % options.jobs >> + >> + if options.defconfigs: >> + defconfigs = [line.strip() for line in >> + open(options.defconfigs, 'r')] >> + else: >> + # All the defconfig files to be processed >> + defconfigs = [] >> + for (dirpath, dirnames, filenames) in os.walk('configs'): >> + dirpath = dirpath[len('configs') + 1:] >> + for filename in fnmatch.filter(filenames, '*_defconfig'): >> + if fnmatch.fnmatch(filename, '.*'): >> + continue >> + defconfigs.append(os.path.join(dirpath, filename)) >> + >> + """Clean up any previous log of failed moves""" >> + if os.path.exists('moveconfig.failed'): >> + os.remove('moveconfig.failed') >> + >> + slots = Slots(config_attrs, options) >> + >> + # Main loop to process defconfig files: >> + # Add a new subprocess into a vacant slot. >> + # Sleep if there is no available slot. >> + for i, defconfig in enumerate(defconfigs): >> + while not slots.add(defconfig, i, len(defconfigs)): >> + while not slots.available(): >> + # No available slot: sleep for a while >> + time.sleep(SLEEP_TIME) >> + >> + # wait until all the subprocesses finish >> + while not slots.empty(): >> + time.sleep(SLEEP_TIME) >> >> cleanup_headers(config_attrs) >> >> - if os.path.exists('moveconfig.failed'): >> + if (not options.clean_only) & os.path.exists('moveconfig.failed'): >> print '!!! Some boards were not processed; move the config manually.' >> print '!!! The list of failed boards are saved in moveconfig.failed' >> print > > > I am OK with this feature, but this 'if' statement ranges over many code lines. > > Perhaps, moving the cleanup_headers to the main function is simpler? > > > def main(): > [snip] > > if not options.clean_only: > move_config(config_attrs, options) > > cleanup_headers(config_attrs) OK. -Joe
diff --git a/tools/moveconfig.py b/tools/moveconfig.py index bb087d4..d63f47f 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -412,48 +412,50 @@ class Slots: def move_config(config_attrs, options): check_top_directory() - for config_attr in config_attrs: - print 'Moving %s (type: %s, default: %s, no_spl: %s)' % ( - config_attr['config'], - config_attr['type'], - config_attr['default'], - config_attr['no_spl_support']) - print '%d jobs...' % options.jobs - - if options.defconfigs: - defconfigs = [line.strip() for line in open(options.defconfigs, 'r')] - else: - # All the defconfig files to be processed - defconfigs = [] - for (dirpath, dirnames, filenames) in os.walk('configs'): - dirpath = dirpath[len('configs') + 1:] - for filename in fnmatch.filter(filenames, '*_defconfig'): - if fnmatch.fnmatch(filename, '.*'): - continue - defconfigs.append(os.path.join(dirpath, filename)) - - """Clean up any previous log of failed moves""" - if os.path.exists('moveconfig.failed'): - os.remove('moveconfig.failed') - - slots = Slots(config_attrs, options) - - # Main loop to process defconfig files: - # Add a new subprocess into a vacant slot. - # Sleep if there is no available slot. - for i, defconfig in enumerate(defconfigs): - while not slots.add(defconfig, i, len(defconfigs)): - while not slots.available(): - # No available slot: sleep for a while - time.sleep(SLEEP_TIME) - - # wait until all the subprocesses finish - while not slots.empty(): - time.sleep(SLEEP_TIME) + if not options.clean_only: + for config_attr in config_attrs: + print 'Moving %s (type: %s, default: %s, no_spl: %s)' % ( + config_attr['config'], + config_attr['type'], + config_attr['default'], + config_attr['no_spl_support']) + print '%d jobs...' % options.jobs + + if options.defconfigs: + defconfigs = [line.strip() for line in + open(options.defconfigs, 'r')] + else: + # All the defconfig files to be processed + defconfigs = [] + for (dirpath, dirnames, filenames) in os.walk('configs'): + dirpath = dirpath[len('configs') + 1:] + for filename in fnmatch.filter(filenames, '*_defconfig'): + if fnmatch.fnmatch(filename, '.*'): + continue + defconfigs.append(os.path.join(dirpath, filename)) + + """Clean up any previous log of failed moves""" + if os.path.exists('moveconfig.failed'): + os.remove('moveconfig.failed') + + slots = Slots(config_attrs, options) + + # Main loop to process defconfig files: + # Add a new subprocess into a vacant slot. + # Sleep if there is no available slot. + for i, defconfig in enumerate(defconfigs): + while not slots.add(defconfig, i, len(defconfigs)): + while not slots.available(): + # No available slot: sleep for a while + time.sleep(SLEEP_TIME) + + # wait until all the subprocesses finish + while not slots.empty(): + time.sleep(SLEEP_TIME) cleanup_headers(config_attrs) - if os.path.exists('moveconfig.failed'): + if (not options.clean_only) & os.path.exists('moveconfig.failed'): print '!!! Some boards were not processed; move the config manually.' print '!!! The list of failed boards are saved in moveconfig.failed' print @@ -467,6 +469,9 @@ def main(): parser = optparse.OptionParser() # Add options here + parser.add_option('-c', '--clean-only', dest='clean_only', + action='store_true', default=False, + help='only clean the headers') parser.add_option('-d', '--defconfigs', type='string', help='a file containing a list of defconfigs to move') parser.add_option('-j', '--jobs', type='int', default=cpu_count,
In some case you may want to only cleanup the headers. Make it possible without waiting for all boards to compile. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> --- Changes in v3: -New for version 3 Changes in v2: None tools/moveconfig.py | 83 ++++++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 39 deletions(-)