Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@project.from_parameters
def dynamic_costs():
# refactor this is legacy
inputs = {
"Start Date":project.task['date_start'],
"End Date":project.task['date_end'],
"Relative Date Range":project.task['date_relative'],
"Shadow Advertiser ID":project.task['shadow_advertiser_id'],
"Main Advertiser ID":project.task['main_advertiser_id'],
"Shadow Campaign ID":project.task['shadow_campaign_id'],
"Main Campaign ID":project.task['main_campaign_id'],
"Dynamic Profile ID":project.task['dynamic_profile_id'],
}
if project.verbose: print("DYNAMIC COSTS PARAMETERS", inputs)
@project.from_parameters
def ds():
if project.verbose: print('DS')
if 'report' in project.task:
day = project.date - timedelta(days=abs(project.task['days']))
_one_report(day)
@project.from_parameters
def entity():
if project.verbose: print 'ENTITY'
# legacy translations ( changed partners, advertisers to accounts with "partner_id:advertiser_id" )
if 'partner_id' in project.task:
project.task['accounts'] = [project.task['partner_id']]
# create entities
for entity in project.task['entities']:
if project.verbose: print 'ENTITY:', entity
# write public files only once
if entity in PUBLIC_FILES:
path = 'gdbm-public:entity/%s.0.%s.json' % (project.date.strftime('%Y%m%d'), entity)
schema = Entity_Schema_Lookup[entity]
move_entity(project, path, entity, schema, 'WRITE_TRUNCATE')
@project.from_parameters
def hello():
if project.verbose: print('HELLO')
print('')
print('-' * 80)
print("Tasks are just python, you can do whatever.")
print("This is a task being executed.")
print('')
print('SAY:', project.task['say'])
print('')
print('')
print('-' * 80)
print("Every task automatically gets a date parameter.")
print("The parameter can be passed in, or defaults to today.")
@project.from_parameters
def _traffic():
"""For development purposes when debugging a specific entity, this function is handy to run just that entity.
"""
setup()
init_daos()
dynamic_targeting_keys()
@project.from_parameters
def smartsheet():
if project.verbose: print('Smartsheet')
link = project.task.get('link', True)
smart = Smartsheet(access_token=project.task['token'])
smart.errors_as_exceptions(True)
sheet = smart.Sheets.get_sheet(project.task['sheet'], include=("rowPermalink" if link else ''))
rows = get_rows(sheet, False, link)
project.task['out'].setdefault('bigquery', {}).setdefault('schema', get_schema(sheet))
print('SCHEMA = %s' % json.dumps(project.task['out']['bigquery']['schema'], indent=2))
if link and 'schema' in project.task['out']['bigquery']:
project.task['out']['bigquery']['schema'].insert(0, { "name":"rowPermalink", "type":"STRING", "mode":"NULLABLE" })
@project.from_parameters
def barnacle():
if project.verbose: print('BARNACLE')
accounts = set(get_rows("user", project.task['accounts']))
if 'accounts' in project.task['endpoints']:
# Accounts
rows = get_accounts(accounts)
put_rows(
project.task['out']['auth'],
put_json('CM_Accounts', ACCOUNTS_SCHEMA),
rows
)
if 'profiles' in project.task['endpoints']:
# Profiles
@project.from_parameters
def lineitem():
if project.verbose: print('LINEITEM')
if 'read' in project.task:
advertisers = []
insertion_orders = []
line_items = []
if 'advertisers' in project.task['read']:
advertisers = get_rows(project.task['auth'], project.task['read']['advertisers'])
elif 'insertion_orders' in project.task['read']:
insertion_orders = get_rows(project.task['auth'], project.task['read']['insertion_orders'])
elif 'line_items' in project.task['read']:
line_items = get_rows(project.task['auth'], project.task['read']['line_items'])
@project.from_parameters
def iam():
set_iam(project.task['auth'], project.id, project.task['role'], project.task['email'])
@project.from_parameters
def salesforce():
if project.verbose: print('Salesforce')
sf = authenticate(
project.task['domain'],
project.task['client'],
project.task['secret'],
project.task['username'],
project.task['password']
)
if 'query' in project.task:
rows = query(sf, project.task['query'])
if rows: put_rows(project.task['auth'], project.task['out'], rows)