-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev sync ago #5
Open
vespinoza0
wants to merge
13
commits into
master
Choose a base branch
from
dev_sync_ago
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Dev sync ago #5
Changes from 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b650f9d
get ago and sde creds from keeper.
4e47fd9
import sync changes from master
65a15db
Get salesforce AGO item id from keeper
adcaf64
print ago item id temp
b6813af
Use new salesforce secret
dc5e12a
Use salesforce copy creds from keeper
20efffc
use citygeo_secrets to get salesforce ago layer
floptical a4e9d82
update salesforce connection
floptical 02dbab8
use dev SF connection function in sync.py
vespinoza0 8bbb1a6
update sample config
floptical e67b63d
get connection functions from utils.py
floptical 1b51baf
make work --actually roland
floptical e80af40
make use maps.phl.backup
floptical File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
import geopetl | ||
import requests | ||
from requests.adapters import HTTPAdapter, Retry | ||
import citygeo_secrets | ||
from common import * | ||
from config import * | ||
|
||
|
@@ -30,13 +31,13 @@ | |
|
||
# if this is set to true in the config | ||
if TEST: | ||
DEST_DB_CONN_STRING = f'{DEST_DB_ACCOUNT}/{THREEONEONE_PASSWORD}@{DEST_TEST_DSN}' | ||
#connect to test DB | ||
dest_conn = citygeo_secrets.connect_with_secrets(connect_311_test, "GIS_311","databridge-oracle/hostname-testing") | ||
else: | ||
DEST_DB_CONN_STRING = f'{DEST_DB_ACCOUNT}/{THREEONEONE_PASSWORD}@{DEST_PROD_DSN}' | ||
# connect to prod DB | ||
dest_conn = citygeo_secrets.connect_with_secrets(connect_311, "GIS_311","databridge-oracle/hostname") | ||
|
||
|
||
# Connect to database | ||
#print("Connecting to oracle, DNS: {}".format(DEST_DB_CONN_STRING)) | ||
dest_conn = cx_Oracle.connect(DEST_DB_CONN_STRING) | ||
dest_conn.autocommit = True | ||
# 1200000 ms is a 20 minute timeout for really big queries | ||
# Nvm, 0 for infinite | ||
|
@@ -59,10 +60,11 @@ def write_log(msg): | |
@click.option('--year_refresh', '-y', default=None, help='Retrieve records that were updated in a specific year, then upsert them. Ex: 2017') | ||
@click.option('--date_column', '-c', default='LastModifiedDate', help='Date column to select cases by from Salesforce. Default is "LastModifiedDate". You can consider using "CreatedDate" when doing full refreshes.') | ||
def sync(day_refresh, year_refresh, month_refresh, date_column): | ||
salesforce_creds = citygeo_secrets.connect_with_secrets(connect_salesforce, "salesforce API copy" ) | ||
# Connect to Salesforce | ||
sf = Salesforce(username=SF_USER, \ | ||
password=SF_PASSWORD, \ | ||
security_token=SF_TOKEN) | ||
sf = Salesforce(username=salesforce_creds.get('login'), \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above; this should leverage citygeo-secrets by using refactoring the Salesforce connection into a function that is passed to the connect_with_secrets method. |
||
password=salesforce_creds.get('password'), \ | ||
security_token=salesforce_creds.get('token')) | ||
# supposedly SalesForce() takes a timeout parameter, but it doesn't appear to work. | ||
# Instead, we can apparently set the tmeout anyway by inserting our own request session | ||
#session = requests.Session() | ||
|
@@ -371,4 +373,4 @@ def process_rows(sf_rows): | |
|
||
if __name__ == '__main__': | ||
sync() | ||
print('Done.') | ||
print('Done.') |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be refactored into a connection function that is passed to citygeo_secrets in the connect_with_secrets method in order to leverage the packages' functionality of trying again with secrets from the keeper api if the first connection attempt fails using secrets from the mapped drive.