コード例 #1
0
def test_input_0():
    """
    Test with an empty input file, should simply log and exit with error code 1
    """

    # Setup
    helper.cleanup()

    file_path = process.TESTING_DIRECTORY + '/empty_file'
    assert(helper.run_processing_engine(file_path) == 1)

    # Teardown
    helper.cleanup()
コード例 #2
0
def grabdetails(url):
	text = helper.download(url)
	if text is None:
		return None
	show = {}
	subtitle = helper.cut(text, "<h3 class=\"overlay-subtitle\">", "</h3>")
	if subtitle is not None and subtitle:
		show["sub-title"] = helper.cleanup(subtitle)

	description = helper.cut(text, "<p class=\"overlay-text\">", "</p>")
	if description is not None and description:
		show["desc"] = helper.cleanup(description)

	if text.find("Untertitel für Hörgeschädigte") != -1:
		show["subtitles"] = True
	return show
コード例 #3
0
def grab(channel, timespan):
	tz = pytz.timezone("Europe/Berlin")
	now = datetime.datetime.now(tz)
	shows = []
	a = 0
	if now.time().hour < 7:
		a = -1

	for i in range(a, 14):
		date = now + datetime.timedelta(days=i)
		text = helper.download("http://www.zdf.de/live-tv?airtimeDate=" + date.strftime("%Y-%m-%d"))
		if text is None:
			continue

		text = helper.cut(text, "<section class=\"b-epg-timeline timeline-" + channel, "</section>")

		sections = helper.split(text, "<li", "</li>")
		laststart = datetime.datetime.min.replace(tzinfo=tz)
		for section in sections:
			show = {}

			temp = helper.cut(section, "<span class=\"time\">", "</span>")
			temp = re.search("(\d\d):(\d\d) - (\d\d):(\d\d)", temp)	
			show["start"] = date.replace(hour=int(temp.group(1)), minute=int(temp.group(2)), second=0, microsecond=0)
			if show["start"] < laststart:
				date += datetime.timedelta(days=1)
				show["start"] += datetime.timedelta(days=1)

			if (show["start"] - now).total_seconds() / 3600 > timespan:
				return shows

			laststart = show["start"]
			show["stop"] = date.replace(hour=int(temp.group(3)), minute=int(temp.group(4)), second=0, microsecond=0)
			if show["stop"] < show["start"]:
				show["stop"] += datetime.timedelta(days=1)
			temp = re.search("<span class=\"overlay-link-category\">(.*?)<span class=\"visuallyhidden\">:</span></span>\s*(?:<.*>)*\s*(.*?)\s*?</a>", section)
			if temp.group(1):
				show["title"] = helper.cleanup(temp.group(1) + " - " + temp.group(2))
			else:
				show["title"] = helper.cleanup(temp.group(2))

			temp = re.search("contentUrl\": \"(.*)\"", section)
			if temp is not None:
				show["details-url"] = "http://www.zdf.de" + temp.group(1)

			shows.append(show)
	return shows
コード例 #4
0
ファイル: start.py プロジェクト: mdwaseem31/IS-python
with open("inputfile") as myfile:
    for line in myfile:
        name, var = line.partition("=")[::2]
        myvars[name.strip()] = str(var)

uuid = (myvars["uuid"]).replace("\n", "")
driveid = (myvars["driveid"]).replace("\n", "")
beginTS = (myvars["beginTS"]).replace("\n", "")
endTS = (myvars["endTS"]).replace("\n", "")
size = int(myvars["size"])

url_adsTS = helper_url.constructurl(myvars["uuid"], myvars["size"], myvars["beginTS"], myvars["endTS"])
url = (url_adsTS[0]).replace("\n", "")
adsTS = (url_adsTS[1]).replace("\n", "")

# pprint (uuid)
# pprint (driveid)
# pprint (beginTS)
# pprint (endTS)
# pprint (size)
# pprint (url)
# pprint (adsTS)
# exit (0)

helper.cleanup(uuid)
allevents_list = helper_json.validatejsonresponse(uuid, url, size)
pprint ("List of events from all pages =  " + str(allevents_list))
exit(0)
helper_geojson.validategeojsonresponse(uuid, url, size)
helper_mds.mdsCount(uuid)
helper_ads.adsCount(uuid, driveid, adsTS)