Prompt user to set up Amazon S3.
323797
def _setup_s3(settings, path, prompt=True):
    
    ret = {'default_s3_buckets': {}, 's3_credentials': settings.get('s3_credentials', {})}

    if prompt:
        use = raw_input("\nWould you like to set up Amazon S3? [Y/n] ")
        if use.lower() != "y" and use != "":
            puts("\n- Not configuring Amazon S3.")
            return ret

    existing_access_key = settings.get('default_s3_access_key_id', None) or \
                          os.environ.get('AWS_ACCESS_KEY_ID', None)
    existing_secret_key = settings.get('default_s3_secret_access_key', None) or \
                          os.environ.get('AWS_SECRET_ACCESS_KEY', None)

    access_key_prompt = "\nPlease enter your default Amazon Access Key ID:"
    if existing_access_key:
        access_key_prompt += ' [%s] ' % existing_access_key
    else:
        access_key_prompt += ' (leave blank to skip) '
    default_aws_access_key_id = raw_input(access_key_prompt)

    if default_aws_access_key_id == '' and existing_access_key:
        default_aws_access_key_id = existing_access_key


    if default_aws_access_key_id:
        secret_key_prompt = "\nPlease enter your default Amazon Secret Access Key:"
        if existing_secret_key:
            secret_key_prompt += ' [%s] ' % existing_secret_key
        else:
            secret_key_prompt += ' (leave blank to skip) '
        default_aws_secret_access_key = raw_input(secret_key_prompt)

        if default_aws_secret_access_key == '' and existing_secret_key:
            default_aws_secret_access_key = existing_secret_key

        ret.update({
            'default_s3_access_key_id': default_aws_access_key_id,
            'default_s3_secret_access_key': default_aws_secret_access_key,
        })

    # If we're all set with AWS creds, we can setup our default
    # staging and production buckets
    if default_aws_access_key_id and default_aws_secret_access_key:
        existing_staging_bucket = None
        existing_production_bucket = None
        if settings.get('default_s3_buckets'):
            existing_staging_bucket = settings['default_s3_buckets'].get('staging', None)
            existing_production_bucket = settings['default_s3_buckets'].get('production', None)

        staging_prompt = "\nWhat is your default staging bucket?"
        if existing_staging_bucket:
            staging_prompt += ' [%s] ' % existing_staging_bucket
        else:
            staging_prompt += ' (e.g. apps.beta.myorg.com, leave blank to skip) '
        staging = raw_input(staging_prompt)

        if staging == '' and existing_staging_bucket:
            staging = existing_staging_bucket
        if staging != "":
            ret['default_s3_buckets'].update({
                'staging': staging,
            })

        production_prompt = "\nWhat is your default production bucket?"
        if existing_production_bucket:
            production_prompt += ' [%s] ' % existing_production_bucket
        else:
            production_prompt += ' (e.g. apps.myorg.com, leave blank to skip) '
        production = raw_input(production_prompt)

        if production == '' and existing_production_bucket:
            production = existing_production_bucket
        if production != "":
            ret['default_s3_buckets'].update({
                'production': production,
            })


    more_prompt = "\nWould you like to add additional buckets and credentials? [y/N] "
    while raw_input(more_prompt).lower() == 'y':
        ## Ask for a uri
        additional_s3_bucket = raw_input(
            "\nPlease specify an additional bucket (e.g. "
            "additional.bucket.myorg.com/, leave blank to skip adding bucket) ")
        if additional_s3_bucket == "":
            continue

        ## Ask for an access key, if it differs from the default
        additional_access_key_prompt = "\nPlease specify an AWS Access Key ID for this bucket:"

        if default_aws_access_key_id:
            additional_access_key_prompt += ' [%s] ' % default_aws_access_key_id
        else:
            additional_access_key_prompt += ' (leave blank to skip adding bucket) '

        additional_aws_access_key_id = raw_input(additional_access_key_prompt)

        if additional_aws_access_key_id == "" and default_aws_access_key_id:
            additional_aws_access_key_id = default_aws_access_key_id
        elif additional_aws_access_key_id == "":
            continue

        # Ask for a secret key, if it differs from default
        additional_secret_key_prompt = "\nPlease specify an AWS Secret Access Key for this bucket:"

        if default_aws_secret_access_key:
            additional_secret_key_prompt += ' [%s] ' % default_aws_secret_access_key
        else:
            additional_secret_key_prompt += ' (leave blank to skip adding bucket) '

        additional_aws_secret_access_key = raw_input(
            additional_secret_key_prompt)

        if additional_aws_secret_access_key == "" and default_aws_secret_access_key:
            additional_aws_secret_access_key = default_aws_secret_access_key
        elif additional_aws_secret_access_key == "":
            continue

        ret['s3_credentials'][additional_s3_bucket] = {
            'access_key_id': additional_aws_access_key_id,
            'secret_access_key': additional_aws_secret_access_key,
        }

    puts("\n- Done configuring Amazon S3.")
    return ret
