示例#1
0
    def take_action(self, parsed_args):
        bucketname, keyname = parsed_args.object
        bucket = self.app.conn.lookup(bucketname)
        if bucket:
            self.log.debug('looking up key %s in bucket %s'
                    % (keyname, bucketname))
            k = bucket.get_key(keyname)
            if k:
                rows = ['Name', 'Size', 'Last Modified', 'Content Type',
                        'etag', 'ACLs']
                data = [k.name, k.size, k.last_modified, k.content_type,
                        k.etag, '']
                acp = k.get_acl()
                for (entity, permissions) in parse_acl(acp):
                    rows.append('  %s' % entity)
                    data.append(permissions)
                if k.metadata:
                    rows.append('Metadata')
                    data.append('')
                    for x, v in k.metadata.iteritems():
                        rows.append('  %s' % x)
                        data.append(v)

                return (rows, data)
            else:
                self.log.warn('could not load key %s in bucket %s'
                        % (keyname, bucketname))
        else:
            self.log.warn('could not load bucket %s' % bucketname)
示例#2
0
 def _show_bucket(self, bucketname):
     bucket = self.app.conn.lookup(bucketname)
     rows = ['Name', 'ACLs']
     data = [bucketname, '']
     if bucket:
         try:
             self.log.debug('looking up acl for %s' % bucketname)
             acp = bucket.get_acl()
             for (entity, permissions) in parse_acl(acp):
                 rows.append('  %s' % entity)
                 data.append(permissions)
             return (rows, data)
         except S3ResponseError:
             self.log.warn('could not get acl for %s' % bucketname)
     else:
         self.log.warn('could not load bucket %s' % bucketname)