本文整理汇总了Python中twython.Twython.update_profile方法的典型用法代码示例。如果您正苦于以下问题:Python Twython.update_profile方法的具体用法?Python Twython.update_profile怎么用?Python Twython.update_profile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twython.Twython
的用法示例。
在下文中一共展示了Twython.update_profile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import update_profile [as 别名]
class TwitterBot:
def __init__(self, name, con_k, con_s, acc_k, acc_s):
self.name = name
self.con_k = con_k
self.con_s = con_s
self.acc_k = acc_k
self.acc_s = acc_s
self.twitter = Twython(self.con_k, self.con_s, self.acc_k, self.acc_s)
self.last_intervals = []
self.last_tweet = ''
def get_dms(self):
if self.twitter is not None:
dms = self.twitter.get_direct_messages()
return dms
def update_image(self):
if self.twitter is not None:
with open('zf.png', 'rb') as image_file:
encoded_string = base64.b64encode(image_file.read())
results = self.twitter.update_profile_image(image=encoded_string)
return results
def change_name(self, name):
if self.twitter is not None:
name = name.replace('"','')
results = self.twitter.update_profile(name=name)
return results
def tweet(self, msg):
if self.twitter is not None:
# > 140 char detection
if len(msg) > 140:
msg = msg[0:139]
syslog.syslog('%s is tweeting %s' % (self.name, msg))
try:
self.twitter.update_status(status=msg)
self.last_tweet = msg
except Exception as e:
syslog.syslog('%s error tweeting -> %s' % (self.name, str(e)))
示例2: TwythonAPITestCase
# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import update_profile [as 别名]
#.........这里部分代码省略.........
self.api.show_friendship(target_screen_name=protected_twitter_1)
def test_get_friends_list(self):
'''Test getting list of users authenticated user then random user is
following succeeds'''
self.api.get_friends_list()
self.api.get_friends_list(screen_name='twitter')
def test_get_followers_list(self):
'''Test getting list of users authenticated user then random user are
followed by succeeds'''
self.api.get_followers_list()
self.api.get_followers_list(screen_name='twitter')
# Users
def test_get_account_settings(self):
'''Test getting the authenticated user account settings succeeds'''
self.api.get_account_settings()
def test_verify_credentials(self):
'''Test representation of the authenticated user call succeeds'''
self.api.verify_credentials()
def test_update_account_settings(self):
'''Test updating a user account settings succeeds'''
self.api.update_account_settings(lang='en')
def test_update_delivery_service(self):
'''Test updating delivery settings fails because we don't have
a mobile number on the account'''
self.assertRaises(TwythonError, self.api.update_delivery_service,
device='none')
def test_update_profile(self):
'''Test updating profile succeeds'''
self.api.update_profile(include_entities='true')
def test_update_profile_colors(self):
'''Test updating profile colors succeeds'''
self.api.update_profile_colors(profile_background_color='3D3D3D')
def test_list_blocks(self):
'''Test listing users who are blocked by the authenticated user
succeeds'''
self.api.list_blocks()
def test_list_block_ids(self):
'''Test listing user ids who are blocked by the authenticated user
succeeds'''
self.api.list_block_ids()
def test_create_block(self):
'''Test blocking a user succeeds'''
self.api.create_block(screen_name='justinbieber')
def test_destroy_block(self):
'''Test unblocking a user succeeds'''
self.api.destroy_block(screen_name='justinbieber')
def test_lookup_user(self):
'''Test listing a number of user objects succeeds'''
self.api.lookup_user(screen_name='twitter,justinbieber')
def test_show_user(self):
'''Test showing one user works'''
self.api.show_user(screen_name='twitter')
示例3: generate
# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import update_profile [as 别名]
"winner of Mario Kart",
"mayor of Animal Crossing"
]
def generate(max_length):
terminator = "Your friend"
length_tolerance = 10
for list_to_shuffle in [ADJECTIVE, DESCRIPTOR, ACTION, RELATIONSHIP]:
random.shuffle(list_to_shuffle)
next_relationship = RELATIONSHIP.pop().capitalize()
bio = "{0} {1} {2}. {3}".format(ADJECTIVE.pop(), DESCRIPTOR.pop(), ACTION.pop(), next_relationship)
while len(bio) < (max_length - length_tolerance):
if len(RELATIONSHIP) == 0:
return attempt
next_relationship = RELATIONSHIP.pop()
attempt = "{0}, {1}. {2}.".format(bio, next_relationship, terminator)
if len(attempt) > max_length:
continue
elif len(attempt) > max_length - length_tolerance:
return attempt
bio += ", {0}".format(next_relationship)
desc = generate(140)
twitter.update_profile(description=desc)
# EOF
示例4: TwitterHelper
# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import update_profile [as 别名]
#.........这里部分代码省略.........
logger.info(result)
if result["result"]["places"]:
# for place in result["result"]["places"]:
# logger.info(place["full_name"])
place = result["result"]["places"][0]
location.place_id_twitter = place["id"]
return location
else:
return None
@retry(**retry_args)
def reverse_geocode(self, location):
result = self.twitter.reverse_geocode(
max_results=5,
lat=location.latitude,
long=location.longitude)
logger.info(result)
if result["result"]["places"]:
# for place in result["result"]["places"]:
# logger.info(place["full_name"])
place = result["result"]["places"][0]
location.place_id_twitter = place["id"]
return location
else:
return None
@retry(**retry_args)
def update_profile_image(self, file_path):
if file_path:
logger.info("updating profile image %s" % file_path)
with open(file_path, 'rb') as file:
self.twitter.update_profile_image(image=file)
@retry(**retry_args)
def update_profile_banner_image(self, file_path):
if file_path:
logger.info("updating banner image %s" % file_path)
with open(file_path, 'rb') as file:
try:
self.twitter.update_profile_banner_image(banner=file)
except TwythonError as ex:
if "Response was not valid JSON" in str(ex):
# twython issue i think
logger.warning(ex)
else:
raise
@retry(**retry_args)
def update_profile(self, **kwargs):
return self.twitter.update_profile(**kwargs)
@retry(**retry_args)
def get_list_statuses(self, **kwargs):
return self.twitter.get_list_statuses(**kwargs)
@retry(**retry_args)
def get_user_suggestions_by_slug(self, **kwargs):
return self.twitter.get_user_suggestions_by_slug(**kwargs)
@retry(**retry_args)
示例5: TwythonAPITestCase
# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import update_profile [as 别名]
#.........这里部分代码省略.........
self.api.show_friendship(target_screen_name=protected_twitter_1)
def test_get_friends_list(self):
"""Test getting list of users authenticated user then random user is
following succeeds"""
self.api.get_friends_list()
self.api.get_friends_list(screen_name='twitter')
def test_get_followers_list(self):
"""Test getting list of users authenticated user then random user are
followed by succeeds"""
self.api.get_followers_list()
self.api.get_followers_list(screen_name='twitter')
# Users
def test_get_account_settings(self):
"""Test getting the authenticated user account settings succeeds"""
self.api.get_account_settings()
def test_verify_credentials(self):
"""Test representation of the authenticated user call succeeds"""
self.api.verify_credentials()
def test_update_account_settings(self):
"""Test updating a user account settings succeeds"""
self.api.update_account_settings(lang='en')
def test_update_delivery_service(self):
"""Test updating delivery settings fails because we don't have
a mobile number on the account"""
self.assertRaises(TwythonError, self.api.update_delivery_service,
device='none')
def test_update_profile(self):
"""Test updating profile succeeds"""
self.api.update_profile(include_entities='true')
def test_update_profile_colors(self):
"""Test updating profile colors succeeds"""
self.api.update_profile_colors(profile_background_color='3D3D3D')
def test_list_blocks(self):
"""Test listing users who are blocked by the authenticated user
succeeds"""
self.api.list_blocks()
def test_list_block_ids(self):
"""Test listing user ids who are blocked by the authenticated user
succeeds"""
self.api.list_block_ids()
def test_create_block(self):
"""Test blocking a user succeeds"""
self.api.create_block(screen_name='justinbieber')
def test_destroy_block(self):
"""Test unblocking a user succeeds"""
self.api.destroy_block(screen_name='justinbieber')
def test_lookup_user(self):
"""Test listing a number of user objects succeeds"""
self.api.lookup_user(screen_name='twitter,justinbieber')
def test_show_user(self):
"""Test showing one user works"""
self.api.show_user(screen_name='twitter')
示例6: TwythonEndpointsTestCase
# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import update_profile [as 别名]
#.........这里部分代码省略.........
self.api.get_friends_list(screen_name='twitter')
@unittest.skip('skipping non-updated test')
def test_get_followers_list(self):
"""Test getting list of users authenticated user then random user are
followed by succeeds"""
self.api.get_followers_list()
self.api.get_followers_list(screen_name='twitter')
# Users
@unittest.skip('skipping non-updated test')
def test_get_account_settings(self):
"""Test getting the authenticated user account settings succeeds"""
self.api.get_account_settings()
@unittest.skip('skipping non-updated test')
def test_verify_credentials(self):
"""Test representation of the authenticated user call succeeds"""
self.api.verify_credentials()
@unittest.skip('skipping non-updated test')
def test_update_account_settings(self):
"""Test updating a user account settings succeeds"""
self.api.update_account_settings(lang='en')
@unittest.skip('skipping non-updated test')
def test_update_delivery_service(self):
"""Test updating delivery settings fails because we don't have
a mobile number on the account"""
self.assertRaises(TwythonError, self.api.update_delivery_service,
device='none')
@unittest.skip('skipping non-updated test')
def test_update_profile(self):
"""Test updating profile succeeds"""
self.api.update_profile(include_entities='true')
@unittest.skip('skipping non-updated test')
def test_update_profile_colors(self):
"""Test updating profile colors succeeds"""
self.api.update_profile_colors(profile_background_color='3D3D3D')
@unittest.skip('skipping non-updated test')
def test_list_blocks(self):
"""Test listing users who are blocked by the authenticated user
succeeds"""
self.api.list_blocks()
@unittest.skip('skipping non-updated test')
def test_list_block_ids(self):
"""Test listing user ids who are blocked by the authenticated user
succeeds"""
self.api.list_block_ids()
@unittest.skip('skipping non-updated test')
def test_create_block(self):
"""Test blocking a user succeeds"""
self.api.create_block(screen_name='justinbieber')
@unittest.skip('skipping non-updated test')
def test_destroy_block(self):
"""Test unblocking a user succeeds"""
self.api.destroy_block(screen_name='justinbieber')
@unittest.skip('skipping non-updated test')
def test_lookup_user(self):