Creates an AWS Chalice project for deployment to AWS Lambda.
190278
def create_aws_lambda(ctx, bucket, region_name, aws_access_key_id, aws_secret_access_key):
    """"""
    from canari.commands.create_aws_lambda import create_aws_lambda
    create_aws_lambda(ctx.project, bucket, region_name, aws_access_key_id, aws_secret_access_key)
893367
def create_project(project_name, skel="basic"):
    
    project_dir = get_project_dir_path(project_name)
    app_tpl = pkg_resources.resource_string(__name__, '%s/app.py' % (SKELETON_DIR))
    propel_tpl = pkg_resources.resource_string(__name__, '%s/propel.yml' % (SKELETON_DIR))
    config_tpl = pkg_resources.resource_string(__name__, '%s/config.py' % (SKELETON_DIR))
    model_tpl = pkg_resources.resource_string(__name__, '%s/model.py' % (SKELETON_DIR))
    manage_tpl = pkg_resources.resource_string(__name__, '%s/juicy.py' % (SKELETON_DIR))

    app_file = "%s/app_%s.py" % (CWD, project_name)
    requirements_txt = "%s/requirements.txt" % CWD
    propel_yml = "%s/propel.yml" % CWD
    config_py = "%s/config.py" % APPLICATION_DIR
    model_py = "%s/model.py" % APPLICATION_DIR
    manage_py = "%s/juicy.py" % CWD

    dirs = [
        APPLICATION_DIR,
        APPLICATION_DATA_DIR,
        project_dir
    ]
    for d in dirs:
        if not os.path.isdir(d):
            os.makedirs(d)

    files = [
        ("%s/__init__.py" % APPLICATION_DIR, "# Juice"),
        (config_py, config_tpl),
        (model_py, model_tpl),
        (app_file, app_tpl.format(project_name=project_name)),
        (requirements_txt, "%s==%s" % (__title__, __version__)),
        (propel_yml, propel_tpl.format(project_name=project_name)),
        (manage_py, manage_tpl)
    ]
    for f in files:
        if not os.path.isfile(f[0]):
            with open(f[0], "wb") as f0:
                f0.write(f[1])

    copy_resource("%s/skel/%s/" % (SKELETON_DIR, skel), project_dir)
    copy_resource("%s/%s/" % (SKELETON_DIR, "_data"), APPLICATION_DATA_DIR)
831904
def create(project: 'projects.Project') -> COMPONENT:
    

    source_path = get_source_path()
    if not source_path:
        return COMPONENT([], [])

    output_slug = 'components/plotly/plotly.min.js'
    output_path = os.path.join(project.output_directory, output_slug)

    return COMPONENT(
        includes=[WEB_INCLUDE(
            name='plotly',
            src='/{}'.format(output_slug)
        )],
        files=[file_io.FILE_COPY_ENTRY(
            source=source_path,
            destination=output_path
        )]
    )
630909
def create_lambda_function( self,
                                bucket=None,
                                function_name=None,
                                handler=None,
                                s3_key=None,
                                description='Zappa Deployment',
                                timeout=30,
                                memory_size=512,
                                publish=True,
                                vpc_config=None,
                                dead_letter_config=None,
                                runtime='python2.7',
                                aws_environment_variables=None,
                                aws_kms_key_arn=None,
                                xray_tracing=False,
                                local_zip=None,
                                use_alb=False,
                            ):
        
        if not vpc_config:
            vpc_config = {}
        if not dead_letter_config:
            dead_letter_config = {}
        if not self.credentials_arn:
            self.get_credentials_arn()
        if not aws_environment_variables:
            aws_environment_variables = {}
        if not aws_kms_key_arn:
            aws_kms_key_arn = ''

        kwargs = dict(
            FunctionName=function_name,
            Runtime=runtime,
            Role=self.credentials_arn,
            Handler=handler,
            Description=description,
            Timeout=timeout,
            MemorySize=memory_size,
            Publish=publish,
            VpcConfig=vpc_config,
            DeadLetterConfig=dead_letter_config,
            Environment={'Variables': aws_environment_variables},
            KMSKeyArn=aws_kms_key_arn,
            TracingConfig={
                'Mode': 'Active' if self.xray_tracing else 'PassThrough'
            }
        )
        if local_zip:
            kwargs['Code'] = {
                'ZipFile': local_zip
            }
        else:
            kwargs['Code'] = {
                'S3Bucket': bucket,
                'S3Key': s3_key
            }

        response = self.lambda_client.create_function(**kwargs)

        resource_arn = response['FunctionArn']
        version = response['Version']

        # If we're using an ALB, let's create an alias mapped to the newly
        # created function. This allows clean, no downtime association when
        # using application load balancers as an event source.
        # See: https://github.com/Miserlou/Zappa/pull/1730
        #      https://github.com/Miserlou/Zappa/issues/1823
        if use_alb:
            self.lambda_client.create_alias(
                FunctionName=resource_arn,
                FunctionVersion=version,
                Name=ALB_LAMBDA_ALIAS,
            )

        if self.tags:
            self.lambda_client.tag_resource(Resource=resource_arn, Tags=self.tags)

        return resource_arn
