当前位置: 首页>>代码示例>>Python>>正文


Python Profile.save方法代码示例

本文整理汇总了Python中profile.Profile.save方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.save方法的具体用法?Python Profile.save怎么用?Python Profile.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在profile.Profile的用法示例。


在下文中一共展示了Profile.save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: profil

# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import save [as 别名]
    def profil(self, **kwargs):
        '''
            Displays user's profile and allows him to edit it.
        '''
        if signed_in():
            profile = Profile(cherrypy.session['identifier'])

            # Update:
            if cherrypy.request.method == 'POST':
                profile.update(kwargs)
                profile.save()
                return unicode(profile_page(profile, u'Profil mis a jour'))
            # Reading:
            else:
                return unicode(profile_page(profile))
        else:
            raise cherrypy.HTTPError(401, u'Vous devez vous connecter')
开发者ID:16plus,项目名称:16plus.jsb.be,代码行数:19,代码来源:application.py

示例2: signin

# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import save [as 别名]
    def signin(self, assertion):
        
        # Validating Mozilla Persona login info:
        assertion_info = {'assertion': assertion,
                          'audience': config.hostname } # window.location.host
        resp = requests.post('https://verifier.login.persona.org/verify',
                             data=assertion_info, verify=True)
        if not resp.ok:
            raise cherrypy.HTTPError(500)

        data = resp.json()

        if data['status'] == 'okay':
            cherrypy.session.update({'identifier': data['email']})
            # Creating a profile for the user if it does not exist.
            profile = Profile(cherrypy.session['identifier'])
            profile.save()
            return resp.content
开发者ID:16plus,项目名称:16plus.jsb.be,代码行数:20,代码来源:application.py

示例3: Installer

# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import save [as 别名]
class Installer(object):

    def __init__(self, package_dir):
        self._get_url = {
            'toolchain-icestorm': self.get_latest_icestorm,
            'tool-scons': self.get_latest_scons
        }
        self._package_dir = package_dir
        self._profile = Profile()
        self._profile.load()

    def install(self, tool):
        if tool in self._get_url:
            print('Install ' + tool)
            if not isdir(self._package_dir):
                makedirs(self._package_dir)
            assert isdir(self._package_dir)
            url = self._get_url[tool]()
            try:
                dlpath = None
                dlpath = self.download(tool, url, self._package_dir)
                if dlpath:
                    if isdir(join(self._package_dir, tool)):
                        shutil.rmtree(join(self._package_dir, tool))
                    assert isfile(dlpath)
                    self.unpack(dlpath, self._package_dir)
            finally:
                if dlpath:
                    remove(dlpath)
                    filename = splitext(splitext(basename(dlpath))[0])[0]
                    if tool == 'tool-scons':
                        rename(join(self._package_dir, filename),
                               join(self._package_dir, tool))
                    self._profile.packages[tool] = basename(dlpath)
                    self._profile.save()

    def uninstall(self, tool):
        if tool in self._get_url:
            if isdir(join(self._package_dir, tool)):
                print('Uninstall package {0}'.format(tool))
                shutil.rmtree(join(self._package_dir, tool))
            else:
                print('Package {0} is not installed'.format(tool))
            self._profile.remove(tool)
            self._profile.save()

    def get_latest_icestorm(self):
        releases_url = 'https://api.github.com/repos/bqlabs/toolchain-icestorm/releases/latest'
        response = urllib2.urlopen(releases_url)
        packages = json.loads(response.read())
        return packages['assets'][0]['browser_download_url']

    def get_latest_scons(self):
        return 'http://sourceforge.net/projects/scons/files/scons/2.4.1/scons-2.4.1.tar.gz'

    def download(self, tool, url, dest_dir, sha1=None):
        fd = FileDownloader(url, dest_dir)
        if self._profile.check_version(tool, basename(fd.get_filepath())):
            print('Download ' + basename(fd.get_filepath()))
            fd.start()
            fd.verify(sha1)
            return fd.get_filepath()
        else:
            print('Package {0} is already the newest version'.format(tool))
            return None

    def unpack(self, pkgpath, dest_dir):
        fu = FileUnpacker(pkgpath, dest_dir)
        return fu.start()
开发者ID:Peque,项目名称:apio,代码行数:71,代码来源:install.py


注:本文中的profile.Profile.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。