本文整理汇总了Python中singer.utils.parse_args方法的典型用法代码示例。如果您正苦于以下问题:Python utils.parse_args方法的具体用法?Python utils.parse_args怎么用?Python utils.parse_args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类singer.utils
的用法示例。
在下文中一共展示了utils.parse_args方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main_impl
# 需要导入模块: from singer import utils [as 别名]
# 或者: from singer.utils import parse_args [as 别名]
def main_impl():
args = utils.parse_args(
["redirect_uri",
"client_id",
"client_secret",
"refresh_token",
"start_date"])
CONFIG.update(args.config)
STATE = {}
if args.state:
STATE.update(args.state)
if args.discover:
do_discover()
elif args.properties:
do_sync(STATE, args.properties)
else:
LOGGER.info("No properties were selected")
示例2: main
# 需要导入模块: from singer import utils [as 别名]
# 或者: from singer.utils import parse_args [as 别名]
def main():
args = utils.parse_args(REQUIRED_CONFIG_KEYS)
#NB> this code will only work correctly when the local time is set to UTC because of calls to the timestamp() method.
os.environ['TZ'] = 'UTC'
mysql_conn = MySQLConnection(args.config)
log_server_params(mysql_conn)
if args.discover:
do_discover(mysql_conn, args.config)
elif args.catalog:
state = args.state or {}
do_sync(mysql_conn, args.config, args.catalog, state)
elif args.properties:
catalog = Catalog.from_dict(args.properties)
state = args.state or {}
do_sync(mysql_conn, args.config, catalog, state)
else:
LOGGER.info("No properties were selected")
示例3: main
# 需要导入模块: from singer import utils [as 别名]
# 或者: from singer.utils import parse_args [as 别名]
def main():
# Parse command line arguments
args = utils.parse_args(REQUIRED_CONFIG_KEYS)
# If discover flag was passed, run discovery mode and dump output to stdout
if args.discover:
catalog = discover()
print(json.dumps(catalog, indent=2))
# Otherwise run in sync mode
else:
Context.tap_start = utils.now()
if args.catalog:
Context.catalog = args.catalog.to_dict()
else:
Context.catalog = discover()
Context.config = args.config
Context.state = args.state
sync()
示例4: main_impl
# 需要导入模块: from singer import utils [as 别名]
# 或者: from singer.utils import parse_args [as 别名]
def main_impl():
args = singer_utils.parse_args(REQUIRED_CONFIG_KEYS)
CONFIG.update(args.config)
sf = None
try:
sf = Salesforce(
refresh_token=CONFIG['refresh_token'],
sf_client_id=CONFIG['client_id'],
sf_client_secret=CONFIG['client_secret'],
quota_percent_total=CONFIG.get('quota_percent_total'),
quota_percent_per_run=CONFIG.get('quota_percent_per_run'),
is_sandbox=CONFIG.get('is_sandbox'),
select_fields_by_default=CONFIG.get('select_fields_by_default'),
default_start_date=CONFIG.get('start_date'),
api_type=CONFIG.get('api_type'))
sf.login()
if args.discover:
do_discover(sf)
elif args.properties:
catalog = args.properties
state = build_state(args.state, catalog)
do_sync(sf, catalog, state)
finally:
if sf:
if sf.rest_requests_attempted > 0:
LOGGER.debug(
"This job used %s REST requests towards the Salesforce quota.",
sf.rest_requests_attempted)
if sf.jobs_completed > 0:
LOGGER.debug(
"Replication used %s Bulk API jobs towards the Salesforce quota.",
sf.jobs_completed)
if sf.login_timer:
sf.login_timer.cancel()
示例5: setup_context
# 需要导入模块: from singer import utils [as 别名]
# 或者: from singer.utils import parse_args [as 别名]
def setup_context():
args = utils.parse_args(REQUIRED_CONFIG_KEYS)
Context.config = args.config
Context.state = args.state
示例6: get_args
# 需要导入模块: from singer import utils [as 别名]
# 或者: from singer.utils import parse_args [as 别名]
def get_args():
unchecked_args = utils.parse_args([])
if 'username' in unchecked_args.config.keys():
return utils.parse_args(REQUIRED_CONFIG_KEYS_HOSTED)
return utils.parse_args(REQUIRED_CONFIG_KEYS_CLOUD)
示例7: main_impl
# 需要导入模块: from singer import utils [as 别名]
# 或者: from singer.utils import parse_args [as 别名]
def main_impl():
args = utils.parse_args(REQUIRED_CONFIG_KEYS)
account_id = args.config['account_id']
access_token = args.config['access_token']
CONFIG.update(args.config)
global RESULT_RETURN_LIMIT
RESULT_RETURN_LIMIT = CONFIG.get('result_return_limit', RESULT_RETURN_LIMIT)
global API
API = FacebookAdsApi.init(access_token=access_token)
user = fb_user.User(fbid='me')
accounts = user.get_ad_accounts()
account = None
for acc in accounts:
if acc['account_id'] == account_id:
account = acc
if not account:
raise TapFacebookException("Couldn't find account with id {}".format(account_id))
if args.discover:
do_discover()
elif args.properties:
catalog = Catalog.from_dict(args.properties)
do_sync(account, catalog, args.state)
else:
LOGGER.info("No properties were selected")
示例8: main
# 需要导入模块: from singer import utils [as 别名]
# 或者: from singer.utils import parse_args [as 别名]
def main():
args = utils.parse_args(tap_facebook.REQUIRED_CONFIG_KEYS)
with tempfile.TemporaryDirectory(prefix='insights-experiment-') as config_dir:
while True:
level = gen_level()
breakdowns = gen_breakdowns()
action_breakdowns = gen_action_breakdowns()
if not action_breakdowns:
action_attribution_windows = []
else:
action_attribution_windows = gen_action_attribution_windows()
table = {
'level': level,
'action_breakdowns': action_breakdowns,
'breakdowns': breakdowns,
'action_attribution_windows': action_attribution_windows
}
field_set_name = random.choice(list(FIELD_SETS.keys()))
fields = FIELD_SETS[field_set_name]
config = copy.deepcopy(args.config)
# config['insights_tables'] = [table] Don't vary config right now
result = run_tap(config_dir, config, table, field_set_name, fields)
json.dump(result, sys.stdout)
print("")
sys.stdout.flush()
示例9: main_impl
# 需要导入模块: from singer import utils [as 别名]
# 或者: from singer.utils import parse_args [as 别名]
def main_impl():
args = utils.parse_args(REQUIRED_CONFIG_KEYS)
CONFIG.update(args.config)
STATE.update(args.state)
customer_ids = CONFIG['customer_ids'].split(",")
if args.discover:
do_discover(customer_ids)
LOGGER.info("Discovery complete")
elif args.properties:
do_sync_all_customers(customer_ids, args.properties)
LOGGER.info("Sync Completed")
else:
LOGGER.info("No properties were selected")
示例10: cli
# 需要导入模块: from singer import utils [as 别名]
# 或者: from singer.utils import parse_args [as 别名]
def cli():
args = utils.parse_args(REQUIRED_CONFIG_KEYS)
main(args.config)
示例11: main
# 需要导入模块: from singer import utils [as 别名]
# 或者: from singer.utils import parse_args [as 别名]
def main(target):
"""
Given a target, stream stdin input as a text stream.
:param target: object which implements `write_batch` and `activate_version`
:return: None
"""
config = utils.parse_args([]).config
input_stream = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8')
stream_to_target(input_stream, target, config=config)
return None
示例12: main
# 需要导入模块: from singer import utils [as 别名]
# 或者: from singer.utils import parse_args [as 别名]
def main():
# Parse command line arguments
args = utils.parse_args(REQUIRED_CONFIG_KEYS)
# If discover flag was passed, run discovery mode and dump output to stdout
if args.discover:
catalog = discover()
catalog.dump()
# Otherwise run in sync mode
else:
if args.catalog:
catalog = args.catalog
else:
catalog = discover()
sync(args.config, args.state, catalog)