コード例 #1
0
ファイル: rfc2822.py プロジェクト: pruan/TestDepot
def formatdate(timeval=None):
	"""Returns time format preferred for Internet standards.

	Sun, 06 Nov 1994 08:49:37 GMT  ; RFC 822, updated by RFC 1123

	According to RFC 1123, day and month names must always be in
	English.  If not for that, this code could use strftime().	It
	can't because strftime() honors the locale and could generated
	non-English names.
	"""
	import timelib
	if timeval is None:
		timeval = timelib.time()
	timeval = timelib.gmtime(timeval)
	return "%s, %02d %s %04d %02d:%02d:%02d GMT" % (
			["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"][timeval[6]],
			timeval[2],
			["Jan", "Feb", "Mar", "Apr", "May", "Jun",
			 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][timeval[1]-1],
								timeval[0], timeval[3], timeval[4], timeval[5])
コード例 #2
0
ファイル: gkrellm_reminder.py プロジェクト: pruan/TestDepot
 def add_event(self, name, days, occurs, start, end=0.0):
     id = long(timelib.time())
     last_displayed = 0.0
     # XXX days and occurs
     ev = ReminderEvent(name, id, days, occurs, start, end, last_displayed)
     self.events.append(ev)
コード例 #3
0
ファイル: httputils.py プロジェクト: pruan/TestDepot
	def set_expires(self, offset):
		offset = float(offset)
		self.expires = timelib.time() + offset
コード例 #4
0
ファイル: httputils.py プロジェクト: pruan/TestDepot
		self[h] = v


# self test
if __name__ == "__main__":
	print "cookies:"
	cookie = Cookie("somename", 'somevalue&this+plus"quotes"')
	print cookie.get_header()
	setcookie = SetCookie(cookie)
	setcookie.set_expires(3600)
	print setcookie.get_header()
	print "----------"
	auth = BasicAuth("myname", "mypassword")
	print auth.get_header()

	print timelib.ctime(_parse_date(_getdate(timelib.time()))) # output in GMT
	ua = UserAgent()
	print ua
	ua = UserAgent("Mozilla/4.0", comment=MicrosoftComment())
	print ua
	print "----------"
	header = get_header(cookie, auth, ua, [Date(_getdate(timelib.time())), Location("/location"), ContentEncoding("gzip")])
	print header
	for hitem in header.items():
		print "%20s: %s" % hitem
	sauth = str(auth)
	print sauth
	newauth = BasicAuth()
	newauth.parse(sauth)
	print newauth.name, newauth.passwd