Mercurial > hg > autobot
annotate autobot/projects/__init__.py @ 294:45fd58949f8a
STUB: autobot/projects/__init__.py autobot/template.py
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Sun, 11 May 2014 04:30:57 -0700 |
parents | 7789fe9f8c30 |
children | 43e472db4353 |
rev | line source |
---|---|
28
5ce65c535472
add a docstring and other stubs to projects
Jeff Hammel <jhammel@mozilla.com>
parents:
19
diff
changeset
|
1 """ |
294
45fd58949f8a
STUB: autobot/projects/__init__.py autobot/template.py
Jeff Hammel <k0scist@gmail.com>
parents:
191
diff
changeset
|
2 projects that need some CI love |
28
5ce65c535472
add a docstring and other stubs to projects
Jeff Hammel <jhammel@mozilla.com>
parents:
19
diff
changeset
|
3 """ |
5ce65c535472
add a docstring and other stubs to projects
Jeff Hammel <jhammel@mozilla.com>
parents:
19
diff
changeset
|
4 |
59
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
5 import imp |
189
cb9ad0b04140
preliminary passing of platform information from slaves; not yet tested
Jeff Hammel <jhammel@mozilla.com>
parents:
139
diff
changeset
|
6 import inspect |
28
5ce65c535472
add a docstring and other stubs to projects
Jeff Hammel <jhammel@mozilla.com>
parents:
19
diff
changeset
|
7 import os |
131
a14d466c843b
fix syntax error and note import errors in projects
Jeff Hammel <jhammel@mozilla.com>
parents:
71
diff
changeset
|
8 import sys |
59
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
9 from buildbot.process.factory import BuildFactory |
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
10 |
189
cb9ad0b04140
preliminary passing of platform information from slaves; not yet tested
Jeff Hammel <jhammel@mozilla.com>
parents:
139
diff
changeset
|
11 __all__ = ['factories', 'descriptions', 'here', 'args'] |
cb9ad0b04140
preliminary passing of platform information from slaves; not yet tested
Jeff Hammel <jhammel@mozilla.com>
parents:
139
diff
changeset
|
12 |
59
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
13 # available factories:: |
71
a1568668175c
make the autobot project possibly do something
Jeff Hammel <jhammel@mozilla.com>
parents:
70
diff
changeset
|
14 # import these automagically; requires non-zipped eggs |
189
cb9ad0b04140
preliminary passing of platform information from slaves; not yet tested
Jeff Hammel <jhammel@mozilla.com>
parents:
139
diff
changeset
|
15 factories = {} # factory classes |
cb9ad0b04140
preliminary passing of platform information from slaves; not yet tested
Jeff Hammel <jhammel@mozilla.com>
parents:
139
diff
changeset
|
16 descriptions = {} # their descriptions |
cb9ad0b04140
preliminary passing of platform information from slaves; not yet tested
Jeff Hammel <jhammel@mozilla.com>
parents:
139
diff
changeset
|
17 args = {} # their arguments |
34
206467b6f61f
* cleanup a bit in projects and start featuring autodiscovery
Jeff Hammel <jhammel@mozilla.com>
parents:
32
diff
changeset
|
18 here = os.path.dirname(os.path.abspath(__file__)) |
206467b6f61f
* cleanup a bit in projects and start featuring autodiscovery
Jeff Hammel <jhammel@mozilla.com>
parents:
32
diff
changeset
|
19 packages = [os.path.join(here, path) |
206467b6f61f
* cleanup a bit in projects and start featuring autodiscovery
Jeff Hammel <jhammel@mozilla.com>
parents:
32
diff
changeset
|
20 for path in os.listdir(here) |
206467b6f61f
* cleanup a bit in projects and start featuring autodiscovery
Jeff Hammel <jhammel@mozilla.com>
parents:
32
diff
changeset
|
21 if os.path.isdir(os.path.join(here, path))] |
59
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
22 packages = [os.path.basename(package) for package in packages |
34
206467b6f61f
* cleanup a bit in projects and start featuring autodiscovery
Jeff Hammel <jhammel@mozilla.com>
parents:
32
diff
changeset
|
23 if os.path.exists(os.path.join(package, '__init__.py'))] |
189
cb9ad0b04140
preliminary passing of platform information from slaves; not yet tested
Jeff Hammel <jhammel@mozilla.com>
parents:
139
diff
changeset
|
24 modules = [os.path.splitext(module)[0] |
cb9ad0b04140
preliminary passing of platform information from slaves; not yet tested
Jeff Hammel <jhammel@mozilla.com>
parents:
139
diff
changeset
|
25 for module in os.listdir(here) |
cb9ad0b04140
preliminary passing of platform information from slaves; not yet tested
Jeff Hammel <jhammel@mozilla.com>
parents:
139
diff
changeset
|
26 if module.endswith('.py') and not module.startswith('_')] |
cb9ad0b04140
preliminary passing of platform information from slaves; not yet tested
Jeff Hammel <jhammel@mozilla.com>
parents:
139
diff
changeset
|
27 packages.extend(modules) |
59
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
28 for package in packages: |
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
29 try: |
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
30 module = imp.load_package('autobot.projects.'+package, imp.find_module(package, [here])[1]) |
139
a0866ad63d93
fix another syntax error andadd the error handling to detect it
Jeff Hammel <jhammel@mozilla.com>
parents:
133
diff
changeset
|
31 except Exception, e: |
a0866ad63d93
fix another syntax error andadd the error handling to detect it
Jeff Hammel <jhammel@mozilla.com>
parents:
133
diff
changeset
|
32 print >> sys.stderr, "Could not import autobot.projects.%s : %s" % (package, e) |
59
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
33 continue |
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
34 for attr in dir(module): |
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
35 try: |
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
36 _obj = getattr(module, attr) |
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
37 if issubclass(_obj, BuildFactory) and _obj.__module__.startswith('autobot.projects.'): |
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
38 factories[package] = _obj |
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
39 descriptions[package] = (getattr(_obj, '__doc__', attr) or attr).strip() |
189
cb9ad0b04140
preliminary passing of platform information from slaves; not yet tested
Jeff Hammel <jhammel@mozilla.com>
parents:
139
diff
changeset
|
40 args[package] = inspect.getargspec(_obj.__init__).args[1:] # not self |
59
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
41 except TypeError: |
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
42 continue |
10
9bda5ada5dca
start on a dict of projects
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
43 |