1009004
def create_cloud_user(cfg, args):
    """"""
    url = cfg['api_server'] + "admin/add-user"
    params = {'user_email': args.user_email, 'user_name': args.user_name,
              'user_role': args.user_role, 'email': cfg['email'],
              'api_key': cfg['api_key']}
    headers = {'Content-Type': 'application/json'}
    response = requests.post(url, data=json.dumps(params),
                             headers=headers)
    if response.status_code not in range(200, 299):
        raise Exception("Errors contacting the cloud node: %s" % (response.content))
    loaded = json.loads(response.content)
    return loaded
1311581
def setup(self):
        ""
        try:
            self.TERM = self.request.term
        except:
            pass
        self.setterm(self.TERM)
        self.sock = self.request._sock
        for k in self.DOACK.keys():
            self.sendcommand(self.DOACK[k], k)
        for k in self.WILLACK.keys():
            self.sendcommand(self.WILLACK[k], k)
11330
def start(self):
        
        if self.instance is None:
            reservation = self.ec2_backend.add_instances(
                image_id=self.ami_id,
                count=1,
                user_data="",
                security_group_names=[],
                security_group_ids=self.security_group_ids,
                instance_type=self.instance_type,
                key_name=self.ssh_keyname,
                ebs_optimized=self.ebs_optimized,
                subnet_id=self.subnet_id,
                associate_public_ip=self.associate_public_ip,
            )
            self.instance = reservation.instances[0]
            self.reported_os = {
                'Family': 'rhel (fixed)',
                'Name': 'amazon (fixed)',
                'Version': '2016.03 (fixed)'
            }
            self.platform = self.instance.platform
            self.security_group_ids = self.instance.security_groups
            self.architecture = self.instance.architecture
            self.virtualization_type = self.instance.virtualization_type
            self.subnet_id = self.instance.subnet_id
            self.root_device_type = self.instance.root_device_type

        self.ec2_backend.start_instances([self.instance.id])
1270609
def run(self, *args, **kwargs):
        
        accounts = list(AWSAccount.get_all(include_disabled=False).values())

        # S3 Bucket config
        s3_acl = get_template('cloudtrail_s3_bucket_policy.json')
        s3_bucket_name = self.dbconfig.get('bucket_name', self.ns)
        s3_bucket_region = self.dbconfig.get('bucket_region', self.ns, 'us-west-2')
        s3_bucket_account = AWSAccount.get(self.dbconfig.get('bucket_account', self.ns))
        CloudTrail.create_s3_bucket(s3_bucket_name, s3_bucket_region, s3_bucket_account, s3_acl)

        self.validate_sqs_policy(accounts)

        for account in accounts:
            ct = CloudTrail(account, s3_bucket_name, s3_bucket_region, self.log)
            ct.run()
