本文整理汇总了Python中env.Env.get_arg方法的典型用法代码示例。如果您正苦于以下问题:Python Env.get_arg方法的具体用法?Python Env.get_arg怎么用?Python Env.get_arg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类env.Env
的用法示例。
在下文中一共展示了Env.get_arg方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Env
# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import get_arg [as 别名]
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:]:
key, val = arg.split('=')
pushdef.set_output_param(key, val)
# Subscribe the definition to the hash
示例2: Env
# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import get_arg [as 别名]
sys.stderr.write(' push-stream-from-csdl.py csdl.txt 20120701000000 20120701235959 twitter 1 http \\\n')
sys.stderr.write(' PushName delivery_frequency=10 url=http://www.example.com/push_endpoint \\\n')
sys.stderr.write(' auth.type=none\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() < 7:
usage()
# Get the args
csdl_filename = 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)
output_type = env.get_arg(5)
name = env.get_arg(6)
# 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)
# Read the CSDL file
csdl = open(csdl_filename, 'r').read()
示例3: Env
# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import get_arg [as 别名]
sys.stderr.write(' acl=private file_prefix=Datasift \\\n')
sys.stderr.write(' auth.access_key=<accesskey> auth.secret_key=<secretkey> \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() < 3:
usage("Not enough arguments")
fieldNames = ["Name", "Hash", "Start", "End", "Sources"]
fn = env.get_arg(0)
f = open(fn, 'rU')
historics_jobs = csv.DictReader(f, fieldNames)
# Skip the header row
next(historics_jobs)
for parameters in historics_jobs:
print parameters
# Get the args
stream_hash = parameters['Hash'].strip()
start = parameters['Start'].strip()
end = parameters['End'].strip()
sources = parameters['Sources'].strip()
示例4: Env
# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import get_arg [as 别名]
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() < 3:
usage()
# Get the args
csdl_filename = env.get_arg(0)
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
示例5: Env
# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import get_arg [as 别名]
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.'
else:
for log_entry in log['log_entries']:
print datetime(log_entry['request_time']).strprint('%Y-%m-%d %H:%M:%S'),
if env.get_arg_count() == 1:
print '[%s]' % (log_entry['subscription_id']),
success = ''
if log_entry['success']:
success = 'Success '
示例6: Env
# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import get_arg [as 别名]
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)
try:
# Create the Historics query
historic = env.get_user().create_historic(stream_hash, start, end, sources.split(','), sample, name)