How to use the build.lib.tango.tango.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 / tango / tango.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 / tango / tango.py View on Github external
def destroyDirectMessage(self, id):
		if self.authenticated is True:
			try:
				return self.opener.open("http://twitter.com/direct_messages/destroy/%s.json" % id, "")
			except HTTPError, e:
				raise TangoError("destroyDirectMessage() failed with a %s error code." % `e.code`, e.code)
		else:
			raise TangoError("You must be authenticated to destroy a direct message.")
github ryanmcgrath / twython / build / lib / tango / tango.py View on Github external
def getSavedSearches(self):
		if self.authenticated is True:
			try:
				return simplejson.load(self.opener.open("http://twitter.com/saved_searches.json"))
			except HTTPError, e:
				raise TangoError("getSavedSearches() failed with a %s error code." % `e.code`, e.code)
		else:
			raise TangoError("getSavedSearches() requires you to be authenticated.")
github ryanmcgrath / twython / build / lib / tango / tango.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 / tango / tango.py View on Github external
def updateProfileBackgroundImage(self, filename, tile="true"):
		if self.authenticated is True:
			try:
				files = [("image", filename, open(filename).read())]
				fields = []
				content_type, body = self.encode_multipart_formdata(fields, files)
				headers = {'Content-Type': content_type, 'Content-Length': str(len(body))}
				r = urllib2.Request("http://twitter.com/account/update_profile_background_image.json?tile=" + tile, body, headers)
				return self.opener.open(r).read()
			except HTTPError, e:
				raise TangoError("updateProfileBackgroundImage() failed with a %s error code." % `e.code`, e.code)
		else:
			raise TangoError("You realize you need to be authenticated to change a background image, right?")
github ryanmcgrath / twython / build / lib / tango / tango.py View on Github external
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
				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:
github ryanmcgrath / twython / build / lib / tango / tango.py View on Github external
def getWeeklyTrends(self, date = None, exclude = False):
		apiURL = "http://search.twitter.com/trends/daily.json"
		questionMarkUsed = False
		if date is not None:
			apiURL += "?date=" + date
			questionMarkUsed = True
		if exclude is True:
			if questionMarkUsed is True:
				apiURL += "&exclude=hashtags"
			else:
				apiURL += "?exclude=hashtags"
		try:
			return simplejson.load(urllib.urlopen(apiURL))
		except HTTPError, e:
			raise TangoError("getWeeklyTrends() failed with a %s error code." % `e.code`, e.code)
github ryanmcgrath / twython / build / lib / tango / tango.py View on Github external
def showStatus(self, id):
		try:
			if self.authenticated is True:
				return simplejson.load(self.opener.open("http://twitter.com/statuses/show/%s.json" % id))
			else:
				return simplejson.load(urllib2.urlopen("http://twitter.com/statuses/show/%s.json" % id))
		except HTTPError, e:
			raise TangoError("Failed with a %s error code. Does this user hide/protect their updates? You'll need to authenticate and be friends to get their timeline." 
				% `e.code`, e.code)
github ryanmcgrath / twython / build / lib / tango / tango.py View on Github external
def updateDeliveryDevice(self, device_name = "none"):
		if self.authenticated is True:
			try:
				return self.opener.open("http://twitter.com/account/update_delivery_device.json?", urllib.urlencode({"device": device_name}))
			except HTTPError, e:
				raise TangoError("updateDeliveryDevice() failed with a %s error code." % `e.code`, e.code)
		else:
			raise TangoError("updateDeliveryDevice() requires you to be authenticated.")
github ryanmcgrath / twython / build / lib / tango / tango.py View on Github external
def notificationLeave(self, id = None, user_id = None, screen_name = None):
		if self.authenticated is True:
			apiURL = ""
			if id is not None:
				apiURL = "http://twitter.com/notifications/leave/" + id + ".json"
			if user_id is not None:
				apiURL = "http://twitter.com/notifications/leave/leave.json?user_id=" + user_id
			if screen_name is not None:
				apiURL = "http://twitter.com/notifications/leave/leave.json?screen_name=" + screen_name
			try:
				return simplejson.load(self.opener.open(apiURL, ""))
			except HTTPError, e:
				raise TangoError("notificationLeave() failed with a %s error code." % `e.code`, e.code)
		else:
			raise TangoError("notificationLeave() requires you to be authenticated.")