Skip to content

Commit

Permalink
Merge branch 'use_pep8' of git://github.com/vrutsky/buildbot
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Oct 19, 2013
2 parents 8efbee5 + 8580058 commit 5118be2
Show file tree
Hide file tree
Showing 25 changed files with 152 additions and 91 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -73,6 +73,7 @@ install:
- "[ $IS_LATEST = false ] || pip install pylint"
- "[ $IS_LATEST = false ] || pip install pyflakes"
- "[ $IS_LATEST = false ] || pip install sphinx"
- "[ $IS_LATEST = false ] || pip install pep8"

# Tests running commands
script:
Expand All @@ -83,6 +84,7 @@ script:
- "[ $IS_LATEST = false ] || make pylint"
- "[ $IS_LATEST = false ] || make pyflakes"
- "[ $IS_LATEST = false ] || make docs"
- "[ $IS_LATEST = false ] || make pep8"

notifications:
email: false
3 changes: 3 additions & 0 deletions Makefile
Expand Up @@ -15,3 +15,6 @@ pylint:

pyflakes:
pyflakes master/buildbot slave/buildslave

pep8:
pep8 --config=common/pep8rc master slave
56 changes: 56 additions & 0 deletions common/pep8rc
@@ -0,0 +1,56 @@
[pep8]
show-source = yes
statistics = yes
count = yes
#max-line-length = 80
exclude = master/contrib/buildbot_json.py

# List of currently ignored PEP8 issues. Some of them definetely should be
# enabled in future.
#
# E121 continuation line indentation is not a multiple of four
# E122 continuation line missing indentation or outdented
# E123 closing bracket does not match indentation of opening bracket's line
# E124 closing bracket does not match visual indentation
# E125 continuation line does not distinguish itself from next logical lin
# E126 continuation line over-indented for hanging indent
# E127 continuation line over-indented for visual indent
# E128 continuation line under-indented for visual indent
# E201 whitespace after '['
# E202 whitespace before ']'
# E203 whitespace before ':'
# E211 whitespace before '('
# E221 multiple spaces before operator
# E222 multiple spaces after operator
# E225 missing whitespace around operator
# E226 missing whitespace around arithmetic operator
# E227 missing whitespace around bitwise or shift operator
# E228 missing whitespace around modulo operator
# E231 missing whitespace after ','
# E241 multiple spaces after ','
# E251 unexpected spaces around keyword / parameter equals
# E261 at least two spaces before inline comment
# E262 inline comment should start with '# '
# E271 multiple spaces after keyword
# E272 multiple spaces before keyword
# E301 expected 1 blank line, found 0
# E302 expected 2 blank lines, found 1
# E303 too many blank lines (2)
# E401 multiple imports on one line
# E501 line too long (80 > 79 characters)
# E502 the backslash is redundant between brackets
# E701 multiple statements on one line (colon)
# E703 statement ends with a semicolon
# E711 comparison to None should be 'if cond is None:'
# E712 comparison to False should be 'if cond is False:' or 'if not cond:'
# E721 do not compare types, use 'isinstance()'
# W191 indentation contains tabs
# W291 trailing whitespace
# W292 no newline at end of file
# W293 blank line contains whitespace
# W391 blank line at end of file
# W601 .has_key() is deprecated, use 'in'
# W602 deprecated form of raising exception
# W604 backticks are deprecated, use 'repr()'

ignore = E121,E122,E123,E124,E125,E126,E127,E128,E201,E202,E203,E211,E221,E222,E225,E226,E227,E228,E231,E241,E251,E261,E262,E271,E272,E301,E302,E303,E401,E501,E502,E701,E703,E711,E712,E721,W191,W291,W292,W293,W391,W601,W602,W604
2 changes: 1 addition & 1 deletion master/buildbot/changes/changes.py
Expand Up @@ -140,7 +140,7 @@ def __str__(self):
self.codebase)

def __cmp__(self, other):
return self.number - other.number
return self.number - other.number

def asText(self):
data = ""
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/changes/gerritchangesource.py
Expand Up @@ -178,7 +178,7 @@ def startStreamProcess(self):
self.lastStreamProcessStart = util.now()
args = [ self.username+"@"+self.gerritserver,"-p", str(self.gerritport)]
if self.identity_file is not None:
args = args + [ '-i', self.identity_file ]
args = args + [ '-i', self.identity_file ]
self.process = reactor.spawnProcess(self.LocalPP(self), "ssh",
[ "ssh" ] + args + [ "gerrit", "stream-events" ])

