forked from airbytehq/airbyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Source Salesforce: Convert to airbyte-lib (airbytehq#33936)
- Loading branch information
Joe Reuter
authored
Jan 9, 2024
1 parent
94f981c
commit e7ff2a1
Showing
5 changed files
with
55 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
airbyte-integrations/connectors/source-salesforce/source_salesforce/run.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
|
||
import sys | ||
import traceback | ||
from datetime import datetime | ||
from typing import List | ||
|
||
from airbyte_cdk.entrypoint import AirbyteEntrypoint, launch | ||
from airbyte_cdk.models import AirbyteErrorTraceMessage, AirbyteMessage, AirbyteTraceMessage, TraceType, Type | ||
from source_salesforce import SourceSalesforce | ||
|
||
|
||
def _get_source(args: List[str]): | ||
catalog_path = AirbyteEntrypoint.extract_catalog(args) | ||
config_path = AirbyteEntrypoint.extract_config(args) | ||
try: | ||
return SourceSalesforce( | ||
SourceSalesforce.read_catalog(catalog_path) if catalog_path else None, | ||
SourceSalesforce.read_config(config_path) if config_path else None, | ||
) | ||
except Exception as error: | ||
print( | ||
AirbyteMessage( | ||
type=Type.TRACE, | ||
trace=AirbyteTraceMessage( | ||
type=TraceType.ERROR, | ||
emitted_at=int(datetime.now().timestamp() * 1000), | ||
error=AirbyteErrorTraceMessage( | ||
message=f"Error starting the sync. This could be due to an invalid configuration or catalog. Please contact Support for assistance. Error: {error}", | ||
stack_trace=traceback.format_exc(), | ||
), | ||
), | ||
).json() | ||
) | ||
return None | ||
|
||
|
||
def run(): | ||
_args = sys.argv[1:] | ||
source = _get_source(_args) | ||
if source: | ||
launch(source, _args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters