You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Due to async nature of the service we need to call terminate() method which
168
99
# ensures all pending requests to server are processed.
169
100
# Failure to call terminate() may result in lost data.
170
-
service.terminate()
101
+
client.terminate()
171
102
```
172
103
173
-
174
104
# Send attachment (screenshots)
175
105
176
-
[python-client](https://github.com/reportportal/client-Python/blob/64550693ec9c198b439f8f6e8b23413812d9adf1/reportportal_client/service.py#L259) uses `requests` library for working with RP and the same semantics to work with attachments (data).
106
+
The client uses `requests` library for working with RP and the same semantics
107
+
to work with attachments (data).
177
108
178
-
There are two ways to pass data as attachment:
109
+
To log an attachment you need to pass file content and metadata to ``
179
110
180
-
### Case 1 - pass file-like object
181
-
```
182
-
with open(screenshot_file_path, "rb") as image_file:
183
-
rp_logger.info("Some Text Here",
184
-
attachment={"name": "test_name_screenshot.png",
185
-
"data": image_file,
186
-
"mime": "image/png"})
187
-
```
111
+
```python
112
+
import logging
188
113
189
-
### Case 2 - pass file content itself (like you did)
190
-
```
191
-
with open(screenshot_file_path, "rb") as image_file:
192
-
file_data = image_file.read()
114
+
from reportportal_client import RPLogger, RPLogHandler
193
115
194
-
rp_logger.info("Some Text Here",
195
-
attachment={"name": "test_name_screenshot.png",
196
-
"data": file_data,
197
-
"mime": "image/png"})
198
-
```
116
+
logging.setLoggerClass(RPLogger)
117
+
rp_logger = logging.getLogger(__name__)
118
+
rp_logger.setLevel(logging.DEBUG)
119
+
rp_logger.addHandler(RPLogHandler())
120
+
121
+
screenshot_file_path ='path/to/file.png'
199
122
123
+
withopen(screenshot_file_path, "rb") as image_file:
0 commit comments