Expand Down
4 changes: 2 additions & 2 deletions master/buildbot/changes/mail.py
Expand Up @@ -197,8 +197,8 @@ def parse(self, m, prefix=None):
# modified_file.c 1.1,1.2

if fileList is None:
log.msg('CVSMaildirSource Mail with no files. Ignoring')
return None # We don't have any files. Email not from CVS
log.msg('CVSMaildirSource Mail with no files. Ignoring')
return None # We don't have any files. Email not from CVS

if cvsmode == '1.11':
# Please, no repo paths with spaces!
Expand Down
16 changes: 8 additions & 8 deletions master/buildbot/db/buildrequests.py
Expand Up @@ -75,12 +75,12 @@ def thd(conn):
reqs_tbl.c.id == claims_tbl.c.brid)

if branch or repository:
from_clause = from_clause.join(bsets_tbl,
reqs_tbl.c.buildsetid ==
bsets_tbl.c.id)
from_clause = from_clause.join(sstamps_tbls,
bsets_tbl.c.sourcestampsetid ==
sstamps_tbls.c.sourcestampsetid)
from_clause = from_clause.join(bsets_tbl,
reqs_tbl.c.buildsetid ==
bsets_tbl.c.id)
from_clause = from_clause.join(sstamps_tbls,
bsets_tbl.c.sourcestampsetid ==
sstamps_tbls.c.sourcestampsetid)

q = sa.select([ reqs_tbl, claims_tbl ]).select_from(from_clause)
if claimed is not None:
Expand All @@ -105,9 +105,9 @@ def thd(conn):
q = q.where(reqs_tbl.c.buildsetid == bsid)

if branch is not None:
q = q.where(sstamps_tbls.c.branch == branch)
q = q.where(sstamps_tbls.c.branch == branch)
if repository is not None:
q = q.where(sstamps_tbls.c.repository == repository)
q = q.where(sstamps_tbls.c.repository == repository)

res = conn.execute(q)

