本文整理汇总了Python中env.Env.get_user方法的典型用法代码示例。如果您正苦于以下问题:Python Env.get_user方法的具体用法?Python Env.get_user怎么用?Python Env.get_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类env.Env
的用法示例。
在下文中一共展示了Env.get_user方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Env
# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import get_user [as 别名]
# Set up the environment
env = Env(sys.argv)
# Make sure we have enough arguments
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))
示例2:
# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import get_user [as 别名]
name = config.name
# FTP
output_type = config.output_type
output_params = config.output_params
try:
# Parse the dates from the command line
in_format = '%Y-%m-%d %H:%M:%S'
start_date = time.strptime(start_date, in_format)
end_date = time.strptime(end_date, in_format)
start = calendar.timegm(start_date)
end = calendar.timegm(end_date)
# 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
for key,val in output_params.items():
pushdef.set_output_param(key, val)
# Subscribe the historic to the hash
sub = pushdef.subscribe_historic(historic, name)
示例3: Env
# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import get_user [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_user [as 别名]
import time
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)
try:
pageSize = 20
pageNum = 1
runLoop = True
while runLoop:
# Get the list of Historics queries in your account
queries = env.get_user().list_historics(pageNum, pageSize)
pageNum += 1
if len(queries['historics']) == 0:
print "No Historics Found"
runLoop = False
break
for historic in queries['historics']:
if historic.get_status() == "init":
historic.delete()
print "Deleting Playback ID: {0}, Status: {1}".format(historic.get_hash(), historic.get_status())
elif historic.get_status() == "succeeded":
#print historic.get_created_at()
histJob = datetime.fromtimestamp(int(historic.get_created_at()))
refDate = datetime.now() - timedelta(days=14)
示例5: Env
# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import get_user [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()));