コード例 #1
0
ファイル: managers.py プロジェクト: mturilin/bount
    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()
コード例 #2
0
ファイル: stacks.py プロジェクト: unicodefreak/bount
    def download_media(self):
        media_dump_basename = "%s_media_%s.tar.gz" % (self.django.project_name, timestamp_str())
        media_dump_remote_path = "%s/%s" % (remote_home(), media_dump_basename)

        media_dump_local_path = self.local_media_dump_dir.joinpath(media_dump_basename)

        with cd(self.django.media_root): cuisine.run("tar -cvzf %s ." % media_dump_remote_path)
        cuisine.file_attribs(media_dump_remote_path, '777')

        get(media_dump_remote_path, media_dump_local_path)

        with cuisine_sudo(): file_delete(media_dump_remote_path)
コード例 #3
0
ファイル: managers.py プロジェクト: mturilin/bount
    def reset_project_dir(self):
        home_dir = remote_home()
        site_path_basename = path(self.remote_site_path).name
        with cuisine_sudo():
            cuisine.dir_ensure(self.remote_site_path, recursive=True, mode="777")
            cuisine.dir_ensure("%s/tmp" % home_dir, mode="777")
            dir_delete("%(home_dir)s/tmp/%(site_path_basename)s" % locals())
            cuisine.run("mv %(site_dir)s %(home_dir)s/tmp" % {"site_dir": self.remote_site_path, "home_dir": home_dir})

            clear_dir(self.remote_project_path)

            # restore site dir
            cuisine.run(
                "mv %(home_dir)s/tmp/%(site_dir_basename)s %(proj_path)s"
                % {"site_dir_basename": site_path_basename, "proj_path": self.remote_project_path, "home_dir": home_dir}
            )
コード例 #4
0
ファイル: managers.py プロジェクト: RuuPiE/bount
    def clear_remote_project_path_save_site(self):
        home_dir = remote_home()
        site_path_basename = path(self.remote_site_path).name
        with cuisine_sudo():
            cuisine.dir_ensure(self.remote_site_path, recursive=True, mode='777')
            cuisine.dir_ensure("%s/tmp" % home_dir, mode='777')
            dir_delete("%(home_dir)s/tmp/%(site_path_basename)s" % locals())
            cuisine.run('mv %(site_dir)s %(home_dir)s/tmp' % {'site_dir': self.remote_site_path, 'home_dir': home_dir})

            clear_dir(self.remote_project_path)


            #restore site dir
            cuisine.run('mv %(home_dir)s/tmp/%(site_dir_basename)s %(proj_path)s' % {
                'site_dir_basename': site_path_basename,
                'proj_path': self.remote_project_path,
                'home_dir': home_dir
            })
コード例 #5
0
ファイル: managers.py プロジェクト: mturilin/bount
    def setup_dependencies(self):
        # file_dependencies = []
        # if self.req_file:
        #    with open(self.req_file, 'r') as file:
        #        dep_str = file.read()
        #        file_dependencies = [str.split('==') for str in dep_str.split('\n') if str != '']
        #

        temp_path = path(remote_home()).joinpath("tmp")
        with cuisine_sudo():
            dir_ensure(temp_path)

        operations.put(self.req_file, str(temp_path), use_sudo=True)

        remote_req_file = temp_path.joinpath(path(self.req_file).basename())

        if self.use_virtualenv:
            with virtualenv(self.virtualenv_path, self.virtualenv_name):
                pip_install(self.dependencies)
                pip_install_file_requirements(remote_req_file)
        else:
            with cuisine_sudo():
                pip_install(self.dependencies)
                pip_install_file_requirements(remote_req_file)