Expand Down
4 changes: 2 additions & 2 deletions master/buildbot/db/buildsets.py
Expand Up @@ -151,9 +151,9 @@ def thd(conn):
q = q.where((bs_tbl.c.complete == 0) |
(bs_tbl.c.complete == None))
if branch:
q = q.where(ss_tbl.c.branch == branch)
q = q.where(ss_tbl.c.branch == branch)
if repository:
q = q.where(ss_tbl.c.repository == repository)
q = q.where(ss_tbl.c.repository == repository)
res = conn.execute(q)
return list(reversed([ self._row2dict(row)
for row in res.fetchall() ]))
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/process/properties.py
Expand Up @@ -336,7 +336,7 @@ def getRenderingFor(self, build):
index = build.render(self.index)
value, index = yield defer.gatherResults([value, index])
if not value.has_key(index):
rv = yield build.render(self.default)
rv = yield build.render(self.default)
else:
if self.defaultWhenFalse:
rv = yield build.render(value[index])
Expand Down
20 changes: 10 additions & 10 deletions master/buildbot/schedulers/forcesched.py
Expand Up @@ -508,15 +508,15 @@ def __init__(self, name, builderNames,
"""

if not self.checkIfType(name, str):
config.error("ForceScheduler name must be a unicode string: %r" %
name)
config.error("ForceScheduler name must be a unicode string: %r" %
name)

if not name:
config.error("ForceScheduler name must not be empty: %r " %
name)
config.error("ForceScheduler name must not be empty: %r " %
name)

if not self.checkIfListOfType(builderNames, str):
config.error("ForceScheduler builderNames must be a list of strings: %r" %
config.error("ForceScheduler builderNames must be a list of strings: %r" %
builderNames)

if self.checkIfType(reason, BaseParameter):
Expand Down Expand Up @@ -588,12 +588,12 @@ def checkIfListOfType(self, obj, chkType):
isListOfType = True

if self.checkIfType(obj, list):
for item in obj:
if not self.checkIfType(item, chkType):
isListOfType = False
break
for item in obj:
if not self.checkIfType(item, chkType):
isListOfType = False
break
else:
isListOfType = False
isListOfType = False

return isListOfType

Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/scripts/stop.py
Expand Up @@ -26,7 +26,7 @@ def stop(config, signame="TERM", wait=False):
quiet = config['quiet']

if config['clean']:
signame = 'USR1'
signame = 'USR1'

if not base.isBuildmasterDir(config['basedir']):
return 1
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/sourcestamp.py
Expand Up @@ -323,7 +323,7 @@ def addSourceStampToDatabase(self, master, sourcestampsetid = None):
patch_level = self.patch[0]
patch_body = self.patch[1]
if len(self.patch) > 2:
patch_subdir = self.patch[2]
patch_subdir = self.patch[2]

patch_author = None
patch_comment = None
Expand Down
4 changes: 2 additions & 2 deletions master/buildbot/status/web/base.py
Expand Up @@ -241,8 +241,8 @@ def performAction(self, request):
@param request: the web request
@returns: URL via Deferred
can also return (URL, alert_msg) to display simple
feedback to user in case of failure
can also return (URL, alert_msg) to display simple
feedback to user in case of failure
"""

def render(self, request):
Expand Down
12 changes: 6 additions & 6 deletions master/buildbot/status/web/builder.py
Expand Up @@ -45,12 +45,12 @@ def force(self, req, builderNames):
# decode all of the args
encoding = getRequestCharset(req)
for name, argl in req.args.iteritems():
if name == "checkbox":
# damn html's ungeneric checkbox implementation...
for cb in argl:
args[cb.decode(encoding)] = True
else:
args[name] = [ arg.decode(encoding) for arg in argl ]
if name == "checkbox":
# damn html's ungeneric checkbox implementation...
for cb in argl:
args[cb.decode(encoding)] = True
else:
args[name] = [ arg.decode(encoding) for arg in argl ]

for sch in master.allSchedulers():
if schedulername == sch.name:
Expand Down
18 changes: 9 additions & 9 deletions master/buildbot/test/fake/web.py
Expand Up @@ -67,12 +67,12 @@ def _get_child_mock(self, **kw):

# cribed from twisted.web.test._util._render
def test_render(self, resource):
result = resource.render(self)
if isinstance(result, str):
self.write(result)
self.finish()
return self.deferred
elif result is server.NOT_DONE_YET:
return self.deferred
else:
raise ValueError("Unexpected return value: %r" % (result,))
result = resource.render(self)
if isinstance(result, str):
self.write(result)
self.finish()
return self.deferred
elif result is server.NOT_DONE_YET:
return self.deferred
else:
raise ValueError("Unexpected return value: %r" % (result,))
6 changes: 3 additions & 3 deletions master/buildbot/test/unit/test_changes_p4poller.py
Expand Up @@ -34,20 +34,20 @@
change_4_log = \
"""Change 4 by mpatel@testclient on 2006/04/13 21:55:39
short desc truncated because this is a long description.
short desc truncated because this is a long description.
"""

change_3_log = \
u"""Change 3 by bob@testclient on 2006/04/13 21:51:39
short desc truncated because this is a long description.
short desc truncated because this is a long description.
ASDF-GUI-P3-\u2018Upgrade Icon\u2019 disappears sometimes.
"""

change_2_log = \
"""Change 2 by slamb@testclient on 2006/04/13 21:46:23
creation
creation
"""

p4change = {
Expand Down
22 changes: 11 additions & 11 deletions master/buildbot/test/unit/test_db_buildrequests.py
Expand Up @@ -305,27 +305,27 @@ def check(brlist):
return d

def test_getBuildRequests_branch(self):
return self.do_test_getBuildRequests_branch_arg(branch='branch_A',
expected=[70, 90])
return self.do_test_getBuildRequests_branch_arg(branch='branch_A',
expected=[70, 90])

def test_getBuildRequests_branch_empty(self):
return self.do_test_getBuildRequests_branch_arg(branch='absent_branch',
expected=[])
return self.do_test_getBuildRequests_branch_arg(branch='absent_branch',
expected=[])

def test_getBuildRequests_repository(self):
return self.do_test_getBuildRequests_branch_arg(
repository='repository_A', expected=[80, 90])
return self.do_test_getBuildRequests_branch_arg(
repository='repository_A', expected=[80, 90])

def test_getBuildRequests_repository_empty(self):
return self.do_test_getBuildRequests_branch_arg(
repository='absent_repository', expected=[])
return self.do_test_getBuildRequests_branch_arg(
repository='absent_repository', expected=[])

def test_getBuildRequests_repository_and_branch(self):
return self.do_test_getBuildRequests_branch_arg(
repository='repository_A', branch='branch_A', expected=[90])
return self.do_test_getBuildRequests_branch_arg(
repository='repository_A', branch='branch_A', expected=[90])

def test_getBuildRequests_no_repository_nor_branch(self):
return self.do_test_getBuildRequests_branch_arg(expected=[70, 80, 90])
return self.do_test_getBuildRequests_branch_arg(expected=[70, 80, 90])

def do_test_claimBuildRequests(self, rows, now, brids, expected=None,
expfailure=None, claimed_at=None):
Expand Down
16 changes: 8 additions & 8 deletions master/buildbot/test/unit/test_db_buildsets.py
Expand Up @@ -420,11 +420,11 @@ def check(bsdictlist):
return d

def test_getRecentBuildsets_noRepoMatch(self):
d = self.insert_test_getRecentBuildsets_data()
d.addCallback(lambda _ :
self.db.buildsets.getRecentBuildsets(2, branch='branch_a',
repository='bad_repo'))
def check(bsdictlist):
self.assertEqual(bsdictlist, [])
d.addCallback(check)
return d
d = self.insert_test_getRecentBuildsets_data()
d.addCallback(lambda _ :
self.db.buildsets.getRecentBuildsets(2, branch='branch_a',
repository='bad_repo'))
def check(bsdictlist):
self.assertEqual(bsdictlist, [])
d.addCallback(check)
return d
2 changes: 1 addition & 1 deletion master/buildbot/test/unit/test_sourcestamp.py
Expand Up @@ -190,6 +190,6 @@ def test_constructor_most_recent_change(self):
revision='1'),
]
for ch in chgs: # mock the DB changeid (aka build number) to match rev
ch.number = int(ch.revision)
ch.number = int(ch.revision)
ss = sourcestamp.SourceStamp(changes=chgs)
self.assertEquals(ss.revision, '3')
2 changes: 1 addition & 1 deletion master/buildbot/test/unit/test_status_mail.py
Expand Up @@ -222,7 +222,7 @@ def test_buildsetFinished_sends_email(self):
build2.getBuilder.return_value = builder1

