# Path: lamvery/log.py
# def get_logger(name):
#     global logger
#     if logger is None:
#         logger = logging.getLogger(name)
#         logger.setLevel(logging.INFO)
#         handler = ColoredStreamHandler(stream=sys.stderr)
#         handler.setLevel(logging.INFO)
#         handler.setFormatter(
#             logging.Formatter('%(name)s: %(message)s'))
#         logger.removeHandler(handler)
#         logger.addHandler(handler)
#     return logger
# 
# Path: lamvery/utils.py
# def run_commands(commands, working_dir=os.getcwd()):
#     cwd = os.getcwd()
#     os.chdir(working_dir)
# 
#     for c in commands:
#         try:
#             subprocess.check_output(
#                 c, stderr=subprocess.STDOUT, shell=True)
#         except subprocess.CalledProcessError as e:
#             os.chdir(cwd)
#             raise Exception(e.output)
# 
#     os.chdir(cwd)


import os
import sys
import tempfile
import shutil
import re
import warnings
import json
import lamvery.secret
import lamvery.config
from zipfile import PyZipFile, ZIP_DEFLATED
from lamvery.log import get_logger
from lamvery.utils import run_commands
                    self._archive_file(zipfile, p)

            if not self._single_file:
                secret_path = os.path.join(self._tmpdir, lamvery.secret.SECRET_FILE_NAME)
                env_path = os.path.join(self._tmpdir, lamvery.env.ENV_FILE_NAME)
                self._generate_json(secret_path, self._secret)
                self._generate_json(env_path, self._env)
                self._archive_file(zipfile, secret_path)
                self._archive_file(zipfile, env_path)

                if self._runtime == lamvery.config.RUNTIME_NODE_JS:
                    self._archive_dist(zipfile, 'lamvery.js')

        self._run_hooks(self._hooks.get('post', []))

        return open(self._zippath, 'rb')

    def _prepare_clean_build(self):
        for p in os.listdir(os.getcwd()):
            path = os.path.join(os.getcwd(), p)
            if not path.startswith(os.environ.get('VIRTUAL_ENV')):
                if os.path.isdir(path):
                    shutil.copytree(path, os.path.join(self._clean_build_dir, p))
                else:
                    shutil.copyfile(path, os.path.join(self._clean_build_dir, p))

    def _run_hooks(self, hooks):
        if self._clean_build:
            return run_commands(hooks, self._clean_build_dir)
        else:

# Path: lamvery/log.py
# def get_logger(name):
#     global logger
#     if logger is None:
#         logger = logging.getLogger(name)
#         logger.setLevel(logging.INFO)
#         handler = ColoredStreamHandler(stream=sys.stderr)
#         handler.setLevel(logging.INFO)
#         handler.setFormatter(
#             logging.Formatter('%(name)s: %(message)s'))
#         logger.removeHandler(handler)
#         logger.addHandler(handler)
#     return logger
# 
# Path: lamvery/utils.py
# def run_commands(commands, working_dir=os.getcwd()):
#     cwd = os.getcwd()
#     os.chdir(working_dir)
# 
#     for c in commands:
#         try:
#             subprocess.check_output(
#                 c, stderr=subprocess.STDOUT, shell=True)
#         except subprocess.CalledProcessError as e:
#             os.chdir(cwd)
#             raise Exception(e.output)
# 
#     os.chdir(cwd)


# Path: lamvery/build.py
import os
import sys
import tempfile
import shutil
import re
import warnings
import json
import lamvery.secret
import lamvery.config
from zipfile import PyZipFile, ZIP_DEFLATED
from lamvery.log import get_logger
from lamvery.utils import run_commands

                    self._archive_file(zipfile, p)

            if not self._single_file:
                secret_path = os.path.join(self._tmpdir, lamvery.secret.SECRET_FILE_NAME)
                env_path = os.path.join(self._tmpdir, lamvery.env.ENV_FILE_NAME)
                self._generate_json(secret_path, self._secret)
                self._generate_json(env_path, self._env)
                self._archive_file(zipfile, secret_path)
                self._archive_file(zipfile, env_path)

                if self._runtime == lamvery.config.RUNTIME_NODE_JS:
                    self._archive_dist(zipfile, 'lamvery.js')

        self._run_hooks(self._hooks.get('post', []))

        return open(self._zippath, 'rb')

    def _prepare_clean_build(self):
        for p in os.listdir(os.getcwd()):
            path = os.path.join(os.getcwd(), p)
            if not path.startswith(os.environ.get('VIRTUAL_ENV')):
                if os.path.isdir(path):
                    shutil.copytree(path, os.path.join(self._clean_build_dir, p))
                else:
                    shutil.copyfile(path, os.path.join(self._clean_build_dir, p))

    def _run_hooks(self, hooks):
        if self._clean_build:
            return run_commands(hooks, self._clean_build_dir)
        else:

            return run_commands(hooks)