Beispiel #1
0
class TestConnection(unittest.TestCase):

	def setUp(self):
		self.connection = Connection("abc","def")
		self.vault = self.connection.get_vault("name")
	
	def test_vault(self):
		self.assertEqual(self.vault.name,"name")
		self.assertEqual(self.vault.region,self.connection.region)
		self.assertEqual(self.vault.connection,self.connection)

	# TODO: Request integrity is not being checked yet

	def test_request(self):
		# check if errors occur while creating a request
		self.assertNotEqual(self.connection.make_request("GET","/glacier"),"")
from glacier import Connection, Vault, Archive

# == Basic job creation ==
# Another easy example of how to get an inventory of your stored
# data in Amazon's Glacier.


# The access keys can be created and found in your AWS management console 
# under "Security Credentials".
access_key = "EXAMPLE_KEY"
secret_access_key = "EXAMPLE_SECRET_KEY"

# Establish a connection to the Glacier
my_glacier = Connection(access_key,secret_access_key,region="us-east-1")

# Get the "example" vault (has to exist)
example_vault = my_glacier.get_vault("example")

# Order the inventory
job_id = example_vault.initiate_job("inventory-retrieval")

# Wait until the job is finished (that will take at least some hours)
# You can check the progress at any time with the following snippet:
# 
# if example_vault.describe_job(job_id)["Completed"]:
#	print "The job is done :-)"
#
# However, each time you call the command you send a request which
# can potentially cost you (more) money.

inventory = example_vault.get_job_output(job_id)
from glacier import Connection, Vault, Archive

# == Basic file upload ==
# An easy example of how to store your data in Amazon's Glacier


# The access keys can be created and found in your AWS management console 
# under "Security Credentials".
access_key = "EXAMPLE_KEY"
secret_access_key = "EXAMPLE_SECRET_KEY"

# Establish a connection to the Glacier
my_glacier = Connection(access_key,secret_access_key,region="us-east-1")

# Create a new vault (not neccessary if you already have one!)
example_vault = my_glacier.create_vault("example")

# Create an archive for a file called "example.txt"
my_archive = Archive("example.txt")

upload_id = example_vault.initiate_multipart_upload(my_archive)
print "Multi-part upload started, id is ... " + upload_id

# That ID can be set here, to continue an upload, instead of initiating a new one above
#my_archive.multi_part_id = "example_multi_part_id"

# Upload each part
for part in range(0, my_archive.partcount):
   print "Sending part %d of %d..." % (part, my_archive.partcount)
   example_vault.upload_part(my_archive, part)
Beispiel #4
0
	def setUp(self):
		self.connection = Connection("abc","def")
		self.vault = self.connection.get_vault("name")