Skip to content

Commit 5639f59

Browse files
authored
Update guide.md
1 parent e77036a commit 5639f59

File tree

1 file changed

+51
-2
lines changed

1 file changed

+51
-2
lines changed

docs/guide.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,65 @@ The so called *flag-line* always appear in pair, with one indicating the start o
156156

157157
### 2.3.1. `PYTHONBUGZILLA_LOG_FILE`
158158

159+
Specify the path of log file. If this environment variable is not set, the log file will be stored in parent directory of the directory in which `_mi.py` locates. And the file name will be equal to `datetime.datetime.now().strftime("BZMI%y%m%d%H%M%S.log")`.
160+
161+
If you specify, please ensure that the path can be handled normally by built-in function `open` (e.g. make sure dir exists), otherwise an exception will be raised and *MI* will exit immediately.
162+
163+
This environment variable is only read during the log setting process before *MI* enters its main loop. Changing it during running will not take effect before the next run of *MI*.
164+
159165
### 2.3.2. `PYTHONBUGZILLA_REQUESTS_TIMEOUT`
160166

161-
### 2.3.3. `__BUGZILLA_UNITTEST`
167+
Used in `_session._BugzillaSession._get_timeout` and `_session._BugzillaSession.request`. Actually the timeout value will be passed to an instance of `requests.Session`. It works for both *XMLRPC* and *REST* because [requests](https://requests.readthedocs.io/en/latest/) is used as a unified backend.
168+
169+
See also (definition of `_session._BugzillaSession._get_timeout`):
170+
```python
171+
def _get_timeout(self):
172+
# Default to 5 minutes. This is longer than bugzilla.redhat.com's
173+
# apparent 3 minute timeout so shouldn't affect legitimate usage,
174+
# but saves us from indefinite hangs
175+
DEFAULT_TIMEOUT = 300
176+
envtimeout = os.environ.get("PYTHONBUGZILLA_REQUESTS_TIMEOUT")
177+
return float(envtimeout or DEFAULT_TIMEOUT)
178+
```
179+
180+
### 2.3.3. `__BUGZILLA_UNITTEST_DEBUG`
181+
182+
It may be changed by `tests.conftest.pytest_configure`, but only affects the return value of `bugzilla._cli._is_unittest_debug`. It seems that the only function it has is to ensure that global log output level is `DEBUG`.
183+
184+
:warning: As the author of this guide I cannot accurately determine its use at present, please use with care if you need.
162185

163-
### 2.3.4. `__BUGZILLA_UNITTEST_DEBUG`
186+
### 2.3.4. `__BUGZILLA_UNITTEST`
187+
188+
Referred only in `tests.__init__` as `os.environ["__BUGZILLA_UNITTEST"] = "1"`. It is suspected that this is a bug, the statement is more likely to be `os.environ["__BUGZILLA_UNITTEST_DEBUG"] = "1"`.
189+
190+
:warning: As the author of this guide I cannot accurately determine its use at present, please use with care if you need.
164191

165192
## 2.4 Exit *MI*
166193

194+
It is recommand that do `CTRL`+`C` or equivalent operation. The try-except mechanism in `MI` would catch `KeyboardInterrupt` and print
195+
```text
196+
|v>STRING<v|
197+
Exited at user request
198+
|^>STRING<^|
199+
```
200+
to `stdout` before exit.
201+
167202
# 3. Tips
168203

169204
## 3.1. Explicitly specify *XMLRPC* or *REST*
170205

206+
For example, it is better to use
207+
```text
208+
--bugzilla https://bugzilla.mozilla.org/xmlrpc.cgi
209+
```
210+
or
211+
```text
212+
--bugzilla https://bugzilla.mozilla.org/rest
213+
```
214+
rather than
215+
```text
216+
--bugzilla https://bugzilla.mozilla.org
217+
```
218+
If you do not specify explicitly, it may cause unpredictable exceptions to be raised or unexpected operations to be performed, although an automatic probe is supported.
219+
171220
## 3.2. Force creation of new connection instance

0 commit comments

Comments
 (0)