|
57 | 57 | from .api.components.v2.scanoss_components_pb2_grpc import ComponentsStub
|
58 | 58 | from .api.cryptography.v2.scanoss_cryptography_pb2 import AlgorithmResponse
|
59 | 59 | from .api.cryptography.v2.scanoss_cryptography_pb2_grpc import CryptographyStub
|
60 |
| -from .api.dependencies.v2.scanoss_dependencies_pb2 import ( |
61 |
| - DependencyRequest, |
62 |
| - DependencyResponse, |
63 |
| -) |
| 60 | +from .api.dependencies.v2.scanoss_dependencies_pb2 import DependencyRequest |
64 | 61 | from .api.dependencies.v2.scanoss_dependencies_pb2_grpc import DependenciesStub
|
65 | 62 | from .api.provenance.v2.scanoss_provenance_pb2 import ProvenanceResponse
|
66 | 63 | from .api.scanning.v2.scanoss_scanning_pb2 import HFHRequest
|
|
77 | 74 |
|
78 | 75 | MAX_CONCURRENT_REQUESTS = 5
|
79 | 76 |
|
| 77 | + |
80 | 78 | class ScanossGrpcError(Exception):
|
81 | 79 | """
|
82 | 80 | Custom exception for SCANOSS gRPC errors
|
@@ -139,7 +137,6 @@ def __init__( # noqa: PLR0913, PLR0915
|
139 | 137 | self.req_headers = req_headers
|
140 | 138 | self.metadata = []
|
141 | 139 |
|
142 |
| - |
143 | 140 | if self.api_key:
|
144 | 141 | self.metadata.append(('x-api-key', api_key)) # Set API key if we have one
|
145 | 142 | if ver_details:
|
@@ -528,9 +525,6 @@ def _check_status_response(self, status_response: StatusResponse, request_id: st
|
528 | 525 | :return: True if successful, False otherwise
|
529 | 526 | """
|
530 | 527 |
|
531 |
| - SUCCEDED_WITH_WARNINGS_STATUS_CODE = 2 |
532 |
| - FAILED_STATUS_CODE = 3 |
533 |
| - |
534 | 528 | if not status_response:
|
535 | 529 | self.print_stderr(f'Warning: No status response supplied (rqId: {request_id}). Assuming it was ok.')
|
536 | 530 | return True
|
@@ -601,18 +595,20 @@ def get_provenance_json(self, purls: dict) -> dict:
|
601 | 595 |
|
602 | 596 | def load_generic_headers(self):
|
603 | 597 | """
|
604 |
| - Adds custom headers from req_headers to metadata. |
| 598 | + Adds custom headers from req_headers to metadata. |
605 | 599 |
|
606 |
| - If x-api-key is present and no URL is configured (directly or via |
607 |
| - environment), sets URL to the premium endpoint (DEFAULT_URL2). |
608 |
| - """ |
| 600 | + If x-api-key is present and no URL is configured (directly or via |
| 601 | + environment), sets URL to the premium endpoint (DEFAULT_URL2). |
| 602 | + """ |
609 | 603 | if self.req_headers: # Load generic headers
|
610 | 604 | for key, value in self.req_headers.items():
|
611 |
| - if key == 'x-api-key': # Set premium URL if x-api-key header is set |
| 605 | + if key == 'x-api-key': # Set premium URL if x-api-key header is set |
612 | 606 | if not self.url and not os.environ.get('SCANOSS_GRPC_URL'):
|
613 | 607 | self.url = DEFAULT_URL2 # API key specific and no alternative URL, so use the default premium
|
614 | 608 | self.api_key = value
|
615 | 609 | self.metadata.append((key, value))
|
| 610 | + |
| 611 | + |
616 | 612 | #
|
617 | 613 | # End of ScanossGrpc Class
|
618 | 614 | #
|
|
0 commit comments