99721
def _createFuture(func, *args, **kwargs):
    """"""
    assert callable(func), (
        "The provided func parameter is not a callable."
    )

    if scoop.IS_ORIGIN and "SCOOP_WORKER" not in sys.modules:
        sys.modules["SCOOP_WORKER"] = sys.modules["__main__"]

    # If function is a lambda or class method, share it (or its parent object)
    # beforehand
    lambdaType = type(lambda: None)
    funcIsLambda = isinstance(func, lambdaType) and func.__name__ == '<lambda>'
    # Determine if function is a method. Methods derived from external
    # languages such as C++ aren't detected by ismethod.
    funcIsMethod = ismethod(func)
    if funcIsLambda or funcIsMethod:
        from .shared import SharedElementEncapsulation
        func = SharedElementEncapsulation(func)

    return Future(control.current.id, func, *args, **kwargs)
63469
def generate(self, project):
		
		for assignment in self.s2n_mapping:
			if assignment["ipprefix"] == project:
				self._name = assignment["package"]
				return self

		#
		# github.com -> github
		# code.google.com/p/ -> googlecode
		# golang.org/x/ -> golangorg
		# gopkg.in/check.v1 -> gopkg-check
		# camlistore.org
		#

		name = project
		if name.startswith("github.com"):
			name = re.sub(r"^github\.com", "github", name)

		if name.startswith("gopkg.in"):
			name = re.sub(r"gopkg\.in", "gopkg", name)
			# any version marks?
			name = re.sub(r"\.v\d", "", name)
			name = re.sub(r"/v\d/", "/", name)

		if name.startswith("code.google.com/p"):
			name = re.sub(r"^code\.google\.com/p", "googlecode", name)

		if name.startswith("golang.org/x"):
			name = re.sub(r"^golang\.org/x", "golangorg", name)

		if name.startswith("google.golang.org"):
			name = re.sub(r"^google\.golang\.org", "googlegolangorg", name)

		if name.startswith("bitbucket.org"):
			name = re.sub(r"^bitbucket\.org", "bitbucket", name)

		if name.startswith("k8s.io"):
			name = re.sub(r"^k8s\.io", "k8s", name)

		if name.endswith(".org"):
			name = re.sub(r"\.org$", "", name)

		name = name.replace("/", "-")

		self._name = "golang-%s" % name

		return self
536829
def create(self, name):
    
    return Bucket(name, context=self._context).create(self._project_id)
448718
def create_generate(kind, project, resource, offset):
    
    generate = eval('Generate' + kind.title())
    return generate(project, resource, offset)
887012
def create(resource_path, previous_version=None, package='perch.migrations'):
    """"""
    pkg, obj = resource_path.rsplit('.', 1)
    module = importlib.import_module(pkg)
    resource = getattr(module, obj)
    version = uuid4().hex
    target_module = importlib.import_module(package)
    target_dir = os.path.dirname(target_module.__file__)
    target_file = os.path.join(target_dir, resource.resource_type + '_' + version + '.py')

    with open(target_file, 'w') as f:
        f.write(MIGRATION_TEMPLATE.format(
            resource_path=resource_path,
            resource_type=resource.resource_type,
            version=version,
            previous_version=previous_version or '',
        ))

    return target_file
416046
def create_project(self, name=None, project_id=None, path=None):
        

        if project_id is not None and project_id in self._projects:
            return self._projects[project_id]
        project = Project(name=name, project_id=project_id, path=path)
        self._check_available_disk_space(project)
        self._projects[project.id] = project
        return project
371849
def startproject(project_name):
    
    # the destination path
    dst_path = os.path.join(os.getcwd(), project_name)
    start_init_info(dst_path)

    # create dst path
    _mkdir_p(dst_path)

    # create project tree
    os.chdir(dst_path)
    # create files
    init_code('manage.py', _manage_admin_code)
    init_code('requirement.txt', _requirement_admin_code)
    init_code('config.py', _config_sql_code)

    # create app/
    app_path = os.path.join(dst_path, 'app')
    _mkdir_p(app_path)

    # create files
    os.chdir(app_path)
    init_code('models.py', _models_admin_code)
    init_code('__init__.py', _init_admin_code)

    # create templates and static
    css_path, templates_path = create_templates_static_files(app_path)
    # create css files
    os.chdir(css_path)
    init_code('sign.css', _auth_login_css_code)

    # create main blueprint
    create_blueprint(
        app_path,
        'main',
        _views_blueprint_code % ('main', 'main'),
        _forms_basic_code,
        templates_path
    )

    # create auth blueprint
    auth_templates_path = create_blueprint(
        app_path,
        'auth',
        _auth_views_code,
        _auth_forms_code,
        templates_path
    )
    # create auth templates files
    os.chdir(auth_templates_path)
    init_code('login.html', _auth_login_html_code)

    # create admin site
    admin_path = os.path.join(app_path, 'admin')
    _mkdir_p(admin_path)

    # create admin files
    os.chdir(admin_path)
    init_code('__init__.py', '')
    init_code('views.py', _admin_views_code)

    # create admin templates
    os.chdir(templates_path)
    admin_templates_path = os.path.join(templates_path, 'admin')
    _mkdir_p(admin_templates_path)

    # create admin templates files
    os.chdir(admin_templates_path)
    init_code('index.html', _admin_index_html_code)
    init_code('logout.html', _admin_logout_html_code)

    init_done_info()
