当前位置: 首页>>代码示例>>Python>>正文


Python Env.get_user方法代码示例

本文整理汇总了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))
开发者ID:IgorekSF,项目名称:datasift-python,代码行数:32,代码来源:push-from-hash.py

示例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)
开发者ID:victorduan,项目名称:ds_support-scripts,代码行数:33,代码来源:historics_script.py

示例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()));
开发者ID:IgorekSF,项目名称:datasift-python,代码行数:32,代码来源:resume.py

示例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)
开发者ID:victorduan,项目名称:ds_support-scripts,代码行数:33,代码来源:historic-clean-up.py

示例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()));
开发者ID:IgorekSF,项目名称:datasift-python,代码行数:32,代码来源:start.py


注:本文中的env.Env.get_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。