本文整理匯總了Python中radula.RadulaProxy.upload方法的典型用法代碼示例。如果您正苦於以下問題:Python RadulaProxy.upload方法的具體用法?Python RadulaProxy.upload怎麽用?Python RadulaProxy.upload使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類radula.RadulaProxy
的用法示例。
在下文中一共展示了RadulaProxy.upload方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: rm_method
# 需要導入模塊: from radula import RadulaProxy [as 別名]
# 或者: from radula.RadulaProxy import upload [as 別名]
def rm_method(method):
radu = RadulaProxy(connection=boto.connect_s3())
radu.make_bucket(subject=TEST_BUCKET)
# give something to rm
args = vars(_parse_args(['up']))
expected = []
for i in xrange(3):
remote_file = REMOTE_FILE + str(i)
expected.append(remote_file)
args.update({
"subject": TEST_FILE,
"target": remote_file
})
radu.upload(**args)
while len(expected):
remove_file = expected.pop()
sys.stdout.truncate(0)
getattr(radu, method)(subject=remove_file)
radu.keys(subject=TEST_BUCKET)
keys = [k.strip() for k in sys.stdout.getvalue().strip().split("\n")]
absent_key = os.path.basename(remove_file)
assert_not_in(absent_key, keys, msg="Expecting absence of key mention '{0}'".format(absent_key))
for expected_key in expected:
expected_key = os.path.basename(expected_key)
assert_in(expected_key, keys, msg="Expecting output containing '{0}'".format(expected_key))
示例2: dl_method
# 需要導入模塊: from radula import RadulaProxy [as 別名]
# 或者: from radula.RadulaProxy import upload [as 別名]
def dl_method(method, test_set):
radu = RadulaProxy(connection=boto.connect_s3())
radu.make_bucket(subject=TEST_BUCKET)
# give something to download
args = vars(_parse_args(['up']))
args.update({
"subject": TEST_FILE,
"target": REMOTE_FILE
})
radu.upload(**args)
sys.stdout.truncate(0)
args = vars(_parse_args([method, '-f']))
args.update(test_set)
getattr(radu, method)(**args)
out = sys.stdout.getvalue().strip()
msgs = [
"Download Progress",
"100.00%",
]
for msg in msgs:
assert_in(msg, out, msg="Expecting log message containing '{0}'".format(msg))
target = test_set.get("target", TEST_FILE)
assert_true(os.path.isfile(target))
if target != TEST_FILE:
os.remove(target)
示例3: allow_user
# 需要導入模塊: from radula import RadulaProxy [as 別名]
# 或者: from radula.RadulaProxy import upload [as 別名]
def allow_user(method, test_set):
subject, flags, expected, unexpected = test_set
conn = boto.connect_s3()
proxy = RadulaProxy(connection=conn)
radu = Radula(connection=conn)
proxy.make_bucket(subject=TEST_BUCKET)
# give something to download
args = vars(_parse_args(['up']))
args.update({
"subject": TEST_FILE,
"target": subject
})
proxy.upload(**args)
sys.stdout.truncate(0)
flags = flags.split(' ')
args = [arg for arg in flags + [method, ALT_USER, subject] if arg]
args = vars(_parse_args(args))
getattr(radu, args.get("command").replace('-', '_'))(**args)
out = [line.strip() for line in sys.stdout.getvalue().split("\n")]
sys.stdout.truncate(0)
for msg in expected:
errmsg = "Expecting log message containing '{0}'".format(msg)
assert_in(msg, out, msg=errmsg)
for msg in unexpected:
errmsg = "Not expecting log message containing '{0}'".format(msg)
assert_not_in(msg, out, msg=errmsg)
示例4: compare_acl
# 需要導入模塊: from radula import RadulaProxy [as 別名]
# 或者: from radula.RadulaProxy import upload [as 別名]
def compare_acl(test_set):
acl, subject, expected, unexpected = test_set
conn = boto.connect_s3()
proxy = RadulaProxy(connection=conn)
radu = Radula(connection=conn)
bucket = conn.create_bucket(TEST_BUCKET)
# give something to download
args = vars(_parse_args(['up']))
args.update({
"subject": TEST_FILE,
"target": REMOTE_FILE
})
proxy.upload(**args)
# for sake of testing, ensure equality
key_name = os.path.basename(REMOTE_FILE)
key = bucket.get_key(key_name)
key.set_canned_acl(acl)
args = vars(_parse_args(['compare-acl', subject, acl]))
radu.compare_acl(**args)
out = [line.strip() for line in sys.stdout.getvalue().split("\n")]
sys.stdout.truncate(0)
for msg in expected:
errmsg = "Expecting log message containing '{0}'".format(msg)
assert_in(msg, out, msg=errmsg)
for msg in unexpected:
errmsg = "Not expecting log message containing '{0}'".format(msg)
assert_not_in(msg, out, msg=errmsg)
示例5: set_acl_subject
# 需要導入模塊: from radula import RadulaProxy [as 別名]
# 或者: from radula.RadulaProxy import upload [as 別名]
def set_acl_subject(test_set, acl):
subject, expected, unexpected = test_set
conn = boto.connect_s3()
proxy = RadulaProxy(connection=conn)
radu = Radula(connection=conn)
proxy.make_bucket(subject=TEST_BUCKET)
# give something to download
args = vars(_parse_args(['up']))
args.update({
"subject": TEST_FILE,
"target": subject
})
proxy.upload(**args)
sys.stdout.truncate(0)
args = vars(_parse_args(['set-acl', subject, acl]))
radu.set_acl(**args)
out = [line.strip() for line in sys.stdout.getvalue().split("\n")]
sys.stdout.truncate(0)
for msg in expected:
errmsg = "Expecting log message containing '{0}'".format(msg)
assert_in(msg, out, msg=errmsg)
for msg in unexpected:
errmsg = "Not expecting log message containing '{0}'".format(msg)
assert_not_in(msg, out, msg=errmsg)
示例6: dl_method_fail
# 需要導入模塊: from radula import RadulaProxy [as 別名]
# 或者: from radula.RadulaProxy import upload [as 別名]
def dl_method_fail(method, test_set):
radu = RadulaProxy(connection=boto.connect_s3())
radu.make_bucket(subject=TEST_BUCKET)
# give something to download
args = vars(_parse_args(['up']))
args.update({
"subject": TEST_FILE,
"target": REMOTE_FILE
})
radu.upload(**args)
sys.stdout.truncate(0)
getattr(radu, method)(**test_set)
示例7: set_acl_canned_fail
# 需要導入模塊: from radula import RadulaProxy [as 別名]
# 或者: from radula.RadulaProxy import upload [as 別名]
def set_acl_canned_fail(acl):
conn = boto.connect_s3()
proxy = RadulaProxy(connection=conn)
radu = Radula(connection=conn)
proxy.make_bucket(subject=TEST_BUCKET)
# give something to download
args = vars(_parse_args(['up']))
args.update({
"subject": TEST_FILE,
"target": REMOTE_FILE
})
proxy.upload(**args)
sys.stdout.truncate(0)
args = vars(_parse_args(['set-acl', REMOTE_FILE, acl]))
radu.set_acl(**args)
示例8: copy_method
# 需要導入模塊: from radula import RadulaProxy [as 別名]
# 或者: from radula.RadulaProxy import upload [as 別名]
def copy_method(method):
handler = TestHandler(Matcher())
logger = logging.getLogger()
logger.addHandler(handler)
radu = RadulaProxy(connection=boto.connect_s3())
radu.make_bucket(subject=TEST_BUCKET)
# give something to download
args = vars(_parse_args(['up']))
args.update({
"subject": TEST_FILE,
"target": REMOTE_FILE
})
radu.upload(**args)
sys.stdout.truncate(0)
# 'threads' needed
args = vars(_parse_args(['-y', method]))
target_file = REMOTE_FILE + '-copy'
args.update({
"subject": REMOTE_FILE,
"target": target_file
})
radu.streaming_copy(**args)
msgs = [
"Finished uploading",
"tests.s3.amazonaws.com/data.txt",
"Download URL",
"Key data matches!"
]
for msg in msgs:
fmt = "Expecting log message containing '{0}'"
assert_true(handler.matches(message=msg), msg=fmt.format(msg))
radu.keys(subject=TEST_BUCKET)
keys = [k.strip() for k in sys.stdout.getvalue().strip().split("\n")]
expected = [REMOTE_FILE, target_file]
fmt = "Expecting output containing '{0}'"
for expected_key in expected:
expected_key = os.path.basename(expected_key)
assert_in(expected_key, keys, msg=fmt.format(expected_key))
示例9: key_info_test
# 需要導入模塊: from radula import RadulaProxy [as 別名]
# 或者: from radula.RadulaProxy import upload [as 別名]
def key_info_test():
radu = RadulaProxy(connection=boto.connect_s3())
radu.make_bucket(subject=TEST_BUCKET)
# give something to info
args = vars(_parse_args(['up']))
remote_file = REMOTE_FILE
args.update({
"subject": TEST_FILE,
"target": remote_file
})
radu.upload(**args)
sys.stdout.truncate(0)
radu.info(subject=REMOTE_FILE)
out = sys.stdout.getvalue().strip()
info = json.loads(out)
for k in ('content_length', 'owner', 'size', 'bucket'):
assert_in(k, info)
assert_equal(info.get("bucket"), TEST_BUCKET)
示例10: verify_test
# 需要導入模塊: from radula import RadulaProxy [as 別名]
# 或者: from radula.RadulaProxy import upload [as 別名]
def verify_test():
# ensure original text
with open(TEST_FILE, 'w') as test_file:
test_file.write("data")
radu = RadulaProxy(connection=boto.connect_s3())
radu.make_bucket(subject=TEST_BUCKET)
# give something to download
args = vars(_parse_args(['up']))
args.update({
"subject": TEST_FILE,
"target": REMOTE_FILE
})
radu.upload(**args)
sys.stdout.truncate(0)
handler = TestHandler(Matcher())
logger = logging.getLogger()
logger.addHandler(handler)
# 'threads' needed
args = vars(_parse_args(["verify"]))
args.update({
"subject": TEST_FILE,
"target": REMOTE_FILE
})
radu.verify(**args)
assert_false(handler.matches(levelno=logging.ERROR))
assert_false(handler.matches(levelno=logging.WARNING))
assert_true(handler.matches(levelno=logging.INFO))
msgs = [
"Checksum Verified!",
'8d777f385d3dfec8815d20f7496026dc',
]
for msg in msgs:
fmt = "Expecting log message containing '{0}'"
assert_true(handler.matches(message=msg), msg=fmt.format(msg))
示例11: key_test
# 需要導入模塊: from radula import RadulaProxy [as 別名]
# 或者: from radula.RadulaProxy import upload [as 別名]
def key_test():
radu = RadulaProxy(connection=boto.connect_s3())
radu.make_bucket(subject=TEST_BUCKET)
# give something to download
args = vars(_parse_args(['up']))
expected = []
for i in xrange(3):
remote_file = REMOTE_FILE + str(i)
expected.append(remote_file)
args.update({
"subject": TEST_FILE,
"target": remote_file
})
radu.upload(**args)
sys.stdout.truncate(0)
radu.keys(subject=TEST_BUCKET)
keys = [k.strip() for k in sys.stdout.getvalue().strip().split("\n")]
for expected_key in expected:
expected_key = os.path.basename(expected_key)
assert_in(expected_key, keys, msg="Expecting output containing '{0}'".format(expected_key))
示例12: remote_md5_test
# 需要導入模塊: from radula import RadulaProxy [as 別名]
# 或者: from radula.RadulaProxy import upload [as 別名]
def remote_md5_test():
# ensure original text
with open(TEST_FILE, 'w') as test_file:
test_file.write("data")
radu = RadulaProxy(connection=boto.connect_s3())
radu.make_bucket(subject=TEST_BUCKET)
# give something to download
args = vars(_parse_args(['up']))
args.update({
"subject": TEST_FILE,
"target": REMOTE_FILE
})
radu.upload(**args)
sys.stdout.truncate(0)
# 'threads' needed
args = vars(_parse_args(["remote-md5", "-t", "2"]))
args.update({
"subject": REMOTE_FILE
})
radu.remote_md5(**args)
out = sys.stdout.getvalue().strip()
assert_equal('8d777f385d3dfec8815d20f7496026dc', out)