36 Commits

Author SHA1 Message Date
Benjamin Drung
c9339aeae4 import-bug-from-debian: add type hints 2024-11-02 15:34:59 +01:00
Benjamin Drung
c205ee0381 import-bug-from-debian: avoid type change of bug_num
The variable `bug_num` has the type `str`. Do not reuse the name for
type `int` to ease mypy.
2024-11-02 15:33:15 +01:00
Benjamin Drung
7577e10f13 import-bug-from-debian: reuse message variable
`log[0]["message"]` was already queried.
2024-11-02 15:32:19 +01:00
Florent 'Skia' Jacquet
e328dc05c2 import-bug-from-debian: split big main function into smaller ones
This allows better understanding of the various parts of the code, by
naming important parts and defining boundaries on the used variables.
2024-11-02 15:08:09 +01:00
Florent 'Skia' Jacquet
9a94c9dea1 import-bug-from-debian: handle multipart messages
With multipart messages, like #1073996, `import-bug-from-debian` would
produce bug description with this:
```
[<email.message.Message object at 0x7fbe14096fa0>, <email.message.Message object at 0x7fbe15143820>]
```
For that kind of bug, it now produces a correct description with the
plain text parts concatenated in the description, the attachments added
as attachments, and the inline images converted to attachments with an
inline message placeholder.

See #981577 for a particularly weird case now gracefully handled.
If something weirder happens, then the tool will now abort with a clear
message instead of producing garbage.

Closes: #969510
2024-11-02 14:57:01 +01:00
Benjamin Drung
aa556af89d Use f-strings
pylint complains about C0209: Formatting a regular string which could be
a f-string (consider-using-f-string)

Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
2023-01-31 19:32:58 +01:00
Benjamin Drung
f6fde2e217 fix: Use lazy % formatting in logging functions
pylint complains about W1201: Use lazy % formatting in logging functions
(logging-not-lazy) and W1203: Use lazy % formatting in logging functions
(logging-fstring-interpolation).

Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
2023-01-31 11:13:07 +01:00
Benjamin Drung
72add78e9d Fix errors found by pylint
Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
2023-01-31 10:19:24 +01:00
Benjamin Drung
b1bc7e1cdc Address pylint complaints
Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
2023-01-30 23:10:31 +01:00
Benjamin Drung
4e27045f49 style: Sort Python imports with isort
```
isort -l 99 --profile=black .
```

Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
2023-01-30 21:28:47 +01:00
Benjamin Drung
3354b526b5 style: Format Python code with black
```
PYTHON_SCRIPTS=$(grep -l -r '^#! */usr/bin/python3$' .)
black -C -l 99 . $PYTHON_SCRIPTS
```

Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
2023-01-30 19:45:36 +01:00
Dan Streetman
0eeb93ee0c logging: update ubuntutools.getLogger() to output to stdout/stderr correctly
Python logging by default sends all output to stderr, but that's not what
normal programs usually do and is not expected for these scripts.

Change the ubuntutools.getLogger() method to return a logger with handlers
correctly set up to send INFO level (or lower) logs to stdout and WARNING
level (or higher; technically INFO+1 level or higher) logs to stderr.

This results in normally logged output going to stdout and warnings/errors
going to stderr, as expected.
2021-02-02 06:25:12 -05:00
Dan Streetman
f2118d6e7f d/control: add python3-debianbts dep, remove runtime check
Signed-off-by: Dan Streetman <ddstreet@canonical.com>
2021-02-02 06:25:12 -05:00
Logan Rosen
2720ffa12a import-bug-from-debian: limit description to 50K chars
LP: #1193941
2020-12-26 01:49:43 -05:00
Dan Streetman
90e8fe81e1 replace ubuntutools.logger with standard python logging 2019-11-25 10:10:06 -05:00
Mattia Rizzolo
e083529784
import-bug-from-debian: revert a change from the last merge: keep debianbts an optional dependency
Signed-off-by: Mattia Rizzolo <mattia@debian.org>
2019-09-26 10:56:48 +02:00
Dan Streetman
0d9d78a721 import-bug-from-debian fixes
change PEP263 coding value from invalid UTF-8 to valid utf-8

don't try to import debianbts, just import debianbts

migrate to argparge

add --verbose option

actually make --dry-run do a dry run

handle multiple cmdline bug numbers

correctly get the bug summary
2019-09-11 17:02:14 -04:00
Stefano Rivera
66afe7c6fc Port import-bug-from-debian to Python 3
Use python3-debianbts for BTS wrangling, rather than SOAPPy, which
wasn't ported to Python 3.
2019-09-04 19:24:44 -03:00
Benjamin Drung
cc7170eccb Fix all flake8 issues 2017-05-01 00:20:03 +02:00
Benjamin Drung
7206593bc9 import-bug-from-debian: Move ubuntutools.logger import before possible usage. 2013-03-19 00:43:31 +01:00
Benjamin Drung
c2aa97dba2 Move devscripts.logger to ubuntutools.logger. 2013-03-19 00:18:02 +01:00
Stefano Rivera
3a07cf4a74 import-bug-from-debian: Bugs are filed against source packages in Ubuntu.
(LP: #844734)
2011-09-08 23:47:38 +02:00
Evan Broder
d82e65e0e2 * ubuntutools.subprocess:
- New drop-in replacement wrapper module around subprocess that
    backports the restore_signals kwarg and defaults close_fds=True
  - Switch everything previously using subprocess to use
    ubuntutools.subprocess instead (LP: #785854)
2011-05-24 20:22:37 +02:00
Stefano Rivera
997fb23b2d Use Launchpadlib.login_with() directly in scripts. 2011-03-01 00:30:54 +02:00
Benjamin Drung
bae108a7ae import-bug-from-debian: Show error messages instead of having the import errors for recommended packages (Closes: #613101, LP: #693813). 2011-02-12 23:13:44 +01:00
Michael Bienia
5ef61615ce Use the new web_link attribute of LP objects instead of our own
translate_api_web() function.
2011-02-11 15:33:09 +01:00
Stefano Rivera
ec5abfe6f2 Include BTS URL, as launchpad links 'bug XYZ' to LP: #XYZ 2011-01-04 22:26:24 +02:00
Stefano Rivera
9c916053b1 import-bug-from-debian: Add --package option, for importing bugs from
psuedo-packages.
2011-01-04 22:24:06 +02:00
Benjamin Drung
b09ddfee2f Make pylint happier. 2010-12-27 21:54:31 +01:00
Stefano Rivera
bd08a0c423 Config file for import-bug-from-debian 2010-12-21 23:41:55 +02:00
Michael Bienia
133f91bbf9 lp-shell, import-bug-from-debian:
Use the 'production' LP instance instead of 'edge' (which is going away).
2010-12-03 13:54:28 +01:00
Benjamin Drung
1943df29eb Remove all trailing spaces. 2010-12-03 00:06:43 +01:00
Stefano Rivera
fafd303131 Manpage for import-bug-from-debian 2010-09-21 18:14:38 +02:00
Michael Bienia
19f2e81a3b import-bug-from-debian: Clean up a little bit 2010-07-29 00:00:33 +02:00
Michael Bienia
aecf197601 Add copyright information for "import-bug-from-debian" and install it as part of ubuntu-dev-tools. 2010-07-11 20:30:08 +02:00
Michael Bienia
becabaff92 Add http://people.canonical.com/~jamesw/import-bug-from-debian.py 2010-07-11 18:43:19 +02:00