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


Python Profile.add_pgp_key方法代码示例

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


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

示例1: update_profile

# 需要导入模块: from market.profile import Profile [as 别名]
# 或者: from market.profile.Profile import add_pgp_key [as 别名]
 def update_profile(self, request):
     try:
         p = Profile(self.db)
         if not p.get().encryption_key \
                 and "name" not in request.args \
                 and "location" not in request.args:
             request.write(json.dumps({"success": False, "reason": "name or location not included"}, indent=4))
             request.finish()
             return False
         u = objects.Profile()
         if "name" in request.args:
             u.name = request.args["name"][0]
         if "location" in request.args:
             # This needs to be formatted. Either here or from the UI.
             u.location = CountryCode.Value(request.args["location"][0].upper())
         if "handle" in request.args:
             u.handle = request.args["handle"][0]
         if "about" in request.args:
             u.about = request.args["about"][0]
         if "short_description" in request.args:
             u.short_description = request.args["short_description"][0]
         if "nsfw" in request.args:
             u.nsfw = bool(request.args["nsfw"][0])
         if "vendor" in request.args:
             u.vendor = bool(request.args["vendor"][0])
         if "moderator" in request.args:
             u.moderator = bool(request.args["moderator"][0])
         if "website" in request.args:
             u.website = request.args["website"][0]
         if "email" in request.args:
             u.email = request.args["email"][0]
         if "primary_color" in request.args:
             u.primary_color = int(request.args["primary_color"][0])
         if "secondary_color" in request.args:
             u.secondary_color = int(request.args["secondary_color"][0])
         if "background_color" in request.args:
             u.background_color = int(request.args["background_color"][0])
         if "text_color" in request.args:
             u.text_color = int(request.args["text_color"][0])
         if "avatar" in request.args:
             u.avatar_hash = unhexlify(request.args["avatar"][0])
         if "header" in request.args:
             u.header_hash = unhexlify(request.args["header"][0])
         if "pgp_key" in request.args and "signature" in request.args:
             p.add_pgp_key(request.args["pgp_key"][0], request.args["signature"][0],
                           self.keychain.guid.encode("hex"))
         enc = u.PublicKey()
         enc.public_key = self.keychain.encryption_pubkey
         enc.signature = self.keychain.signing_key.sign(enc.public_key)[:64]
         u.encryption_key.MergeFrom(enc)
         p.update(u)
         request.write(json.dumps({"success": True}))
         request.finish()
         return server.NOT_DONE_YET
     except Exception, e:
         request.write(json.dumps({"success": False, "reason": e.message}, indent=4))
         request.finish()
         return server.NOT_DONE_YET
开发者ID:gubatron,项目名称:OpenBazaar-Server,代码行数:60,代码来源:restapi.py

示例2: update_profile

# 需要导入模块: from market.profile import Profile [as 别名]
# 或者: from market.profile.Profile import add_pgp_key [as 别名]
 def update_profile(self, request):
     try:
         p = Profile(self.db)
         if not p.get().encryption_key \
                 and "name" not in request.args \
                 and "location" not in request.args:
             return "False"
         u = objects.Profile()
         if "name" in request.args:
             u.name = request.args["name"][0]
         if "location" in request.args:
             # This needs to be formatted. Either here or from the UI.
             u.location = CountryCode.Value(request.args["location"][0].upper())
         if "handle" in request.args:
             u.handle = request.args["handle"][0]
         if "about" in request.args:
             u.about = request.args["about"][0]
         if "short_description" in request.args:
             u.short_description = request.args["short_description"][0]
         if "nsfw" in request.args:
             u.nsfw = True
         if "vendor" in request.args:
             u.vendor = True
         if "moderator" in request.args:
             u.moderator = True
         if "website" in request.args:
             u.website = request.args["website"][0]
         if "email" in request.args:
             u.email = request.args["email"][0]
         if "avatar" in request.args:
             with open(DATA_FOLDER + "store/avatar", 'wb') as outfile:
                 outfile.write(request.args["avatar"][0])
             avatar_hash = digest(request.args["avatar"][0])
             self.db.HashMap().insert(avatar_hash, DATA_FOLDER + "store/avatar")
             u.avatar_hash = avatar_hash
         if "header" in request.args:
             with open(DATA_FOLDER + "store/header", 'wb') as outfile:
                 outfile.write(request.args["header"][0])
             header_hash = digest(request.args["header"][0])
             self.db.HashMap().insert(header_hash, DATA_FOLDER + "store/header")
             u.header_hash = header_hash
         if "pgp_key" in request.args and "signature" in request.args:
             p.add_pgp_key(request.args["pgp_key"][0], request.args["signature"][0],
                           self.keychain.guid.encode("hex"))
         enc = u.PublicKey()
         enc.public_key = self.keychain.encryption_pubkey
         enc.signature = self.keychain.signing_key.sign(enc.public_key)[:64]
         u.encryption_key.MergeFrom(enc)
         p.update(u)
         request.write(json.dumps({"success": True}))
         request.finish()
         return server.NOT_DONE_YET
     except Exception, e:
         request.write(json.dumps({"success": False, "reason": e.message}, indent=4))
         request.finish()
         return server.NOT_DONE_YET
