Exemple #1
0
    def handler(self, **args):
        """
		This will go on freshmeat to look for a software version
		"""
        import httpfetcher

        # Get the name of the software and put the name in all lowercase
        name = self.getText(args, 1).lower().replace(" ", "+")

        url = "http://freshmeat.net/projects/%s/releases.atom" % name
        error = None
        match = None
        try:
            fetcher = httpfetcher.urlopen(
                url, httpfetcher.RegexChecker(self.rTitle))
            match = fetcher.fetch()
        except socket.timeout:
            error = "timeout"

        if error:
            output = "failed to check version for %s: %s" % (name, error)
        else:
            if not match:
                output = "Can't find %s on [fm]" % name
            else:
                version = match.group(1)
                output = "Latest version of %s according to [fm]: %s" % (
                    name, version)

        return self.msg_sender(args, output)
Exemple #2
0
	def handler(self, **args):
		"""
		This will go on freshmeat to look for a software version
		"""
		import httpfetcher

		# Get the name of the software and put the name in all lowercase
		name = self.getText(args, 1).lower().replace(" ", "+")

		url = "http://freshmeat.net/projects/%s/releases.atom" % name
		error = None
		match = None
		try:
			fetcher = httpfetcher.urlopen(url, httpfetcher.RegexChecker(self.rTitle))
			match = fetcher.fetch()
		except socket.timeout:
			error = "timeout"

		if error:
			output	= "failed to check version for %s: %s" % (name, error)
		else:
			if not match:
				output	= "Can't find %s on [fm]" % name
			else:
				version = match.group(1)
				output	= "Latest version of %s according to [fm]: %s" % (name, version)

		return self.msg_sender(args, output)
Exemple #3
0
def fetch(url, timeout = 10):
	match = None
	try:
		h = httpfetcher.urlopen(url, httpfetcher.RegexChecker(rTitle), timeout)
		if h.status == 200:
			match = h.fetch()
	except socket.timeout:
		return None

	if match:
		titleGetter = TitleGetter()

		encoding = getEncodingFromHeaders(h.headers)
		if encoding:
			titleGetter.encodings.append(encoding)

		try:
			titleGetter.feed(match.group(0))
			titleGetter.close()
		except HTMLParser.HTMLParseError:
			pass

		return titleGetter.title