本文整理汇总了Python中env.Env.get_arg_count方法的典型用法代码示例。如果您正苦于以下问题:Python Env.get_arg_count方法的具体用法?Python Env.get_arg_count怎么用?Python Env.get_arg_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类env.Env
的用法示例。
在下文中一共展示了Env.get_arg_count方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Env
# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import get_arg_count [as 别名]
sys.stderr.write(' key=val = output_type-specific arguments\n')
sys.stderr.write('\n')
sys.stderr.write('Example\n')
sys.stderr.write(' PushFromHash http stream <hash> \"Push Name\" delivery_frequency=10 \\\n')
sys.stderr.write(' url=http://www.example.com/push_endpoint auth.type=none\n')
sys.stderr.write('\n')
sys.stderr.write('\n')
if exit:
sys.exit(1)
# 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:]:
示例2: Env
# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import get_arg_count [as 别名]
# encoding: utf-8
# This example displays the log for all or one subscription in your account.
import sys, os
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)
# Do we have a subscription ID?
try:
arg_count = env.get_arg_count()
if arg_count > 1:
sys.stderr.write('Please specify no more than one subscription ID\n')
sys.exit(1)
elif arg_count == 0:
log = env.get_user().get_push_subscription_log()
else:
# Get the subscription ID
subscription_id = env.get_arg(0)
# Get the subscription
log = env.get_user().get_push_subscription_log(subscription_id)
# Display the log
if log['count'] == 0:
print 'No log entries found.'
示例3: Env
# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import get_arg_count [as 别名]
# encoding: utf-8
# This example resumes one or more Push subscriptions in your account.
import sys, os
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)
示例4: Env
# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import get_arg_count [as 别名]
sys.stderr.write(' sources = the data sources the Historics query should match\n')
sys.stderr.write(' sample = what percentage of the matching interactions are required\n')
sys.stderr.write(' name = a friendly name for the Historics query\n')
sys.stderr.write('\n')
sys.stderr.write('Example\n')
sys.stderr.write(' create-from-hash.py <hash> 20120801120000 20120801130000 twitter 100 \\\n')
sys.stderr.write(' MyHistoricsQuery\n')
sys.stderr.write('\n')
if exit:
sys.exit(1)
# Set up the environment
env = Env(sys.argv)
# Make sure we have enough arguments
if env.get_arg_count() != 6:
usage()
# Get the args
stream_hash = env.get_arg(0)
start_date = env.get_arg(1)
end_date = env.get_arg(2)
sources = env.get_arg(3)
sample = env.get_arg(4)
name = env.get_arg(5)
# Parse the dates from the command line
in_format = '%Y%m%d%H%M%S'
out_format = '%s'
start = datetime.strptime(start_date, in_format).strftime(out_format)
end = datetime.strptime(end_date, in_format).strftime(out_format)