1190301
def _put_bucket_lifecycle(self):
        """"""
        status = 'deleted'
        if self.s3props['lifecycle']['enabled']:
            lifecycle_config = {
                'Rules': self.s3props['lifecycle']['lifecycle_rules']
            }
            LOG.debug('Lifecycle Config: %s', lifecycle_config)
            _response = self.s3client.put_bucket_lifecycle_configuration(Bucket=self.bucket,
                                                                         LifecycleConfiguration=lifecycle_config)
            status = 'applied'
        else:
            _response = self.s3client.delete_bucket_lifecycle(Bucket=self.bucket)
        LOG.debug('Response setting up S3 lifecycle: %s', _response)
        LOG.info('S3 lifecycle configuration %s', status)
1047271
def set_options(self, options):
        
        self.verbosity = int(options.get('verbosity'))

        # Will we be gzipping?
        self.gzip = getattr(settings, 'BAKERY_GZIP', False)

        # And if so what content types will we be gzipping?
        self.gzip_content_types = getattr(
            settings,
            'GZIP_CONTENT_TYPES',
            DEFAULT_GZIP_CONTENT_TYPES
        )

        # What ACL (i.e. security permissions) will be giving the files on S3?
        self.acl = getattr(settings, 'DEFAULT_ACL', self.DEFAULT_ACL)

        # Should we set cache-control headers?
        self.cache_control = getattr(settings, 'BAKERY_CACHE_CONTROL', {})

        # If the user specifies a build directory...
        if options.get('build_dir'):
            # ... validate that it is good.
            if not os.path.exists(options.get('build_dir')):
                raise CommandError(self.build_missing_msg)
            # Go ahead and use it
            self.build_dir = options.get("build_dir")
        # If the user does not specify a build dir...
        else:
            # Check if it is set in settings.py
            if not hasattr(settings, 'BUILD_DIR'):
                raise CommandError(self.build_unconfig_msg)
            # Then make sure it actually exists
            if not os.path.exists(settings.BUILD_DIR):
                raise CommandError(self.build_missing_msg)
            # Go ahead and use it
            self.build_dir = settings.BUILD_DIR

        # If the user provides a bucket name, use that.
        if options.get("aws_bucket_name"):
            self.aws_bucket_name = options.get("aws_bucket_name")
        else:
            # Otherwise try to find it the settings
            if not hasattr(settings, 'AWS_BUCKET_NAME'):
                raise CommandError(self.bucket_unconfig_msg)
            self.aws_bucket_name = settings.AWS_BUCKET_NAME

        # The bucket prefix, if it exists
        self.aws_bucket_prefix = options.get("aws_bucket_prefix")

        # If the user sets the --force option
        if options.get('force'):
            self.force_publish = True
        else:
            self.force_publish = False

        # set the --dry-run option
        if options.get('dry_run'):
            self.dry_run = True
            if self.verbosity > 0:
                logger.info("Executing with the --dry-run option set.")
        else:
            self.dry_run = False

        self.no_delete = options.get('no_delete')
        self.no_pooling = options.get('no_pooling')
82165
def get_bucket(s3_bucket=None, validate=False):
    """"""
    global S3Connection

    if S3Connection != None:
        settings = oz.settings
        s3_bucket = s3_bucket or settings["s3_bucket"]
        opts = {}
        if settings["s3_host"]:
            opts["host"] = settings["s3_host"]
        if settings["aws_access_key"] and settings["aws_secret_key"]:
            opts["aws_access_key_id"] = settings["aws_access_key"]
            opts["aws_secret_access_key"] = settings["aws_secret_key"]
        return S3Connection(**opts).get_bucket(s3_bucket, validate=validate)
    else:
        raise Exception("S3 not supported in this environment as boto is not installed")
