Merge ~paelzer/ubuntu-helpers:lp-test-small-fixes into ~paelzer/ubuntu-helpers:master

Proposed by Christian Ehrhardt 
Status: Merged
Merge reported by: Christian Ehrhardt 
Merged at revision: fd36e0f191c80fd7224a655a2db4239ccc8fcd36
Proposed branch: ~paelzer/ubuntu-helpers:lp-test-small-fixes
Merge into: ~paelzer/ubuntu-helpers:master
Prerequisite: ~bryce/ubuntu-helpers:lp-test-refactoring
Diff against target: 84 lines (+11/-5)
1 file modified
cpaelzer/lp-test-ppa (+11/-5)
Reviewer Review Type Date Requested Status
Bryce Harrington (community) Approve
Canonical Server Pending
Review via email: mp+425209@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Michał Małoszewski (michal-maloszewski99) wrote (last edit ):

Code is good in my opinion.
One question: I know it's not linux kernel coding style, but wouldn't it be easier to use tabs and then spaces to align the code?
I mean <tab> <space space space> code - instead of only spaces. I mean indentation.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

On Wed, Jun 22, 2022 at 1:58 PM Michał Małoszewski
<email address hidden> wrote:
>
> Code is good in my opinion.
> One question: I know it's not linux kernel coding style, but wouldn't it be easier to use tabs and then spaces to align the code?
> I mean <tab> <space space space> code - instead of only spaces.

TBH I think the majority of code we deal with uses only space and we
generally stick to whatever we find some code use.

P.S: In fact I can't write tabs as I globally auto convert it to 4
spaces, to write one I have to copy it. Which confirms how rarely it
is needed.

Revision history for this message
Bryce Harrington (bryce) wrote :

On Wed, Jun 22, 2022 at 02:54:18PM -0000, Christian Ehrhardt  wrote:
> On Wed, Jun 22, 2022 at 1:58 PM Michał Małoszewski
> <email address hidden> wrote:
> >
> > Code is good in my opinion.
> > One question: I know it's not linux kernel coding style, but wouldn't it be easier to use tabs and then spaces to align the code?
> > I mean <tab> <space space space> code - instead of only spaces.
>
> TBH I think the majority of code we deal with uses only space and we
> generally stick to whatever we find some code use.
>
> P.S: In fact I can't write tabs as I globally auto convert it to 4
> spaces, to write one I have to copy it. Which confirms how rarely it
> is needed.

My own policy is to conform to the tab/space style of the project in
question. In my experience spaces-only cause the least commotion,
however I've worked on codebases the full spectrum and so have adopted
the habit of including a Mode line in my scripts. For python scripts I
include this as the 2nd line:

# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-

This both helps to document the whitespace convention for the project on
a per-file basis, and also is parsed by vim/emacs so I can be lazy and
not have to think about it. :-)

Bryce

Revision history for this message
Bryce Harrington (bryce) wrote :

Thanks for the review Christian! And doubly so for implementing your review comments and doing a follow on MP. Per your directions on https://code.launchpad.net/~paelzer/ubuntu-helpers/+git/ubuntu-helpers/+merge/425209 I've merged both branches and landed them.

I squashed some of the smaller and more obvious changes into the commits that created the issue, but have left most of your review comments as-is since they include some useful commentary and/or are distinct.

I need to re-base the branch Athos reviewed on top of these, however we're still discussing a couple refactoring points, so will tackle that later. Meanwhile, please let me know if you spot any other issues with any of these changes.

review: Approve
Revision history for this message
Bryce Harrington (bryce) wrote :

This branch can be marked merged btw.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cpaelzer/lp-test-ppa b/cpaelzer/lp-test-ppa
2index 448ed70..91017ae 100755
3--- a/cpaelzer/lp-test-ppa
4+++ b/cpaelzer/lp-test-ppa
5@@ -30,11 +30,14 @@ from launchpadlib.launchpad import Launchpad
6
7 # Global constants
8 ARCHES = ["amd64", "s390x", "ppc64el", "arm64", "armhf", "riscv64"]
9+LPAPI = "https://api.launchpad.net/devel"
10+
11
12 def error(msg):
13 """Prints message to stderr"""
14 sys.stderr.write("Error: {}\n".format(msg))
15
16+
17 class Job:
18 def __init__(self, number, time, pkg, series, arch, jobinfo):
19 self.number = number
20@@ -146,7 +149,7 @@ def showActive(release, ppa_user, ppa_name):
21 if running:
22 print(rformat % ("time", "pkg", "release", "arch", "ppa", "trigger"))
23 for e in running:
24- print(rformat % (str(e.time), e.pkg, e.series, e.arch, ','.join(e.ppas), ','.join(e.triggers)))
25+ print(rformat % (str(datetime.timedelta(seconds=e.time)), e.pkg, e.series, e.arch, ','.join(e.ppas), ','.join(e.triggers)))
26
27 print("Waiting:")
28 waiting = getWaiting()
29@@ -290,11 +293,12 @@ def showResult(result, published):
30
31 print("\t%s %s" % (overall_status, report_txt))
32
33+
34 def showBinaries(ppa, release):
35 """Report all published binaries in this PPA"""
36 print("Binaries:")
37 for arch in ARCHES:
38- archs = "%s/ubuntu/%s/%s" % (base, release, arch)
39+ archs = "%s/ubuntu/%s/%s" % (LPAPI, release, arch)
40 ppa_builds = ppa.getPublishedBinaries(distro_arch_series=archs)
41 if not ppa_builds:
42 print("%s - no binaries present yet" % arch)
43@@ -305,6 +309,7 @@ def showBinaries(ppa, release):
44 build.binary_package_version,
45 build.status))
46
47+
48 def create_arg_parser():
49 """Sets up the command line parser object.
50
51@@ -401,13 +406,14 @@ def main(args):
52
53 # log in
54 cred_location = os.path.expanduser('~/.lp_creds')
55- credential_store = UnencryptedFileCredentialStore(cred_location)
56+ UnencryptedFileCredentialStore(cred_location)
57 lp = Launchpad.login_with('affectrelease', 'production', version='devel')
58
59 # project/person owning the PPA
60 person = lp.people[ppa_user]
61
62 if args.arches:
63+ global ARCHES
64 ARCHES = args.arches[0]
65
66 # get ppa
67@@ -421,8 +427,7 @@ def main(args):
68 for release in args.releases[0]:
69 print("---- ---- ---- ----")
70 print("Release: %s" % release)
71- base="https://api.launchpad.net/devel"
72- series = "%s/ubuntu/%s" % (base, release)
73+ series = "%s/ubuntu/%s" % (LPAPI, release)
74 ppa_sources = ppa.getPublishedSources(distro_series=series)
75 if not ppa_sources:
76 print("Warning: no sources present for %s" % release)
77@@ -462,6 +467,7 @@ def main(args):
78 error("PPA %s not found" % ppa_name)
79 return 1
80
81+
82 if __name__ == "__main__":
83 parser = create_arg_parser()
84 args = parser.parse_args()

Subscribers

People subscribed via source and target branches

to all changes: