How to use the build.lib.twython2k.TangoError function in build

To help you get started, we’ve selected a few build examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ryanmcgrath / twython / build / lib / twython2k.py View on Github external
updateProfileQueryString = ""
			if name is not None:
				if len(list(name)) < 20:
					updateProfileQueryString += "name=" + name
					useAmpersands = True
				else:
					raise TangoError("Twitter has a character limit of 20 for all usernames. Try again.")
			if email is not None and "@" in email:
				if len(list(email)) < 40:
					if useAmpersands is True:
						updateProfileQueryString += "&email=" + email
					else:
						updateProfileQueryString += "email=" + email
						useAmpersands = True
				else:
					raise TangoError("Twitter has a character limit of 40 for all email addresses, and the email address must be valid. Try again.")
			if url is not None:
				if len(list(url)) < 100:
					if useAmpersands is True:
						updateProfileQueryString += "&" + urllib.urlencode({"url": url})
					else:
						updateProfileQueryString += urllib.urlencode({"url": url})
						useAmpersands = True
				else:
					raise TangoError("Twitter has a character limit of 100 for all urls. Try again.")
			if location is not None:
				if len(list(location)) < 30:
					if useAmpersands is True:
						updateProfileQueryString += "&" + urllib.urlencode({"location": location})
					else:
						updateProfileQueryString += urllib.urlencode({"location": location})
						useAmpersands = True
github ryanmcgrath / twython / build / lib / twython2k.py View on Github external
def checkIfBlockExists(self, id = None, user_id = None, screen_name = None):
		apiURL = ""
		if id is not None:
			apiURL = "http://twitter.com/blocks/exists/" + id + ".json"
		if user_id is not None:
			apiURL = "http://twitter.com/blocks/exists.json?user_id=" + user_id
		if screen_name is not None:
			apiURL = "http://twitter.com/blocks/exists.json?screen_name=" + screen_name
		try:
			return simplejson.load(urllib2.urlopen(apiURL))
		except HTTPError, e:
			raise TangoError("checkIfBlockExists() failed with a %s error code." % `e.code`, e.code)
github ryanmcgrath / twython / build / lib / twython2k.py View on Github external
def destroySavedSearch(self, id):
		if self.authenticated is True:
			try:
				return simplejson.load(self.opener.open("http://twitter.com/saved_searches/destroy/" + id + ".json", ""))
			except HTTPError, e:
				raise TangoError("destroySavedSearch() failed with a %s error code." % `e.code`, e.code)
		else:
			raise TangoError("destroySavedSearch() requires you to be authenticated.")
github ryanmcgrath / twython / build / lib / twython2k.py View on Github external
if len(list(location)) < 30:
					if useAmpersands is True:
						updateProfileQueryString += "&" + urllib.urlencode({"location": location})
					else:
						updateProfileQueryString += urllib.urlencode({"location": location})
						useAmpersands = True
				else:
					raise TangoError("Twitter has a character limit of 30 for all locations. Try again.")
			if description is not None:
				if len(list(description)) < 160:
					if useAmpersands is True:
						updateProfileQueryString += "&" + urllib.urlencode({"description": description})
					else:
						updateProfileQueryString += urllib.urlencode({"description": description})
				else:
					raise TangoError("Twitter has a character limit of 160 for all descriptions. Try again.")
			
			if updateProfileQueryString != "":
				try:
					return self.opener.open("http://twitter.com/account/update_profile.json?", updateProfileQueryString)
				except HTTPError, e:
					raise TangoError("updateProfile() failed with a %s error code." % `e.code`, e.code)
		else:
			raise TangoError("updateProfile() requires you to be authenticated.")
github ryanmcgrath / twython / build / lib / twython2k.py View on Github external
def destroyStatus(self, id):
		if self.authenticated is True:
			try:
				return simplejson.load(self.opener.open("http://twitter.com/status/destroy/%s.json", "POST" % id))
			except HTTPError, e:
				raise TangoError("destroyStatus() failed with a %s error code." % `e.code`, e.code)
		else:
			raise TangoError("destroyStatus() requires you to be authenticated.")
github ryanmcgrath / twython / build / lib / twython2k.py View on Github external
def createFavorite(self, id):
		if self.authenticated is True:
			try:
				return simplejson.load(self.opener.open("http://twitter.com/favorites/create/" + id + ".json", ""))
			except HTTPError, e:
				raise TangoError("createFavorite() failed with a %s error code." % `e.code`, e.code)
		else:
			raise TangoError("createFavorite() requires you to be authenticated.")
github ryanmcgrath / twython / build / lib / twython2k.py View on Github external
def destroyFavorite(self, id):
		if self.authenticated is True:
			try:
				return simplejson.load(self.opener.open("http://twitter.com/favorites/destroy/" + id + ".json", ""))
			except HTTPError, e:
				raise TangoError("destroyFavorite() failed with a %s error code." %	`e.code`, e.code)
		else:
			raise TangoError("destroyFavorite() requires you to be authenticated.")
github ryanmcgrath / twython / build / lib / twython2k.py View on Github external
def getPublicTimeline(self):
		try:
			return simplejson.load(urllib2.urlopen("http://twitter.com/statuses/public_timeline.json"))
		except HTTPError, e:
			raise TangoError("getPublicTimeline() failed with a %s error code." % `e.code`)
github ryanmcgrath / twython / build / lib / twython2k.py View on Github external
def getUserMentions(self, **kwargs):
		if self.authenticated is True:
			try:
				mentionsFeedURL = self.constructApiURL("http://twitter.com/statuses/mentions.json", kwargs)
				return simplejson.load(self.opener.open(mentionsFeedURL))
			except HTTPError, e:
				raise TangoError("getUserMentions() failed with a %s error code." % `e.code`, e.code)
		else:
			raise TangoError("getUserMentions() requires you to be authenticated.")
github ryanmcgrath / twython / build / lib / twython2k.py View on Github external
def createFriendship(self, id = None, user_id = None, screen_name = None, follow = "false"):
		if self.authenticated is True:
			apiURL = ""
			if id is not None:
				apiURL = "http://twitter.com/friendships/create/" + id + ".json" + "?follow=" + follow
			if user_id is not None:
				apiURL = "http://twitter.com/friendships/create.json?user_id=" + user_id + "&follow=" + follow
			if screen_name is not None:
				apiURL = "http://twitter.com/friendships/create.json?screen_name=" + screen_name + "&follow=" + follow
			try:
				return simplejson.load(self.opener.open(apiURL))
			except HTTPError, e:
				# Rate limiting is done differently here for API reasons...
				if e.code == 403:
					raise TangoError("You've hit the update limit for this method. Try again in 24 hours.")
				raise TangoError("createFriendship() failed with a %s error code." % `e.code`, e.code)
		else:
			raise TangoError("createFriendship() requires you to be authenticated.")