Пример #1
0
    def init(self, delete_if_exists, python_path=""):
        if self.use_virtualenv:
            virtualenv_full_path = path(self.virtualenv_path).joinpath(self.virtualenv_name)
            if cuisine.dir_exists(virtualenv_full_path) and delete_if_exists:
                dir_delete(virtualenv_full_path)

            with cuisine_sudo():
                pip_install(['virtualenv'])

            with cuisine_sudo():
                dir_ensure(self.virtualenv_path, recursive=True, mode=777)
                dir_attribs(self.virtualenv_path, mode=777, recursive=True)

            # make lib synlinks to install PIL correctly
            with cuisine_sudo():
                if not file_exists("/usr/lib/libfreetype.so"):
                    run("ln -sf /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib/")

                if not file_exists("/usr/lib/libz.so"):
                    run("ln -sf /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/")

                if not file_exists("/usr/lib/libjpeg.so"):
                    run("ln -sf /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/")

            with cd(self.virtualenv_path):
                run('VIRTUALENV_EXTRA_SEARCH_DIR="%s" && virtualenv %s' % (python_path, self.virtualenv_name))
Пример #2
0
    def upload_code(self, update_submodules=True):
        self.before_upload_code()

        # we need to ensure the directory is open for writing
        with cuisine_sudo():
            dir_attribs(self.remote_project_path, mode="777")

        temp_dir_prefix = "django_temp_"

        # zip and upload file
        temp_dir = temp_dir_prefix + self.project_name + "_" + timestamp_str()

        temp_remote_path = path(remote_home()).joinpath("tmp").joinpath(temp_dir)
        temp_local_path = path(self.project_local_path).joinpath(temp_dir)
        local_dir_ensure(temp_local_path)
        with cuisine_sudo():
            dir_ensure(temp_remote_path, recursive=True, mode="666")

        files = self.scm.local_archive(temp_local_path, include_submodules=update_submodules)

        # upload files
        for dir, file in files.iteritems():
            local_archive_path = temp_local_path.joinpath(file)
            remote_archive_path = temp_remote_path.joinpath(file)
            operations.put(str(local_archive_path), str(temp_remote_path), use_sudo=True)
            local_file_delete(local_archive_path)

        # reset project dir
        self.reset_project_dir()

        # unpack files
        for dir, file in files.iteritems():
            remote_archive_path = temp_remote_path.joinpath(file)

            # unzip file
            with cuisine_sudo():
                if self.webserver:
                    self.webserver.stop()

                extdir = path(self.remote_project_path).joinpath(dir).abspath()
                dir_ensure(extdir, recursive=True, mode="777")
                file_unzip(remote_archive_path, extdir)
                file_delete(remote_archive_path)

        cuisine.run("cd %s" % self.src_root)
        cuisine.run("pwd")

        with cuisine_sudo():
            cuisine.dir_attribs(self.remote_project_path, mode="777", recursive=True)

        for precomp in self.precompilers:
            precomp.compile()

        # clear old archives
        local_dirs_delete(self.project_local_path, "%s%s.*" % (temp_dir_prefix, self.project_name))

        ## upload ends here
        self.after_upload_code()
Пример #3
0
    def upload_code(self, update_submodules=True):
        if self.webserver:
            self.webserver.stop()

        self.before_upload_code()

        # we need to ensure the directory is open for writing
        with cuisine_sudo():
            dir_attribs(self.remote_project_path, mode='777')

        self.clear_remote_project_path_save_site()

        temp_dir_prefix = 'django_temp_'

        # zip and upload file
        temp_dir = temp_dir_prefix + self.project_name + '_' + timestamp_str()

        temp_remote_path = path(self.remote_project_path).joinpath(temp_dir)
        temp_local_path = path(self.project_local_path).joinpath(temp_dir)
        local_dir_ensure(temp_local_path)
        dir_ensure(temp_remote_path)

        files = self.scm.local_archive(temp_local_path, include_submodules=update_submodules)

        for dir, file in files.iteritems():
            local_archive_path = temp_local_path.joinpath(file)
            remote_archive_path = temp_remote_path.joinpath(file)
            put(str(local_archive_path), str(temp_remote_path), use_sudo=True)
            local_file_delete(local_archive_path)

            #unzip file
            with cuisine_sudo():
                extdir = path(self.remote_project_path).joinpath(dir).abspath()
                dir_ensure(extdir, recursive=True, mode='777')
                file_unzip(remote_archive_path, extdir)
                file_delete(remote_archive_path)

        cuisine.run("cd %s" % self.src_root)
        cuisine.run("pwd")

        with cuisine_sudo():
            cuisine.dir_attribs(self.remote_project_path, mode="777", recursive=True)

        for precomp in self.precompilers:
            precomp.compile()

        # clear old archives
        local_dirs_delete(self.project_local_path, '%s%s.*' % (temp_dir_prefix, self.project_name))

        ## upload ends here
        self.after_upload_code()

        if self.webserver:
            self.webserver.start()
Пример #4
0
    def init(self, delete_if_exists, python_path=""):
        if self.use_virtualenv:
            virtualenv_full_path = path(self.virtualenv_path).joinpath(self.virtualenv_name)
            if cuisine.dir_exists(virtualenv_full_path) and delete_if_exists:
                dir_delete(virtualenv_full_path)

            with cuisine_sudo():
                pip_install(['virtualenv'])

            with cuisine_sudo():
                dir_ensure(self.virtualenv_path, recursive=True, mode=777)
                dir_attribs(self.virtualenv_path, mode=777, recursive=True)

            with cd(self.virtualenv_path):
                run('VIRTUALENV_EXTRA_SEARCH_DIR="%s" && virtualenv %s' % (python_path, self.virtualenv_name))
Пример #5
0
    def restore_latest_media(self):
        dump_basename = self.latest_media_dump_basename()

        dump_local_path = self.local_media_dump_dir.joinpath(dump_basename)
        dump_remote_path = path(self.django.media_root).joinpath(dump_basename)

        put(str(dump_local_path), str(dump_remote_path), use_sudo=True, mode=0777)

        with cd(self.django.media_root):
            sudo("tar -xvzf %s" % dump_remote_path)

        with cuisine_sudo():
            dir_attribs(self.django.media_root, mode='777', recursive=True)

        with cuisine_sudo(): file_delete(dump_remote_path)