Mercurial > hg > autobot
annotate autobot/projects/__init__.py @ 289:754cda797873
update
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Tue, 15 Apr 2014 21:37:18 -0700 |
parents | 7789fe9f8c30 |
children | 45fd58949f8a |
rev | line source |
---|---|
28
5ce65c535472
add a docstring and other stubs to projects
Jeff Hammel <jhammel@mozilla.com>
parents:
19
diff
changeset
|
1 """ |
5ce65c535472
add a docstring and other stubs to projects
Jeff Hammel <jhammel@mozilla.com>
parents:
19
diff
changeset
|
2 projects that need some testing: |
5ce65c535472
add a docstring and other stubs to projects
Jeff Hammel <jhammel@mozilla.com>
parents:
19
diff
changeset
|
3 |
70 | 4 * logparser [WORKING] |
133 | 5 * autobot [WORKING] |
70 | 6 * mozmill [IN FLIGHT] |
7 * devicemanager [IN FLIGHT] | |
8 * profilemanager [IN FLIGHT] | |
29 | 9 * firebug [TODO] |
10 * jetpack thing [TODO] | |
28
5ce65c535472
add a docstring and other stubs to projects
Jeff Hammel <jhammel@mozilla.com>
parents:
19
diff
changeset
|
11 """ |
5ce65c535472
add a docstring and other stubs to projects
Jeff Hammel <jhammel@mozilla.com>
parents:
19
diff
changeset
|
12 |
59
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
13 import imp |
189
cb9ad0b04140
preliminary passing of platform information from slaves; not yet tested
Jeff Hammel <jhammel@mozilla.com>
parents:
139
diff
changeset
|
14 import inspect |
28
5ce65c535472
add a docstring and other stubs to projects
Jeff Hammel <jhammel@mozilla.com>
parents:
19
diff
changeset
|
15 import os |
131
a14d466c843b
fix syntax error and note import errors in projects
Jeff Hammel <jhammel@mozilla.com>
parents:
71
diff
changeset
|
16 import sys |
59
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
17 from buildbot.process.factory import BuildFactory |
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
18 |
189
cb9ad0b04140
preliminary passing of platform information from slaves; not yet tested
Jeff Hammel <jhammel@mozilla.com>
parents:
139
diff
changeset
|
19 __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
|
20 |
59
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
21 # available factories:: |
71
a1568668175c
make the autobot project possibly do something
Jeff Hammel <jhammel@mozilla.com>
parents:
70
diff
changeset
|
22 # 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
|
23 factories = {} # factory classes |
cb9ad0b04140
preliminary passing of platform information from slaves; not yet tested
Jeff Hammel <jhammel@mozilla.com>
parents:
139
diff
changeset
|
24 descriptions = {} # their descriptions |
cb9ad0b04140
preliminary passing of platform information from slaves; not yet tested
Jeff Hammel <jhammel@mozilla.com>
parents:
139
diff
changeset
|
25 args = {} # their arguments |
34
206467b6f61f
* cleanup a bit in projects and start featuring autodiscovery
Jeff Hammel <jhammel@mozilla.com>
parents:
32
diff
changeset
|
26 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
|
27 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
|
28 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
|
29 if os.path.isdir(os.path.join(here, path))] |
59
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
30 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
|
31 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
|
32 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
|
33 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
|
34 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
|
35 packages.extend(modules) |
59
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
36 for package in packages: |
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
37 try: |
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
38 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
|
39 except Exception, e: |
a0866ad63d93
fix another syntax error andadd the error handling to detect it
Jeff Hammel <jhammel@mozilla.com>
parents:
133
diff
changeset
|
40 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
|
41 continue |
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
42 for attr in dir(module): |
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
43 try: |
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
44 _obj = getattr(module, attr) |
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
45 if issubclass(_obj, BuildFactory) and _obj.__module__.startswith('autobot.projects.'): |
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
46 factories[package] = _obj |
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
47 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
|
48 args[package] = inspect.getargspec(_obj.__init__).args[1:] # not self |
59
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
49 except TypeError: |
e66165f2f31b
complete automagic imports
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
50 continue |
10
9bda5ada5dca
start on a dict of projects
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
51 |