Пример #1
0
def check_downtime(url, url_id, start, end):
	current_time_date = datetime.datetime.now()
	#url = orm.session.query(orm.URL).filter_by(id=url_id).first()
	# if current time is passed downtime end, clear downtime
	try:
		if current_time_date > end:
			core.clear_downtime(url_id)
			print '%s downtime ended at %r' % (url, end)
			return 'no'
		elif current_time_date < start:
			print '%s downtime starts at %r' % (url, start)
			return 'no'
		else:
			print '%s has downtime scheduled from %r to %r' %(url, start, end)
			return 'yes'
	except TypeError:
		print 'Downtime never scheduled for %s' % url
		return 'no'
Пример #2
0
def test_clear_downtime():
	'''set the status of downtime to no and clear time values'''
	url_id = 6
	result = core.clear_downtime(url_id)
	tools.assert_equals(result.scheduled_downtime, 'no')