diff options
author | CoprDistGit <infra@openeuler.org> | 2023-04-23 02:12:51 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-04-23 02:12:51 +0000 |
commit | d86c5c52671f1633bdec96d24395499eaee1ced5 (patch) | |
tree | 61d1f765582cef7185afa68c38b8b2554962be75 | |
parent | 844e6c461c12fc3ae1b4be07a9ce5bc65b549ada (diff) |
automatic import of python-reportportal-clientopeneuler20.03
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-reportportal-client.spec | 554 | ||||
-rw-r--r-- | sources | 2 |
3 files changed, 180 insertions, 377 deletions
@@ -1 +1,2 @@ /reportportal-client-5.3.0.tar.gz +/reportportal-client-5.3.1.tar.gz diff --git a/python-reportportal-client.spec b/python-reportportal-client.spec index 5cb73b5..ae2f2f4 100644 --- a/python-reportportal-client.spec +++ b/python-reportportal-client.spec @@ -1,11 +1,11 @@ %global _empty_manifest_terminate_build 0 Name: python-reportportal-client -Version: 5.3.0 +Version: 5.3.1 Release: 1 Summary: Python client for Report Portal v5. License: Apache 2.0. URL: https://github.com/reportportal/client-Python -Source0: https://mirrors.nju.edu.cn/pypi/web/packages/00/bc/3d445b367a299cbeba361f5ea39a995b216eaa49f6ed9f591891a8d1e1a5/reportportal-client-5.3.0.tar.gz +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/3e/36/ae29af9228f3b4923afe09a3a946840fe266a718171173b3ebfd50568d41/reportportal-client-5.3.1.tar.gz BuildArch: noarch Requires: python3-aenum @@ -26,14 +26,12 @@ Requires: python3-six Library used only for implementors of custom listeners for ReportPortal - ## Already implemented listeners: - [PyTest Framework](https://github.com/reportportal/agent-python-pytest) - [Robot Framework](https://github.com/reportportal/agent-Python-RobotFramework) - [Behave Framework](https://github.com/reportportal/agent-python-behave) -- [Nose Framework](https://github.com/reportportal/agent-python-nosetests) - +- [Nose Framework (archived)](https://github.com/reportportal/agent-python-nosetests) ## Installation @@ -43,53 +41,19 @@ The latest stable version is available on PyPI: pip install reportportal-client ``` -**IMPORTANT!** -The latest client version **does** not support Report Portal versions below -5.0.0. - -Version 3 is the latest one which supports Report Portal versions below 5.0.0 -to install it: - -``` -pip install reportportal-client~=3.0 -``` - - -## Contribution - -All the fixes for the client that supports Report Portal versions below 5.0.0 -should go into the v3 branch. The master branch will store the code base for -the client for Report Portal versions 5 and above. - - ## Usage -Main classes are: - -- reportportal_client.ReportPortalService -- reportportal_client.ReportPortalServiceAsync(Client version 3.x only) - Basic usage example: ```python import os import subprocess -import traceback from mimetypes import guess_type -from time import time -# Report Portal versions below 5.0.0: -from reportportal_client import ReportPortalServiceAsync +from reportportal_client import RPClient +from reportportal_client.helpers import timestamp -# Report Portal versions >= 5.0.0: -from reportportal_client import ReportPortalService - - -def timestamp(): - return str(int(time() * 1000)) - - -endpoint = "http://10.6.40.6:8080" +endpoint = "http://docker.local:8080" project = "default" # You can get UUID from user profile page in the Report Portal. token = "1adf271d-505f-44a8-ad71-0afbdf8c83bd" @@ -97,62 +61,40 @@ launch_name = "Test launch" launch_doc = "Testing logging with attachment." -def my_error_handler(exc_info): - """ - This callback function will be called by async service client when error occurs. - Return True if error is not critical and you want to continue work. - :param exc_info: result of sys.exc_info() -> (type, value, traceback) - :return: - """ - print("Error occurred: {}".format(exc_info[1])) - traceback.print_exception(*exc_info) - - -# Report Portal versions below 5.0.0: -service = ReportPortalServiceAsync(endpoint=endpoint, project=project, - token=token, error_handler=my_error_handler) +client = RPClient(endpoint=endpoint, project=project, + token=token) -# Report Portal versions >= 5.0.0: -service = ReportPortalService(endpoint=endpoint, project=project, - token=token) +# Start log upload thread +client.start() # Start launch. -launch = service.start_launch(name=launch_name, - start_time=timestamp(), - description=launch_doc) - -# Start test item Report Portal versions below 5.0.0: -test = service.start_test_item(name="Test Case", - description="First Test Case", - tags=["Image", "Smoke"], - start_time=timestamp(), - item_type="STEP", - parameters={"key1": "val1", - "key2": "val2"}) - -# Start test item Report Portal versions >= 5.0.0: -item_id = service.start_test_item(name="Test Case", - description="First Test Case", - start_time=timestamp(), - item_type="STEP", - parameters={"key1": "val1", - "key2": "val2"}) - +launch = client.start_launch(name=launch_name, + start_time=timestamp(), + description=launch_doc) + +item_id = client.start_test_item(name="Test Case", + description="First Test Case", + start_time=timestamp(), + attributes=[{"key": "key", "value": "value"}, + {"value", "tag"}], + item_type="STEP", + parameters={"key1": "val1", + "key2": "val2"}) # Create text log message with INFO level. -service.log(time=timestamp(), - message="Hello World!", - level="INFO") +client.log(time=timestamp(), + message="Hello World!", + level="INFO") # Create log message with attached text output and WARN level. -service.log(time=timestamp(), - message="Too high memory usage!", - level="WARN", - attachment={ - "name": "free_memory.txt", - "data": subprocess.check_output("free -h".split()), - "mime": "text/plain" - }) +client.log(time=timestamp(), + message="Too high memory usage!", + level="WARN", + attachment={ + "name": "free_memory.txt", + "data": subprocess.check_output("free -h".split()), + "mime": "text/plain" + }) # Create log message with binary file, INFO level and custom mimetype. image = "/tmp/image.png" @@ -162,57 +104,49 @@ with open(image, "rb") as fh: "data": fh.read(), "mime": guess_type(image)[0] or "application/octet-stream" } - service.log(timestamp(), "Screen shot of issue.", "INFO", attachment) - -# Create log message supplying only contents -service.log( - timestamp(), - "running processes", - "INFO", - attachment=subprocess.check_output("ps aux".split())) - -# Finish test item Report Portal versions below 5.0.0. -service.finish_test_item(end_time=timestamp(), status="PASSED") + client.log(timestamp(), "Screen shot of issue.", "INFO", attachment) -# Finish test item Report Portal versions >= 5.0.0. -service.finish_test_item(item_id=item_id, end_time=timestamp(), status="PASSED") +client.finish_test_item(item_id=item_id, end_time=timestamp(), status="PASSED") # Finish launch. -service.finish_launch(end_time=timestamp()) +client.finish_launch(end_time=timestamp()) # Due to async nature of the service we need to call terminate() method which # ensures all pending requests to server are processed. # Failure to call terminate() may result in lost data. -service.terminate() +client.terminate() ``` - # Send attachment (screenshots) -[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). +The client uses `requests` library for working with RP and the same semantics +to work with attachments (data). -There are two ways to pass data as attachment: +To log an attachment you need to pass file content and metadata to `` -### Case 1 - pass file-like object -``` -with open(screenshot_file_path, "rb") as image_file: - rp_logger.info("Some Text Here", - attachment={"name": "test_name_screenshot.png", - "data": image_file, - "mime": "image/png"}) -``` +```python +import logging -### Case 2 - pass file content itself (like you did) -``` -with open(screenshot_file_path, "rb") as image_file: - file_data = image_file.read() +from reportportal_client import RPLogger, RPLogHandler -rp_logger.info("Some Text Here", - attachment={"name": "test_name_screenshot.png", - "data": file_data, - "mime": "image/png"}) -``` +logging.setLoggerClass(RPLogger) +rp_logger = logging.getLogger(__name__) +rp_logger.setLevel(logging.DEBUG) +rp_logger.addHandler(RPLogHandler()) +screenshot_file_path = 'path/to/file.png' + +with open(screenshot_file_path, "rb") as image_file: + file_data = image_file.read() + + # noinspection PyArgumentList + rp_logger.info( + "Some Text Here", + attachment={"name": "test_name_screenshot.png", + "data": file_data, + "mime": "image/png"} + ) +``` # Copyright Notice @@ -239,14 +173,12 @@ BuildRequires: python3-pip Library used only for implementors of custom listeners for ReportPortal - ## Already implemented listeners: - [PyTest Framework](https://github.com/reportportal/agent-python-pytest) - [Robot Framework](https://github.com/reportportal/agent-Python-RobotFramework) - [Behave Framework](https://github.com/reportportal/agent-python-behave) -- [Nose Framework](https://github.com/reportportal/agent-python-nosetests) - +- [Nose Framework (archived)](https://github.com/reportportal/agent-python-nosetests) ## Installation @@ -256,53 +188,19 @@ The latest stable version is available on PyPI: pip install reportportal-client ``` -**IMPORTANT!** -The latest client version **does** not support Report Portal versions below -5.0.0. - -Version 3 is the latest one which supports Report Portal versions below 5.0.0 -to install it: - -``` -pip install reportportal-client~=3.0 -``` - - -## Contribution - -All the fixes for the client that supports Report Portal versions below 5.0.0 -should go into the v3 branch. The master branch will store the code base for -the client for Report Portal versions 5 and above. - - ## Usage -Main classes are: - -- reportportal_client.ReportPortalService -- reportportal_client.ReportPortalServiceAsync(Client version 3.x only) - Basic usage example: ```python import os import subprocess -import traceback from mimetypes import guess_type -from time import time - -# Report Portal versions below 5.0.0: -from reportportal_client import ReportPortalServiceAsync - -# Report Portal versions >= 5.0.0: -from reportportal_client import ReportPortalService - - -def timestamp(): - return str(int(time() * 1000)) +from reportportal_client import RPClient +from reportportal_client.helpers import timestamp -endpoint = "http://10.6.40.6:8080" +endpoint = "http://docker.local:8080" project = "default" # You can get UUID from user profile page in the Report Portal. token = "1adf271d-505f-44a8-ad71-0afbdf8c83bd" @@ -310,62 +208,40 @@ launch_name = "Test launch" launch_doc = "Testing logging with attachment." -def my_error_handler(exc_info): - """ - This callback function will be called by async service client when error occurs. - Return True if error is not critical and you want to continue work. - :param exc_info: result of sys.exc_info() -> (type, value, traceback) - :return: - """ - print("Error occurred: {}".format(exc_info[1])) - traceback.print_exception(*exc_info) +client = RPClient(endpoint=endpoint, project=project, + token=token) - -# Report Portal versions below 5.0.0: -service = ReportPortalServiceAsync(endpoint=endpoint, project=project, - token=token, error_handler=my_error_handler) - -# Report Portal versions >= 5.0.0: -service = ReportPortalService(endpoint=endpoint, project=project, - token=token) +# Start log upload thread +client.start() # Start launch. -launch = service.start_launch(name=launch_name, - start_time=timestamp(), - description=launch_doc) - -# Start test item Report Portal versions below 5.0.0: -test = service.start_test_item(name="Test Case", - description="First Test Case", - tags=["Image", "Smoke"], - start_time=timestamp(), - item_type="STEP", - parameters={"key1": "val1", - "key2": "val2"}) - -# Start test item Report Portal versions >= 5.0.0: -item_id = service.start_test_item(name="Test Case", - description="First Test Case", - start_time=timestamp(), - item_type="STEP", - parameters={"key1": "val1", - "key2": "val2"}) - +launch = client.start_launch(name=launch_name, + start_time=timestamp(), + description=launch_doc) + +item_id = client.start_test_item(name="Test Case", + description="First Test Case", + start_time=timestamp(), + attributes=[{"key": "key", "value": "value"}, + {"value", "tag"}], + item_type="STEP", + parameters={"key1": "val1", + "key2": "val2"}) # Create text log message with INFO level. -service.log(time=timestamp(), - message="Hello World!", - level="INFO") +client.log(time=timestamp(), + message="Hello World!", + level="INFO") # Create log message with attached text output and WARN level. -service.log(time=timestamp(), - message="Too high memory usage!", - level="WARN", - attachment={ - "name": "free_memory.txt", - "data": subprocess.check_output("free -h".split()), - "mime": "text/plain" - }) +client.log(time=timestamp(), + message="Too high memory usage!", + level="WARN", + attachment={ + "name": "free_memory.txt", + "data": subprocess.check_output("free -h".split()), + "mime": "text/plain" + }) # Create log message with binary file, INFO level and custom mimetype. image = "/tmp/image.png" @@ -375,57 +251,49 @@ with open(image, "rb") as fh: "data": fh.read(), "mime": guess_type(image)[0] or "application/octet-stream" } - service.log(timestamp(), "Screen shot of issue.", "INFO", attachment) - -# Create log message supplying only contents -service.log( - timestamp(), - "running processes", - "INFO", - attachment=subprocess.check_output("ps aux".split())) + client.log(timestamp(), "Screen shot of issue.", "INFO", attachment) -# Finish test item Report Portal versions below 5.0.0. -service.finish_test_item(end_time=timestamp(), status="PASSED") - -# Finish test item Report Portal versions >= 5.0.0. -service.finish_test_item(item_id=item_id, end_time=timestamp(), status="PASSED") +client.finish_test_item(item_id=item_id, end_time=timestamp(), status="PASSED") # Finish launch. -service.finish_launch(end_time=timestamp()) +client.finish_launch(end_time=timestamp()) # Due to async nature of the service we need to call terminate() method which # ensures all pending requests to server are processed. # Failure to call terminate() may result in lost data. -service.terminate() +client.terminate() ``` - # Send attachment (screenshots) -[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). +The client uses `requests` library for working with RP and the same semantics +to work with attachments (data). -There are two ways to pass data as attachment: +To log an attachment you need to pass file content and metadata to `` -### Case 1 - pass file-like object -``` -with open(screenshot_file_path, "rb") as image_file: - rp_logger.info("Some Text Here", - attachment={"name": "test_name_screenshot.png", - "data": image_file, - "mime": "image/png"}) -``` +```python +import logging -### Case 2 - pass file content itself (like you did) -``` -with open(screenshot_file_path, "rb") as image_file: - file_data = image_file.read() +from reportportal_client import RPLogger, RPLogHandler -rp_logger.info("Some Text Here", - attachment={"name": "test_name_screenshot.png", - "data": file_data, - "mime": "image/png"}) -``` +logging.setLoggerClass(RPLogger) +rp_logger = logging.getLogger(__name__) +rp_logger.setLevel(logging.DEBUG) +rp_logger.addHandler(RPLogHandler()) +screenshot_file_path = 'path/to/file.png' + +with open(screenshot_file_path, "rb") as image_file: + file_data = image_file.read() + + # noinspection PyArgumentList + rp_logger.info( + "Some Text Here", + attachment={"name": "test_name_screenshot.png", + "data": file_data, + "mime": "image/png"} + ) +``` # Copyright Notice @@ -449,14 +317,12 @@ Provides: python3-reportportal-client-doc Library used only for implementors of custom listeners for ReportPortal - ## Already implemented listeners: - [PyTest Framework](https://github.com/reportportal/agent-python-pytest) - [Robot Framework](https://github.com/reportportal/agent-Python-RobotFramework) - [Behave Framework](https://github.com/reportportal/agent-python-behave) -- [Nose Framework](https://github.com/reportportal/agent-python-nosetests) - +- [Nose Framework (archived)](https://github.com/reportportal/agent-python-nosetests) ## Installation @@ -466,53 +332,19 @@ The latest stable version is available on PyPI: pip install reportportal-client ``` -**IMPORTANT!** -The latest client version **does** not support Report Portal versions below -5.0.0. - -Version 3 is the latest one which supports Report Portal versions below 5.0.0 -to install it: - -``` -pip install reportportal-client~=3.0 -``` - - -## Contribution - -All the fixes for the client that supports Report Portal versions below 5.0.0 -should go into the v3 branch. The master branch will store the code base for -the client for Report Portal versions 5 and above. - - ## Usage -Main classes are: - -- reportportal_client.ReportPortalService -- reportportal_client.ReportPortalServiceAsync(Client version 3.x only) - Basic usage example: ```python import os import subprocess -import traceback from mimetypes import guess_type -from time import time - -# Report Portal versions below 5.0.0: -from reportportal_client import ReportPortalServiceAsync - -# Report Portal versions >= 5.0.0: -from reportportal_client import ReportPortalService +from reportportal_client import RPClient +from reportportal_client.helpers import timestamp -def timestamp(): - return str(int(time() * 1000)) - - -endpoint = "http://10.6.40.6:8080" +endpoint = "http://docker.local:8080" project = "default" # You can get UUID from user profile page in the Report Portal. token = "1adf271d-505f-44a8-ad71-0afbdf8c83bd" @@ -520,62 +352,40 @@ launch_name = "Test launch" launch_doc = "Testing logging with attachment." -def my_error_handler(exc_info): - """ - This callback function will be called by async service client when error occurs. - Return True if error is not critical and you want to continue work. - :param exc_info: result of sys.exc_info() -> (type, value, traceback) - :return: - """ - print("Error occurred: {}".format(exc_info[1])) - traceback.print_exception(*exc_info) - +client = RPClient(endpoint=endpoint, project=project, + token=token) -# Report Portal versions below 5.0.0: -service = ReportPortalServiceAsync(endpoint=endpoint, project=project, - token=token, error_handler=my_error_handler) - -# Report Portal versions >= 5.0.0: -service = ReportPortalService(endpoint=endpoint, project=project, - token=token) +# Start log upload thread +client.start() # Start launch. -launch = service.start_launch(name=launch_name, - start_time=timestamp(), - description=launch_doc) - -# Start test item Report Portal versions below 5.0.0: -test = service.start_test_item(name="Test Case", - description="First Test Case", - tags=["Image", "Smoke"], - start_time=timestamp(), - item_type="STEP", - parameters={"key1": "val1", - "key2": "val2"}) - -# Start test item Report Portal versions >= 5.0.0: -item_id = service.start_test_item(name="Test Case", - description="First Test Case", - start_time=timestamp(), - item_type="STEP", - parameters={"key1": "val1", - "key2": "val2"}) - +launch = client.start_launch(name=launch_name, + start_time=timestamp(), + description=launch_doc) + +item_id = client.start_test_item(name="Test Case", + description="First Test Case", + start_time=timestamp(), + attributes=[{"key": "key", "value": "value"}, + {"value", "tag"}], + item_type="STEP", + parameters={"key1": "val1", + "key2": "val2"}) # Create text log message with INFO level. -service.log(time=timestamp(), - message="Hello World!", - level="INFO") +client.log(time=timestamp(), + message="Hello World!", + level="INFO") # Create log message with attached text output and WARN level. -service.log(time=timestamp(), - message="Too high memory usage!", - level="WARN", - attachment={ - "name": "free_memory.txt", - "data": subprocess.check_output("free -h".split()), - "mime": "text/plain" - }) +client.log(time=timestamp(), + message="Too high memory usage!", + level="WARN", + attachment={ + "name": "free_memory.txt", + "data": subprocess.check_output("free -h".split()), + "mime": "text/plain" + }) # Create log message with binary file, INFO level and custom mimetype. image = "/tmp/image.png" @@ -585,57 +395,49 @@ with open(image, "rb") as fh: "data": fh.read(), "mime": guess_type(image)[0] or "application/octet-stream" } - service.log(timestamp(), "Screen shot of issue.", "INFO", attachment) - -# Create log message supplying only contents -service.log( - timestamp(), - "running processes", - "INFO", - attachment=subprocess.check_output("ps aux".split())) + client.log(timestamp(), "Screen shot of issue.", "INFO", attachment) -# Finish test item Report Portal versions below 5.0.0. -service.finish_test_item(end_time=timestamp(), status="PASSED") - -# Finish test item Report Portal versions >= 5.0.0. -service.finish_test_item(item_id=item_id, end_time=timestamp(), status="PASSED") +client.finish_test_item(item_id=item_id, end_time=timestamp(), status="PASSED") # Finish launch. -service.finish_launch(end_time=timestamp()) +client.finish_launch(end_time=timestamp()) # Due to async nature of the service we need to call terminate() method which # ensures all pending requests to server are processed. # Failure to call terminate() may result in lost data. -service.terminate() +client.terminate() ``` - # Send attachment (screenshots) -[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). +The client uses `requests` library for working with RP and the same semantics +to work with attachments (data). -There are two ways to pass data as attachment: +To log an attachment you need to pass file content and metadata to `` -### Case 1 - pass file-like object -``` -with open(screenshot_file_path, "rb") as image_file: - rp_logger.info("Some Text Here", - attachment={"name": "test_name_screenshot.png", - "data": image_file, - "mime": "image/png"}) -``` +```python +import logging -### Case 2 - pass file content itself (like you did) -``` -with open(screenshot_file_path, "rb") as image_file: - file_data = image_file.read() +from reportportal_client import RPLogger, RPLogHandler -rp_logger.info("Some Text Here", - attachment={"name": "test_name_screenshot.png", - "data": file_data, - "mime": "image/png"}) -``` +logging.setLoggerClass(RPLogger) +rp_logger = logging.getLogger(__name__) +rp_logger.setLevel(logging.DEBUG) +rp_logger.addHandler(RPLogHandler()) +screenshot_file_path = 'path/to/file.png' + +with open(screenshot_file_path, "rb") as image_file: + file_data = image_file.read() + + # noinspection PyArgumentList + rp_logger.info( + "Some Text Here", + attachment={"name": "test_name_screenshot.png", + "data": file_data, + "mime": "image/png"} + ) +``` # Copyright Notice @@ -644,7 +446,7 @@ license (see the LICENSE.txt file). %prep -%autosetup -n reportportal-client-5.3.0 +%autosetup -n reportportal-client-5.3.1 %build %py3_build @@ -684,5 +486,5 @@ mv %{buildroot}/doclist.lst . %{_docdir}/* %changelog -* Mon Apr 10 2023 Python_Bot <Python_Bot@openeuler.org> - 5.3.0-1 +* Sun Apr 23 2023 Python_Bot <Python_Bot@openeuler.org> - 5.3.1-1 - Package Spec generated @@ -1 +1 @@ -a919cb5b23a06790a530bc295ab84a9a reportportal-client-5.3.0.tar.gz +567f56a8ff663ae6dc008a1da7041b83 reportportal-client-5.3.1.tar.gz |