Exemplo n.º 1
0
def run_db():
    # Login and save the html file to gen
    logging.info('Login and saving notice board html to gen')
    tpo = TpoSession()
    tpo.login()

    NoticeWrapper.init_db()

    # From the html file, extract and save the notices
    logging.info('Saving the notices to database.')
    num = insert.insert_db()
    if num is None:
        logging.error("Error encountered during extraction. Exiting.")
        exit()
    logging.info("Inserted %d notices.", num)

    # Update the json files to include the notice details and attachments
    logging.info('Updating json files')
    update.update_db()

    # Send the unsent notices
    logging.info('Sending unsent notices.')
    send.send_unsent_db()

    NoticeWrapper.deinit_db()

    logging.info("Finished running script.")
Exemplo n.º 2
0
def run_db():
	# Login and save the html file to gen
	logging.info('Login and saving notice board html to gen')
	tpo = TpoSession()
	tpo.login()

	NoticeWrapper.init_db()

	# From the html file, extract and save the notices
	logging.info('Saving the notices to database.')
	num = insert.insert_db()
	if num is None:
		logging.error("Error encountered during extraction. Exiting.")
		exit()
	logging.info("Inserted %d notices.", num)

	# Update the json files to include the notice details and attachments
	logging.info('Updating json files')
	update.update_db()

	# Send the unsent notices
	logging.info('Sending unsent notices.')
	send.send_unsent_db()

	NoticeWrapper.deinit_db()

	logging.info("Finished running script.")
Exemplo n.º 3
0
def get_details_url(url, attach):
    """
	Given url of notice and whether attachments are present, extract a dict
	containing update information and return.
	"""
    tpo = TpoSession()
    tpo.start_session()
    tpo.forum_login()
    # Get the notice page html from the TPO website
    logging.debug("Extracting notice page html from the TPO website")
    html = tpo.get_forum_notice(url)
    if html is None:
        logging.error("Failed getting html file of notice from TPO")
        return None

    # Extract information from the notice
    logging.debug("Extract useful information from the notice page.")
    details = extract.get_notice_details(html, attach)
    if details is None:
        logging.error("Failed extracting information from the notice page.")
        return None

    return details
def get_details_url(url, attach):
    """
	Given url of notice and whether attachments are present, extract a dict
	containing update information and return.
	"""
    tpo = TpoSession()
    tpo.start_session()
    tpo.forum_login()
    # Get the notice page html from the TPO website
    logging.debug("Extracting notice page html from the TPO website")
    html = tpo.get_forum_notice(url)
    if html is None:
        logging.error("Failed getting html file of notice from TPO")
        return None

        # Extract information from the notice
    logging.debug("Extract useful information from the notice page.")
    details = extract.get_notice_details(html, attach)
    if details is None:
        logging.error("Failed extracting information from the notice page.")
        return None

    return details
Exemplo n.º 5
0
		n = Notice(fl)
		notice = n.get_json()
		if not notice['sent']:
			notice['sent'] = True
			n.save_json(notice)

root = os.path.abspath(os.path.dirname(__file__))
path = root + "/gen"

if os.path.isdir(path):
	logging.info("Found gen folder. Cleaning it up.")
	shutil.rmtree(path)

# Login and save the html file to gen
logging.info('Login and save html file to gen')
tpo = TpoSession()
tpo.login()

# From the html file, extract and save the notices
logging.info('From the html file, extract and save the notices')
num = insert.insert()
if num is None:
	logging.error("Error encountered during extraction. Exiting.")
	exit()
logging.info("Inserted %d notices.", num)

# Update the json files to include the notice details and attachments
logging.info('Updating the json files.')
update.update()

# Do not send redundant pushes on first run