コード例 #1
0
    def Connect(self):
        test = True
        if not test:
            serialport = connect()
        else:
            serialport = 111
        if serialport is not None:

            self.worker = WorkerObject(serialport)
            self.worker.start()

            self.worker.signalStatus.connect(self.Process_data)

            self.ui.statusBar.showMessage(str(serialport), 10000)
        else:

            self.ui.statusBar.showMessage('Not connected', 10000)
コード例 #2
0
import time
import json
import requests
from selenium import webdriver
from bs4 import BeautifulSoup
from selenium.webdriver.common.keys import Keys
from handler import getKidInformation
from Connect import connect

collection = connect()


#note for concern, this program cannot break
class missingKidScraper:
    def __init__(self, headers, params, url):
        self.headers = headers
        self.params = params
        self.url = url
        self.missingChildren = {}
        self.childrenNames = []
        self.driver = webdriver.Firefox()
        self.driver.get(self.url)
        #keep track of page number incase code breaks so we dont have to start from the beginning
        self.pageNumber = 0

    #get, use, and saveHTML is just for development purpose so
    # we do not constantly send requests to the target site
    # when we refactor, develop and interface
    def open(self):
        self.driver.find_element_by_class_name("missing-filter-submit").click()
        time.sleep(3)
コード例 #3
0
import sys
sys.path.append('../Connection')
from Connect import connect

connection = connect()
cursor = connection.cursor()

with open('busAmenities.txt', 'r') as f:
    bus_amenities = [line for line in f]
for sql in bus_amenities[1:]:
    cursor.execute("insert into bus_amenities " + bus_amenities[0][0:-1] +
                   " values" + sql[0:-1])
connection.commit()
コード例 #4
0
# create logger
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
# create console handler and set level to debug
ch = logging.StreamHandler(sys.stdout)
ch.setLevel(logging.DEBUG)
# create formatter
formatter = logging.Formatter(
    '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# add formatter to ch
ch.setFormatter(formatter)
# add ch to logger
logger.addHandler(ch)

db = connect()


def cleanEpisode(episode):
    '''Detects errors in episode and writes changes to database'''
    set_fields = {}  # Fields to update in the object
    tags = []
    if 'Subtitle' in episode:
        # Parse datetime from Subtitle attrubite. Includes hour, endtime, and timezone.
        # Stores datetime in UTC time.
        try:
            subtitle = episode['Subtitle']
            # Match 'CSPAN July 16, 2009 11:00pm-2:00am EDT'
            time = '(\d+):(\d+)(\w+)'
            match = re.match(f'.* (\w+) (\d+), (\d+) {time}-{time} (\w+)',
                             subtitle)