961726
def deploy(self, *lambdas):
        """"""

        if not self.role:
            logger.error('Missing AWS Role')
            raise ArgumentsError('Role required')

        logger.debug('Deploying lambda {}'.format(self.lambda_name))
        zfh = self.package()

        if self.lambda_name in self.get_function_names():
            logger.info('Updating {} lambda'.format(self.lambda_name))

            response = self.client.update_function_code(
                FunctionName=self.lambda_name,
                ZipFile=zfh.getvalue(),
                Publish=True
            )
        else:
            logger.info('Adding new {} lambda'.format(self.lambda_name))

            response = self.client.create_function(
                FunctionName=self.lambda_name,
                Runtime=yaep.env(
                    'LAMBDA_RUNTIME',
                    'python2.7'
                ),
                Role=self.role,
                Handler=yaep.env(
                    'LAMBDA_HANDLER',
                    'lambda_function.lambda_handler'
                ),
                Code={
                    'ZipFile': zfh.getvalue(),
                },
                Description=yaep.env(
                    'LAMBDA_DESCRIPTION',
                    'Lambda code for {}'.format(self.lambda_name)
                ),
                Timeout=yaep.env(
                    'LAMBDA_TIMEOUT',
                    3,
                    convert_booleans=False,
                    type_class=int
                ),
                MemorySize=yaep.env(
                    'LAMBDA_MEMORY_SIZE',
                    128,
                    convert_booleans=False,
                    type_class=int
                ),
                Publish=True
            )

        status_code = response.get(
            'ResponseMetadata', {}
        ).get('HTTPStatusCode')

        if status_code in [200, 201]:
            logger.info('Successfully deployed {} version {}'.format(
                self.lambda_name,
                response.get('Version', 'Unkown')
            ))
        else:
            logger.error('Error deploying {}: {}'.format(
                self.lambda_name,
                response
            ))
796841
def _create_project(config):
    """"""
    try:
        response = config.pbclient.create_project(config.project['name'],
                                                  config.project['short_name'],
                                                  config.project['description'])
        check_api_error(response)
        return ("Project: %s created!" % config.project['short_name'])
    except exceptions.ConnectionError:
        return("Connection Error! The server %s is not responding" % config.server)
    except (ProjectNotFound, TaskNotFound):
        raise
194157
def create(self):
        
        self.service.create()

        os.environ[predix.config.get_env_key(self.use_class, 'host')] = self.get_eventhub_host()
        os.environ[predix.config.get_env_key(self.use_class, 'port')] = self.get_eventhub_grpc_port()
        os.environ[predix.config.get_env_key(self.use_class, 'wss_publish_uri')] = self.get_publish_wss_uri()
        os.environ[predix.config.get_env_key(self.use_class, 'zone_id')] = self.get_zone_id()
43370
def build(self, region=None, profile=None):
        """"""

        with self.lock:
            # memoization lookup key derived from region + profile.
            key = "{}-{}".format(profile, region)
            try:
                # assume provider is in provider dictionary.
                provider = self.providers[key]
            except KeyError:
                msg = "Missed memoized lookup ({}), creating new AWS Provider."
                logger.debug(msg.format(key))
                if not region:
                    region = self.region
                # memoize the result for later.
                self.providers[key] = Provider(
                    get_session(region=region, profile=profile),
                    region=region,
                    **self.kwargs
                )
                provider = self.providers[key]

        return provider
119311
def create(self):
        
        steps = [
            (self.create_role, (), {}),
            (self.create_vpc, (), {}),
            (self.create_cluster, (), {}),
            (self.create_node_group, (), {}),
            (self.create_spot_nodes, (), {}),
            (self.create_utilities, (), {}),
        ]
        # Execute creation.
        for step in tqdm.tqdm(steps, ncols=70):
            method, args, kwargs = step
            method(*args, **kwargs)
680688
def create_project(self, name, description):
        
        return self._create_item_response(
            self.data_service.create_project(name, description),
            Project)