13521
function Prompt({ message, when = true }) {
  return (
    <RouterContext.Consumer>
      {context => {
        invariant(context, "You should not use <Prompt> outside a <Router>");

        if (!when || context.staticContext) return null;

        const method = context.history.block;

        return (
          <Lifecycle
            onMount={self => {
              self.release = method(message);
            }}
            onUpdate={(self, prevProps) => {
              if (prevProps.message !== message) {
                self.release();
                self.release = method(message);
              }
            }}
            onUnmount={self => {
              self.release();
            }}
            message={message}
          />
        );
      }}
    </RouterContext.Consumer>
  );
}
677217
def cli(obj, name, email, password, status, text):
    """"""
    client = obj['client']
    if not email:
        raise click.UsageError('Need "--email" to sign-up new user.')
    if not password:
        raise click.UsageError('Need "--password" to sign-up new user.')
    try:
        r = client.signup(name=name, email=email, password=password, status=status, attributes=None, text=text)
    except Exception as e:
        click.echo('ERROR: {}'.format(e))
        sys.exit(1)
    if 'token' in r:
        click.echo('Signed Up.')
    else:
        raise AuthError
636790
function awsPublisher() {
  if (!process.env.AWS_KEY || !process.env.AWS_SECRET) {
    throw 'AWS credentials are required!';
  }
  return aws.create({
      key: process.env.AWS_KEY,
      secret: process.env.AWS_SECRET,
      bucket: pkg.name
  });
}
269091
def create(self, user: str, *,
               pwd: str, sgrp: str, comment: str=None) -> None:
        """"""
        data = {
            'action': 'add',
            'user': user,
            'pwd': pwd,
            'grp': 'users',
            'sgrp': sgrp
        }

        if comment:
            data['comment'] = comment

        self._request('post', URL, data=data)
555481
def turn_on(host, did, token=None):
    """"""
    urllib3.disable_warnings()
    if token:
        scheme = "https"
    if not token:
        scheme = "http"
        token = "1234567890"
    url = (
            scheme + '://' + host + '/gwr/gop.php?cmd=DeviceSendCommand&data=<gip><version>1</version><token>' + token + '</token><did>' + did + '</did><value>1</value></gip>&fmt=xml')
    response = requests.get(url, verify=False)
    if response.status_code == '200':
        return True
    else:
        return False
1150773
def user_s3_bucket(canonical_user_id=None):
    """"""
    s3 = _s3_resource()
    if not canonical_user_id:
        canonical_user_id = _get_canonical_aws_user_id(s3)

    s3_bucket_name = "dallinger-{}".format(
        hashlib.sha256(canonical_user_id.encode("utf8")).hexdigest()[0:8]
    )

    return _get_or_create_s3_bucket(s3, s3_bucket_name)
182925
def ready(self, source):
        """"""

        from hfos.database import configschemastore
        configschemastore[self.name] = self.configschema

        self._start_server()

        if not self.insecure:
            self._drop_privileges()

        self.fireEvent(cli_register_event('components', cli_components))
        self.fireEvent(cli_register_event('drop_privileges', cli_drop_privileges))
        self.fireEvent(cli_register_event('reload_db', cli_reload_db))
        self.fireEvent(cli_register_event('reload', cli_reload))
        self.fireEvent(cli_register_event('quit', cli_quit))
        self.fireEvent(cli_register_event('info', cli_info))
1081617
def setup(self):
        """"""
        if self.dry_run is not True:
            self.client = self._get_client()
            self._disable_access_key()
82217
def on_intent(intent_request, session):
    

    print("on_intent requestId=" + intent_request['requestId'] +
          ", sessionId=" + session['sessionId'])

    intent = intent_request['intent']
    intent_name = intent_request['intent']['name']

    # Dispatch to your skill's intent handlers
    if intent_name == "MyColorIsIntent":
        return set_color_in_session(intent, session)
    elif intent_name == "WhatsMyColorIntent":
        return get_color_from_session(intent, session)
    elif intent_name == "AMAZON.HelpIntent":
        return get_welcome_response()
    elif intent_name == "AMAZON.CancelIntent" or intent_name == "AMAZON.StopIntent":
        return handle_session_end_request()
    else:
        raise ValueError("Invalid intent")