本文整理汇总了Python中env.Env.get_args方法的典型用法代码示例。如果您正苦于以下问题:Python Env.get_args方法的具体用法?Python Env.get_args怎么用?Python Env.get_args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类env.Env
的用法示例。
在下文中一共展示了Env.get_args方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: usage
# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import get_args [as 别名]
if env.get_arg_count() < 4:
usage()
# Get the args
output_type = env.get_arg(0)
hash_type = env.get_arg(1)
hash = env.get_arg(2)
name = env.get_arg(3)
try:
# Create the Push definition
pushdef = env.get_user().create_push_definition()
pushdef.set_output_type(output_type)
# Now add the output_type-specific args from the command line
for arg in env.get_args()[4:]:
key, val = arg.split('=')
pushdef.set_output_param(key, val)
# Subscribe the definition to the hash
if hash_type == 'stream':
sub = pushdef.subscribe_stream_hash(hash, name)
elif hash_type == 'historic':
sub = pushdef.subscribe_historic_playback_id(hash, name)
else:
usage('Invalid hash_type: %s' % (hash_type))
# Display the details of the new subscription
env.display_subscription_details(sub)
except datasift.InvalidDataError, e:
sys.stderr.write('InvalidDataError: %s\n' % e)
示例2:
# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import get_args [as 别名]
streamdef = env.get_user().create_definition(csdl)
# Create the historic
historic = streamdef.create_historic(start, end, sources.split(','), sample, '%s_historic' % (name))
# Display the details of the Historics query
print 'Historics query:'
env.display_historic_details(historic)
print ''
# Create the Push definition
pushdef = env.get_user().create_push_definition()
pushdef.set_output_type(output_type)
# Now add the output_type-specific args from the command line
for arg in env.get_args()[7:]:
key, val = arg.split('=')
pushdef.set_output_param(key, val)
# Subscribe the historic to the hash
sub = pushdef.subscribe_historic(historic, name)
# Start the Historics query
historic.start()
# Display the details of the new subscription
print 'Push subscription:'
env.display_subscription_details(sub)
except datasift.InvalidDataError, e:
sys.stderr.write('InvalidDataError: %s\n' % e)
except datasift.APIError, e:
示例3: Env
# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import get_args [as 别名]
from datetime import datetime
sys.path[0:0] = [os.path.join(os.path.dirname(__file__), "..", ".."),]
import datasift
from env import Env
# Set up the environment
env = Env(sys.argv)
# Make sure we have something to do
if env.get_arg_count() == 0:
sys.stderr.write('Please specify one or more subscription ID\n')
sys.exit(1)
try:
# Go through the subscription IDs we've been given
for subscription_id in env.get_args():
# Get the subscription
subscription = env.get_user().get_push_subscription(subscription_id)
# Pause it
print 'Resuming %s...' % (subscription_id)
subscription.resume()
except datasift.InvalidDataError, e:
sys.stderr.write('InvalidDataError: %s\n' % e)
except datasift.APIError, e:
sys.stderr.write('APIError: %s\n' % e)
except datasift.AccessDeniedError, e:
sys.stderr.write('InvalidDataError: %s\n' % e)
sys.stderr.write('Rate-limit-remaining: %s\n' % str(env.get_user().get_rate_limit_remaining()));
示例4: Env
# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import get_args [as 别名]
from datetime import datetime
sys.path[0:0] = [os.path.join(os.path.dirname(__file__), "..", ".."),]
import datasift
from env import Env
# Set up the environment
env = Env(sys.argv)
# Make sure we have something to do
if env.get_arg_count() == 0:
sys.stderr.write('Please specify one or more playback IDs\n')
sys.exit(1)
try:
# Go through the playback_ids we've been given
for playback_id in env.get_args():
# Get the Historics query
historic = env.get_user().get_historic(playback_id)
# Delete it
print 'Starting %s...' % (playback_id)
historic.start()
except datasift.InvalidDataError, e:
sys.stderr.write('InvalidDataError: %s\n' % e)
except datasift.APIError, e:
sys.stderr.write('APIError: %s\n' % e)
except datasift.AccessDeniedError, e:
sys.stderr.write('InvalidDataError: %s\n' % e)
sys.stderr.write('Rate-limit-remaining: %s\n' % str(env.get_user().get_rate_limit_remaining()));
示例5:
# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import get_args [as 别名]
output_type = env.get_arg(1)
try:
# Create the historics job
historic = env.get_user().create_historic(stream_hash, start, end, sources.split(','), sample, name)
sys.stderr.write('Historic playback ID: {0}\n'.format(historic.get_hash()))
env.display_historic_details(historic)
# Create the Push definition
pushdef = env.get_user().create_push_definition()
pushdef.set_output_type(output_type)
# Now add the output_type-specific args from the command line
for arg in env.get_args()[2:]:
key, val = arg.split('=')
pushdef.set_output_param(key, val)
# Subscribe the historic to the hash
sub = pushdef.subscribe_historic(historic, name)
# Start the Historics query
historic.start()
print 'Push subscription:'
env.display_subscription_details(sub)
except datasift.InvalidDataError, e:
sys.stderr.write('InvalidDataError: %s\n' % e)
except datasift.AccessDeniedError, e:
示例6: open
# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import get_args [as 别名]
output_type = env.get_arg(1)
name = env.get_arg(2)
# Read the CSDL file
csdl = open(csdl_filename, 'r').read()
try:
# Create the stream definition
streamdef = env.get_user().create_definition(csdl)
# Create the Push definition
pushdef = env.get_user().create_push_definition()
pushdef.set_output_type(output_type)
# Now add the output_type-specific args from the command line
for arg in env.get_args()[3:]:
key, val = arg.split('=')
pushdef.set_output_param(key, val)
# Subscribe the definition to the hash
sub = pushdef.subscribe_definition(streamdef, name)
# Display the details of the new subscription
env.display_subscription_details(sub)
except datasift.InvalidDataError, e:
sys.stderr.write('InvalidDataError: %s\n' % e)
except datasift.APIError, e:
sys.stderr.write('APIError: %s\n' % e)
except datasift.AccessDeniedError, e:
sys.stderr.write('AccessDeniedError: %s\n' % e)