'Repackage and update the function code.'

def update(self):

    self.check_venv()
    if self.prebuild_script:
        self.execute_prebuild_script()
    try:
        updated_time = 1472581018
        function_response = self.zappa.lambda_client.get_function(FunctionName=self.lambda_name)
        conf = function_response[u'Configuration']
        last_updated = parser.parse(conf[u'LastModified'])
        last_updated_unix = time.mktime(last_updated.timetuple())
    except botocore.exceptions.BotoCoreError as e:
        click.echo(((click.style(type(e).__name__, fg=u'red') + u':    ') + e.args[0]))
        sys.exit((-1))
    except Exception as e:
        click.echo((((((click.style(u'Warning!', fg=u'red') + u"    Couldn't    get    function    ") + self.lambda_name) + u'    in    ') + self.zappa.aws_region) + u'    -    have    you    deployed    yet?'))
        sys.exit((-1))
    if (last_updated_unix <= updated_time):
        click.echo((((click.style(u'Warning!', fg=u'red') + u'    You    may    have    upgraded    Zappa    since    deploying    this    application.    You    will    need    to    ') + click.style(u'redeploy', bold=True)) + u'    for    this    deployment    to    work    properly!'))
    if self.manage_roles:
        try:
            self.zappa.create_iam_roles()
        except botocore.client.ClientError:
            click.echo((((click.style(u'Failed', fg=u'red') + u'    to    ') + click.style(u'manage    IAM    roles', bold=True)) + u'!'))
            click.echo(((u'You    may    ' + click.style(u'lack    the    necessary    AWS    permissions', bold=True)) + u'    to    automatically    manage    a    Zappa    execution    role.'))
            click.echo((u'To    fix    this,    see    here:    ' + click.style(u'https://github.com/Miserlou/Zappa#using-custom-aws-iam-roles-and-policies', bold=True)))
            sys.exit((-1))
    self.create_package()
    self.callback(u'zip')
    success = self.zappa.upload_to_s3(self.zip_path, self.s3_bucket_name, disable_progress=self.disable_progress)
    if (not success):
        raise ClickException(u'Unable    to    upload    project    to    S3.    Quitting.')
    if self.stage_config.get(u'slim_handler', False):
        success = self.zappa.upload_to_s3(self.handler_path, self.s3_bucket_name, disable_progress=self.disable_progress)
        if (not success):
            raise ClickException(u'Unable    to    upload    handler    to    S3.    Quitting.')
        current_project_name = u'{0!s}_current_project.zip'.format(self.project_name)
        success = self.zappa.copy_on_s3(src_file_name=self.zip_path, dst_file_name=current_project_name, bucket_name=self.s3_bucket_name)
        if (not success):
            raise ClickException(u'Unable    to    copy    the    zip    to    be    the    current    project.    Quitting.')
        handler_file = self.handler_path
    else:
        handler_file = self.zip_path
    self.lambda_arn = self.zappa.update_lambda_function(self.s3_bucket_name, handler_file, self.lambda_name)
    self.remove_uploaded_zip()
    self.lambda_arn = self.zappa.update_lambda_configuration(lambda_arn=self.lambda_arn, function_name=self.lambda_name, handler=self.lambda_handler, description=self.lambda_description, vpc_config=self.vpc_config, timeout=self.timeout_seconds, memory_size=self.memory_size, runtime=self.runtime, aws_environment_variables=self.aws_environment_variables, aws_kms_key_arn=self.aws_kms_key_arn)
    if self.stage_config.get(u'delete_local_zip', True):
        self.remove_local_zip()
    if self.use_apigateway:
        self.zappa.create_stack_template(lambda_arn=self.lambda_arn, lambda_name=self.lambda_name, api_key_required=self.api_key_required, iam_authorization=self.iam_authorization, authorizer=self.authorizer, cors_options=self.cors, description=self.apigateway_description)
        self.zappa.update_stack(self.lambda_name, self.s3_bucket_name, wait=True, update_only=True, disable_progress=self.disable_progress)
        api_id = self.zappa.get_api_id(self.lambda_name)
        if self.binary_support:
            self.zappa.add_binary_support(api_id=api_id, cors=self.cors)
        else:
            self.zappa.remove_binary_support(api_id=api_id, cors=self.cors)
        endpoint_url = self.deploy_api_gateway(api_id)
        if self.stage_config.get(u'domain', None):
            endpoint_url = self.stage_config.get(u'domain')
    else:
        endpoint_url = None
    self.schedule()
    self.callback(u'post')
    if (endpoint_url and (u'https://' not in endpoint_url)):
        endpoint_url = (u'https://' + endpoint_url)
    deployed_string = ((u'Your    updated    Zappa    deployment    is    ' + click.style(u'live', fg=u'green', bold=True)) + u'!')
    if self.use_apigateway:
        deployed_string = ((deployed_string + u':    ') + click.style(u'{}'.format(endpoint_url), bold=True))
        api_url = None
        if (endpoint_url and (u'amazonaws.com' not in endpoint_url)):
            api_url = self.zappa.get_api_url(self.lambda_name, self.api_stage)
            if (endpoint_url != api_url):
                deployed_string = (((deployed_string + u'    (') + api_url) + u')')
        if self.stage_config.get(u'touch', True):
            if api_url:
                requests.get(api_url)
            elif endpoint_url:
                requests.get(endpoint_url)
    click.echo(deployed_string)
