5 from util
.commands
import run_cmd
, get_output
6 from util
.hg
import get_repo_name
, make_hg_url
7 from subprocess
import CalledProcessError
9 log
= logging
.getLogger(__name__
)
13 """check if buildbot command works"""
15 run_cmd(['buildbot', '--version'])
16 except CalledProcessError
:
17 log
.error("FAIL: buildbot command doesn't work", exc_info
=True)
21 def find_version(contents
, versionNumber
):
22 """Given an open readable file-handle look for the occurrence
23 of the version # in the file"""
24 ret
= re
.search(re
.compile(re
.escape(versionNumber
), re
.DOTALL
), contents
)
28 def locale_diff(locales1
, locales2
):
29 """ accepts two lists and diffs them both ways, returns any differences
31 diff_list
= [locale
for locale
in locales1
if not locale
in locales2
]
32 diff_list
.extend(locale
for locale
in locales2
if not locale
in locales1
)
36 def get_buildbot_username_param():
37 cmd
= ['buildbot', 'sendchange', '--help']
38 output
= get_output(cmd
)
39 if "-W, --who=" in output
:
45 def sendchange(branch
, revision
, username
, master
, products
):
46 """Send the change to buildbot to kick off the release automation"""
47 if isinstance(products
, basestring
):
52 get_buildbot_username_param(),
59 'products:%s' % ','.join(products
),
61 'script_repo_revision:%s' % revision
,
64 logging
.info("Executing: %s" % cmd
)
68 def verify_mozconfigs(mozconfig_pair
, nightly_mozconfig_pair
, platform
,
69 mozconfigWhitelist
={}):
70 """Compares mozconfig to nightly_mozconfig and compare to an optional
71 whitelist of known differences. mozconfig_pair and nightly_mozconfig_pair
72 are pairs containing the mozconfig's identifier and the list of lines in
75 # unpack the pairs to get the names, the names are just for
76 # identifying the mozconfigs when logging the error messages
77 mozconfig_name
, mozconfig_lines
= mozconfig_pair
78 nightly_mozconfig_name
, nightly_mozconfig_lines
= nightly_mozconfig_pair
80 missing_args
= mozconfig_lines
== [] or nightly_mozconfig_lines
== []
82 log
.info("Missing mozconfigs to compare for %s" % platform
)
87 diffInstance
= difflib
.Differ()
88 diff_result
= diffInstance
.compare(mozconfig_lines
, nightly_mozconfig_lines
)
89 diffList
= list(diff_result
)
92 clean_line
= line
[1:].strip()
93 if (line
[0] == '-' or line
[0] == '+') and len(clean_line
) > 1:
95 if clean_line
.startswith('#'):
97 # compare to whitelist
100 if platform
in mozconfigWhitelist
.get('release', {}):
102 mozconfigWhitelist
['release'][platform
]:
105 if platform
in mozconfigWhitelist
.get('nightly', {}):
107 mozconfigWhitelist
['nightly'][platform
]:
110 log
.warning("%s not in %s %s!" % (
111 clean_line
, platform
,
112 mozconfigWhitelist
['nightly'][platform
]))
114 log
.error("Skipping line %s!" % line
)
116 message
= "found in %s but not in %s: %s"
118 log
.error(message
% (mozconfig_name
,
119 nightly_mozconfig_name
, clean_line
))
121 log
.error(message
% (nightly_mozconfig_name
,
122 mozconfig_name
, clean_line
))