Пример #1
0
def list_s3_files(source_url, patterns):
    """List remote s3 files that match one of the patterns."""
    s3_conn = connect_s3()
    for bucket, root, path in generate_s3_sources(s3_conn, source_url,
                                                  patterns):
        source = join_as_s3_url(bucket, root, path)
        src_key = get_s3_key(s3_conn, source)
        print "%10d %s" % (src_key.size if src_key is not None else -1, path)
Пример #2
0
    def connect(self, bucket_name=None):
        # If we have a valid bucket, and the name matches the one
        # we want to use, let's just return
        if self.bucket and bucket_name == self.bucket.name:
            return

        # Looks like we need to connect to the bucket
        conn = boto3.connect_s3(self.access_key, self.secret_key)
        self.bucket = conn.create_bucket(bucket_name)
Пример #3
0
    def connect(self, bucket_name=None):
        # If we have a valid bucket, and the name matches the one
        # we want to use, let's just return
        if self.bucket and bucket_name == self.bucket.name:
            return

        # Looks like we need to connect to the bucket
        conn = boto3.connect_s3(self.access_key, self.secret_key)
        self.bucket = conn.create_bucket(bucket_name)
Пример #4
0
def get_s3_files(source_url, dest_root, patterns):
    """Copy remote s3 files that match one of the patterns to a local destination."""
    s3_conn = connect_s3()
    for bucket, root, path in generate_s3_sources(s3_conn, source_url,
                                                  patterns):
        source = join_as_s3_url(bucket, root, path)
        dest_name = path.replace('/', '_')
        destination = os.path.join(dest_root, dest_name)
        src_key = get_s3_key(s3_conn, source)
        if src_key is not None:
            src_key.get_contents_to_filename(destination)
        else:
            print "No key for source " + source
Пример #5
0
    policies = iam.list_role_policies(role.role_name)
    policies = policies.list_role_policies_response.list_role_policies_result.policy_names
    for policy_name in policies:
        policy = iam.get_role_policy(role.role_name, policy_name)
        policy = policy.get_role_policy_response.get_role_policy_result.policy_document
        policy = urllib.unquote(policy)
        role_policy.append(
            config_line_policy("iam:rolepolicy", role.role_name, policy_name,
                               policy))
    debug(policies)
output_lines(role_policy)

#  S3 bucket policies
verbose("Getting S3 bucket policies:")
s3 = boto3.connect_s3(access_key_id,
                      secret_access_key,
                      security_token=security_token)
bucket_info = []
buckets = s3.get_all_buckets()
for bucket in buckets:
    try:
        policy = bucket.get_policy()
        bucket_info.append(
            config_line_policy("s3:bucketpolicy", bucket.name, "", policy))
    except boto3.exception.S3ResponseError as e:
        bucket_info.append(
            config_line("s3:bucketpolicy", bucket.name, "", e.code))
output_lines(bucket_info)

# SQS queue policies
verbose("Getting SQS queue policies:")
Пример #6
0
from pyAudioAnalysis import audioBasicIO
from pyAudioAnalysis import ShortTermFeatures
import boto3 as boto
import os
import matplotlib.pyplot as plt
access_key = os.environ['']
access_secret_key = os.environ['']

conn = boto.connect_s3(access_key, access_secret_key)
bucket = conn.get_bucket('aravindsamala')
file_key = bucket.get_key('312_AUDIO.wav')
file_key.get_contents_to_filename('312_AUDIO.wav')
[Fs, x] = audioBasicIO.read_audio_file('312_AUDIO.wav')
F, f_names, time = ShortTermFeatures.spectrogram(x, Fs, 0.050 * Fs, 0.025 * Fs)
print(F.shape)




"""
fstep = int(num_fft / 5.0)
frequency_ticks = range(0, int(num_fft) + fstep, fstep)
frequency_tick_labels = \
    [str(sampling_rate / 2 -
         int((f * sampling_rate) / (2 * num_fft)))
     for f in frequency_ticks]
ax.set_yticks(frequency_ticks)
ax.set_yticklabels(frequency_tick_labels)
t_step = int(count_fr / 3)

Пример #7
0

    #Policies around what the assumed role can do
    policies = iam.list_role_policies(role.role_name)
    policies = policies.list_role_policies_response.list_role_policies_result.policy_names
    for policy_name in policies:
        policy = iam.get_role_policy(role.role_name, policy_name)
        policy = policy.get_role_policy_response.get_role_policy_result.policy_document
        policy = urllib.unquote(policy)
        role_policy.append(config_line_policy("iam:rolepolicy", role.role_name, policy_name, policy))
    debug(policies)
output_lines(role_policy)

#  S3 bucket policies
verbose("Getting S3 bucket policies:")
s3 = boto3.connect_s3(access_key_id, secret_access_key, security_token=security_token)
bucket_info = []
buckets = s3.get_all_buckets()
for bucket in buckets:
    try:
        policy = bucket.get_policy()
        bucket_info.append(config_line_policy("s3:bucketpolicy", bucket.name, "", policy))
    except boto3.exception.S3ResponseError as e:
        bucket_info.append(config_line("s3:bucketpolicy", bucket.name, "", e.code))
output_lines(bucket_info)


# SQS queue policies
verbose("Getting SQS queue policies:")
sqs = boto3.connect_sqs(access_key_id, secret_access_key, security_token=security_token)
queue_info = []
Пример #8
0
 def open_connection(self, credentials):
     in_access_key, in_secret_key, in_bucket = credentials
     self.boto_conn = boto3.connect_s3(in_access_key, in_secret_key)
     self.open_bucket = self.boto_conn.get_bucket(in_bucket,
                                                  validate=False)
     self.config_vars["S3_BUCKET_NAME"] = in_bucket
 def connect(self):
     #read akey and skey
     conn = boto3.connect_s3('')
     return conn