开发者ID:Joaz,项目名称:OpenBazaar-Server,代码行数:58,代码来源:restapi.py

示例3: addpgpkey

# 需要导入模块: from market.profile import Profile [as 别名]
# 或者: from market.profile.Profile import add_pgp_key [as 别名]
 def addpgpkey():
     parser = argparse.ArgumentParser(
         description="Add a pgp key to the profile.",
         usage='''usage:
 networkcli.py addpgpkey -k KEY, -s SIGNATURE''')
     parser.add_argument('-k', '--key', help="path to the key file")
     parser.add_argument('-s', '--signature', help="path to the signature file")
     args = parser.parse_args(sys.argv[2:])
     with open(args.key, "r") as filename:
         key = filename.read()
     with open(args.signature, "r") as filename:
         sig = filename.read()
     p = Profile()
     print p.add_pgp_key(key, sig, KeyChain().guid.encode("hex"))
开发者ID:the9ull,项目名称:OpenBazaar-Server,代码行数:16,代码来源:networkcli.py

示例4: update_profile

# 需要导入模块: from market.profile import Profile [as 别名]
# 或者: from market.profile.Profile import add_pgp_key [as 别名]
 def update_profile(self, request):
     p = Profile()
     if not p.get().encryption_key \
             and "name" not in request.args \
             and "location" not in request.args:
         return "False"
     u = objects.Profile()
     if "name" in request.args:
         u.name = request.args["name"][0]
     if "location" in request.args:
         # This needs to be formatted. Either here or from the UI.
         u.location = CountryCode.Value(request.args["location"][0].upper())
     if "handle" in request.args:
         u.handle = request.args["handle"][0]
     if "about" in request.args:
         u.about = request.args["about"][0]
     if "short_description" in request.args:
         u.short_description = request.args["short_description"][0]
     if "nsfw" in request.args:
         u.nsfw = True
     if "vendor" in request.args:
         u.vendor = True
     if "moderator" in request.args:
         u.moderator = True
     if "website" in request.args:
         u.website = request.args["website"][0]
     if "email" in request.args:
         u.email = request.args["email"][0]
     if "avatar" in request.args:
         with open(DATA_FOLDER + "store/avatar", 'wb') as outfile:
             outfile.write(request.args["avatar"][0])
         avatar_hash = digest(request.args["avatar"][0])
         HashMap().insert(avatar_hash, DATA_FOLDER + "store/avatar")
         u.avatar_hash = avatar_hash
     if "header" in request.args:
         with open(DATA_FOLDER + "store/header", 'wb') as outfile:
             outfile.write(request.args["header"][0])
         header_hash = digest(request.args["header"][0])
         HashMap().insert(header_hash, DATA_FOLDER + "store/header")
         u.header_hash = header_hash
     if "pgp_key" in request.args and "signature" in request.args:
         p.add_pgp_key(request.args["pgp_key"][0], request.args["signature"][0],
                       KeyChain().guid.encode("hex"))
     enc = u.PublicKey()
     enc.public_key = KeyChain().encryption_pubkey
     enc.signature = KeyChain().signing_key.sign(enc.public_key)[:64]
     u.encryption_key.MergeFrom(enc)
     p.update(u)
开发者ID:bglassy,项目名称:OpenBazaar-Server,代码行数:50,代码来源:restapi.py

示例5: test_MarketProfile_add_pgp_key_wrong_guid

# 需要导入模块: from market.profile import Profile [as 别名]
# 或者: from market.profile.Profile import add_pgp_key [as 别名]
 def test_MarketProfile_add_pgp_key_wrong_guid(self):
     p = Profile(self.db)
     wrong_guid = '5c2dedbd-5977-4326-b965-c9a2435c8e91'
     self.assertFalse(p.add_pgp_key(self.PUBLIC_KEY, self.SIGNATURE, wrong_guid))
开发者ID:1234max,项目名称:OpenBazaar-Server,代码行数:6,代码来源:test_profile.py

示例6: test_MarketProfile_add_pgp_key_success

# 需要导入模块: from market.profile import Profile [as 别名]
# 或者: from market.profile.Profile import add_pgp_key [as 别名]
 def test_MarketProfile_add_pgp_key_success(self):
     p = Profile(self.db)
     self.assertTrue(p.add_pgp_key(self.PUBLIC_KEY, self.SIGNATURE, self.VALID_GUID))
     u = p.get()
     self.assertEqual(self.SIGNATURE, u.pgp_key.signature)
     self.assertEqual(self.PUBLIC_KEY, u.pgp_key.public_key)
开发者ID:1234max,项目名称:OpenBazaar-Server,代码行数:8,代码来源:test_profile.py


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