Skip to content

Commit 71237aa

Browse files
authored
Update guide.md
1 parent 284cbfd commit 71237aa

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

docs/guide.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,115 @@ Limited by our time and resources, these less important content has been removed
4646

4747

4848
# 2. Usage
49+
50+
Before we start, it is assumed that you have fully understood the original [python-bugzilla](https://github.com/python-bugzilla/python-bugzilla). Since *MI* can be regarded as a wrapper of the original *CLI*, we will not repeat the contents that can be consulted in `bugzilla.1` or `bugzilla.rst`.
51+
52+
## 2.1. Run *MI*
53+
54+
### 2.1.1. Details
55+
56+
First of all, get into the root directory of this project and then run this in your terminal:
57+
58+
```shell
59+
./bugzilla-mi
60+
```
61+
62+
If there is no accident, you will see the prompt message from `stdout`
63+
```text
64+
|v>ARGINF<v|
65+
ArgumentParser waiting
66+
|^>ARGINF<^|
67+
```
68+
which indicates that *MI* has started running.
69+
70+
Then you need to write these parameters of a call for original `bugzilla-cli` to current `stdin`. At the end, write a *line break* (which equals, the effect when you press *Enter*). And then wait for the new output from `stdout`.
71+
72+
Next, you may need to write other information to current `stdin` according to the prompt message, such as user name and password.
73+
74+
Finally, you will always *(of course, when there is no accident)* get the output of this round from `stdout`.
75+
76+
### 2.1.2. An example
77+
78+
Assuming that you run the original `bugzilla-cli` as
79+
```shell
80+
./bugzilla-cli --bugzilla https://bugzilla.mozilla.org/rest info --products
81+
```
82+
83+
Then you should see this stuff on your screen
84+
```text
85+
AUS Graveyard
86+
Add-on SDK Graveyard
87+
Air Mozilla
88+
...
89+
support.mozillamessaging.com Graveyard
90+
www.mozilla.org
91+
www.mozilla.org Graveyard
92+
```
93+
94+
Now you run `./bugzilla-mi` and then should get
95+
```text
96+
|v>ARGINF<v|
97+
ArgumentParser waiting
98+
|^>ARGINF<^|
99+
100+
```
101+
Type
102+
```text
103+
--bugzilla https://bugzilla.mozilla.org/rest info --products
104+
```
105+
in current line and press *Enter*, you should get this stuff:
106+
```text
107+
|v>STRING<v|
108+
AUS Graveyard
109+
Add-on SDK Graveyard
110+
Air Mozilla
111+
...
112+
support.mozillamessaging.com Graveyard
113+
www.mozilla.org
114+
www.mozilla.org Graveyard
115+
116+
|^>STRING<^|
117+
118+
|v>ARGINF<v|
119+
ArgumentParser waiting
120+
|^>ARGINF<^|
121+
122+
```
123+
Now you are in another round waiting for input.
124+
125+
## 2.2. Understand syntax in `stdout`
126+
127+
### 2.2.1. *Expected* :vs: *Unexpected*
128+
129+
**Expected** output in `stdout`, whether single line or multiple lines, is wrapped by *start-flag-line* and *end-flag-line*. Using a *State Machine* like can make it easy to parse these things.
130+
131+
The front and back of the two lines are forced to add *line break* for each, which ensure that they form separate lines and are easily captured. For example, you can use the following Python style regex to match:
132+
```python
133+
r"\|v>[A-Z]{6}<v\|" #start-flag-line
134+
r"\|\^>[A-Z]{6}<\^\|" #end-flag-line
135+
```
136+
137+
**Unexpected** output in `stdout` is also easy to parse, because these things are not wrapped by any preset flags. They are usually caused by exceptions which can not be handled and cause current process to exit abnormally.
138+
139+
* `|v>ARGINF<v|` & `|^>ARGINF<^|`
140+
* `|v>EXCEPT<v|` & `|^>EXCEPT<^|`
141+
* `|v>STRING<v|` & `|^>STRING<^|`
142+
* `|v>FORMAT<v|` & `|^>FORMAT<^|`
143+
* `|v>ATTACH<v|` & `|^>ATTACH<^|`
144+
* `|v>ILOGIN<v|` & `|^>ILOGIN<^|`
145+
146+
## 2.3. Environment variables
147+
148+
### 2.3.1. `PYTHONBUGZILLA_LOG_FILE`
149+
150+
### 2.3.2. `PYTHONBUGZILLA_REQUESTS_TIMEOUT`
151+
152+
### 2.3.3. `__BUGZILLA_UNITTEST`
153+
154+
### 2.3.4. `__BUGZILLA_UNITTEST_DEBUG`
155+
156+
# 3. Tips
157+
158+
## 3.1. Explicitly specify *XMLRPC* or *REST*
159+
160+
## 3.2. Force creation of new connection instance

0 commit comments

Comments
 (0)