imip-agent

tools/update_scheduling_modules.py

1034:365c2fab060e
2016-01-31 Paul Boddie Fixed unmodified invocations after function signature changes.
     1 #!/usr/bin/env python     2      3 """     4 Update the scheduling modules import manifest.     5      6 Copyright (C) 2016 Paul Boddie <paul@boddie.org.uk>     7      8 This program is free software; you can redistribute it and/or modify it under     9 the terms of the GNU General Public License as published by the Free Software    10 Foundation; either version 3 of the License, or (at your option) any later    11 version.    12     13 This program is distributed in the hope that it will be useful, but WITHOUT    14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    15 FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more    16 details.    17     18 You should have received a copy of the GNU General Public License along with    19 this program.  If not, see <http://www.gnu.org/licenses/>.    20 """    21     22 from glob import glob    23 from os.path import join, split, splitext    24 import imiptools.handlers    25     26 reserved = ["__init__.py", "manifest.py"]    27     28 # The main program generating a new version of the manifest module.    29     30 if __name__ == "__main__":    31     dirname = join(split(imiptools.handlers.__file__)[0], "scheduling")    32     33     # Get all Python files in the scheduling directory, filtering out the    34     # reserved files that do not provide scheduling functions.    35     36     filenames = []    37     for filename in glob(join(dirname, "*.py")):    38         filename = split(filename)[-1]    39         if filename not in reserved:    40             filenames.append(filename)    41     42     # Open the manifest module and write code to import and combine the    43     # functions from each module.    44     45     f = open(join(dirname, "manifest.py"), "w")    46     try:    47         print >>f, "scheduling_functions = {}"    48         for filename in filenames:    49             module = splitext(filename)[0]    50             print >>f, "from imiptools.handlers.scheduling.%s import scheduling_functions as l" % module    51             print >>f, "scheduling_functions.update(l)"    52     finally:    53         f.close()    54     55 # vim: tabstop=4 expandtab shiftwidth=4