def fakeGetBuilder(buildername):
return {"Builder1": builder1, "Builder2": builder2}[buildername]
return {"Builder1": builder1, "Builder2": builder2}[buildername]


self.db = fakedb.FakeDBConnector(self)
Expand Down
Expand Up @@ -29,7 +29,7 @@ def tearDown(self):
return self.tearDownBuildStep()

def test_no_specfile(self):
self.assertRaises(config.ConfigErrors, lambda :
self.assertRaises(config.ConfigErrors, lambda :
rpmbuild.RpmBuild())

def test_success(self):
Expand Down
4 changes: 2 additions & 2 deletions master/contrib/SimpleConfig.py
Expand Up @@ -388,8 +388,8 @@ def addSimpleProject(self, name, category, repourl, builderconfigs):
already = False
for cs in self['change_source']:
if cs.repourl == repourl:
log.msg("There's already a changesource for %s. Hope it has the branch you wanted." % cs.repourl)
already = True
log.msg("There's already a changesource for %s. Hope it has the branch you wanted." % cs.repourl)
already = True
if not already:
self['change_source'].append(
# Fuzz the interval to avoid slamming the git server and hitting the MaxStartups or MaxSessions limits
Expand Down
2 changes: 1 addition & 1 deletion master/contrib/buildbot_cvs_mail.py
Expand Up @@ -119,7 +119,7 @@ def send_mail(options):
print >> s, 'CVSROOT: %s' % options.cvsroot
print >> s, 'Files: %s' % fileList
if options.path:
print >> s, 'Path: %s' % options.path
print >> s, 'Path: %s' % options.path
print >> s, 'Project: %s' % options.project
s.write(sys.stdin.read())
print >> s
Expand Down

0 comments on commit 5118be2

Please sign in to comment.