def fetch(
        self
    ):  # Get bookname and author name and send it to the scrapy module for searching and scraping
        global download_path
        bookName = self.bookNameTextbox.text()
        authorName = self.authorNameTextbox.text()
        authorName = re.split(
            ';|,| ',
            authorName)  #Get the different words in the author name list
        authorName = [
            x.lower() for x in authorName if x
        ]  # Convert it to lower case and filter out empty strings
        authorName = set(authorName)  # Add to set
        if bookName == '':
            self.show_error('Please provide atleast one book name')
        else:
            linkScraper = BookLinkScraper()
            linkScraper.begin(bookName, authorName)
            if linkScraper.get_list_length() == 0:
                self.show_error("No matches found")
                return
            prioritizer = Prioritizer()
            prioritizer.prioritize()

            downloader = DownloadLinkScraper(download_path)
            status = downloader.begin()
            status = "Success"
            if status == "Limit Reached":
                self.show_error('Download cannot be completed due to limits')
            elif status == "Success":
                Converter().convert(book_name=bookName,
                                    download_dir=download_path)
                Emailer().send(bookName, download_dir=download_path)
                Remover().remove(download_dir=download_path)
                self.show_message("Process Complete")
Beispiel #2
0
    def __init__(self, parameters=None, emailer=None):
        if parameters is None:
            parameters = TestRunnerParameters(self.cfgParser)

        if emailer is None:
            emailerParameters = EmailerParameters(self.cfgParser)
            emailer = Emailer(emailerParameters)

        self.emailer = emailer
        self.parameters = parameters
        self.experiments = []
Beispiel #3
0
 def run(self):
     """
     Calls everything. Execution starts here
     :return: -1 or 1
     """
     raw_json_data = QueryCowin("294").get_json_data()
     receiver_config = self.get_receivers_configs()
     for vaccine in receiver_config:
         responsecombiner = CombinedResponse(raw_json_data, vaccine, "Karnataka")
         combined_data = responsecombiner.get_combined_response()
         Emailer(combined_data, vaccine, receiver_config[vaccine]).send_vaccine_info()
Beispiel #4
0
 def main(self):
     scrape = Scraper(self.from_ct, self.date, self.time)
     data = scrape.fetch_full()
     nj = NJParser(data[0]).parse_data()
     ct = CTParser(data[1]).parse_data()
     if self.from_ct:
         schedule = Scheduler(ct, nj, self.low, self.high).generate()
     else:
         schedule = Scheduler(nj, ct, self.low, self.high).generate()
     message = "Train schedules for " + self.date.strftime('%Y-%m-%d')
     Emailer(self.password, self.email,
             self.file).send_email(message + ":\n" + schedule, message)
Beispiel #5
0
def email_loop():
    threading.Timer(config.EMAIL_LOOP_INTERVAL, email_loop).start()
    emails = generate_email.generate_all_email()
    print(datetime.now().strftime("%d/%m/%Y - %H:%M:%S"))
    print("Emails Generated -", len(emails))
    if len(emails) > 0:
        EmailSystem = Emailer()
        for email in emails:
            EmailSystem.send_email(email)
        print()
    else:
        print()
Beispiel #6
0
    def run(self):
        outputs = {}
        for handle in self.handles:
            if '(类型)' not in handle.keys():
                raise RuntimeError('not find (类型)')

            handle_type: str = handle['(类型)']

            if handle_type == '(输出)':
                outputer = GioOutputer(self.projects, self.dashboards, handle,
                                       outputs)
                outputer.run()
            elif handle_type == '(邮件)':
                emailer = Emailer(self.mailbox, handle, outputs)
                emailer.run()
Beispiel #7
0
def test():
    from ConfigParser import ConfigParser
    from ParametersParsing import EmailerParameters, GeneralParameters, Tools

    configFile = "Parameters.conf"
    parentDir = os.path.abspath(
        os.path.join(os.path.dirname(__file__), os.pardir))
    configFile = os.path.join(parentDir, configFile)
    cfgParser = ConfigParser()
    cfgParser.read(configFile)

    tools = Tools(cfgParser)
    emailerParameters = EmailerParameters(cfgParser)
    generalParameters = GeneralParameters(cfgParser)
    solutionBuilder = SolutionBuilder(Emailer(emailerParameters))

    solutionBuilder.BuildSln(generalParameters, tools)
Beispiel #8
0
    def run(self):
        if len(self.handles) is 0:
            raise RuntimeError('未找到任务处理')

        for handle in self.handles:
            # print(handle)
            if len(handle) is 0:
                raise RuntimeError('未找到操作片段')

            results = {}
            for segment in handle:
                key = list(segment.keys())[0]
                value = list(segment.values())[0]
                if key == '(SELECT)':
                    selecter = Selecter(self.databases, results, value)
                    selecter.run()
                    print(results)
                elif key == '(JOIN)':
                    joiner = Joiner(results, value)
                    joiner.run()
                    print(results)
                elif key == '(UNION)':
                    unioner = Unioner(results, value)
                    unioner.run()
                    print(results)
                elif key == '(ADD)':
                    adder = Adder(results, value)
                    minuser.run()
                    print(results)
                elif key == '(MINUS)':
                    minuser = Minuser(results, value)
                    minuser.run()
                    print(results)
                elif key == '(GROUP)':
                    grouper = Grouper(results, value)
                    grouper.run()
                    print(results)
                elif key == '(输出)':
                    outputer = Outputer(results, value)
                    outputer.run()
                    print(results)
                elif key == '(邮件)':
                    emailer = Emailer(self.email, value[0], results)
                    emailer.run()
Beispiel #9
0
def CheckFace(valid_output, vid_image, graph, frame_name, match_count):

    # run a single inference on the image and overwrite the
    # boxes and labels
    test_output = run_inference(vid_image, graph)

    matched_face = face_match(valid_output, test_output)
    if (matched_face != False):

        print('PASS!  File ' + matched_face + ' matches ')
        match_count += 1
        if (match_count >= 5 and match_count <= 7):
            print('User Checked In!')
            found_match = 2
            if (match_count == 7):
                match_count = 0
                Requestor().start()
                excemptions = ['Michael', 'Chris L']
                if matched_face not in excemptions:
                    fileName = '/home/tme/Desktop/Log/' + matched_face + str(
                        datetime.now()) + '.png'
                    cv2.imwrite(fileName, vid_image)
                    emailMessage = Emailer(fileName, matched_face)
                    emailMessage.start()

        else:
            found_match = 1

    else:
        found_match = 3
        # print('FAIL!  File ' + frame_name + ' does not match ')
        match_count = 0
        # Uncomment next line to view the image sent to the graph
        # vid_image = preprocess_image(vid_image)

    overlay_on_image(vid_image, frame_name, found_match, matched_face)
    return match_count
Beispiel #10
0
 def email(self, emailList, sms_list, subjectLine, emailContent):
     sender = Emailer(emailList, sms_list, subjectLine, emailContent)
     sender.alert()
Beispiel #11
0
def CreateSocket(q):
    # Read the IP address of the door
    with open(r'/home/tme/door.txt') as file:
        host = file.readline()
    port = 8686
    q.put(False)

    doorOpenedTime = None
    sendEmail = True

    # Create a socket item
    mySocket = socket.socket()
    # Try to connect to the socket server running on the Pi
    try:
        mySocket.connect((host, port))
    except socket.error as e:
        print(e)
    # Loop forever checking the socket for messages
    while True:
        if doorOpenedTime is not None:
            if (datetime.now() -
                    doorOpenedTime).total_seconds() > 1800 and sendEmail:
                sendEmail = False
                emailMessage = Emailer()
                emailMessage.start()
        # Check the Queue to see if it has information, if it does check to see if it says exit.
        # If the Queue says exit then break the loop
        if not q.empty():
            qData = q.get()
            if qData == "exit":
                break
            else:
                q.put(qData)
        # Set receive listen timeout to 1/10 of a second so it doesn't hang forever waiting for a message
        mySocket.settimeout(0.1)
        # Try to receive data from the socket, if it times out pass and run loop again
        try:
            data = mySocket.recv(1024).decode()
            # If data is None then the socket server isn't running and break the loop
            if not data:
                break
            print("from connected  user: "******"opened":
                if q.empty():
                    q.put(True)

                else:
                    qData = q.get()
                    if qData == "exit":
                        break
                    q.put(True)
                doorOpenedTime = datetime.now()
                print("Door opened at " + str(doorOpenedTime))
            elif data == "closed":
                if q.empty():
                    q.put(False)
                else:
                    qData = q.get()
                    if qData == "exit":
                        print("quitting")
                        break
                    q.put(False)
                sendEmail = True
                doorOpenedTime = None
                print("Door closed")
        except KeyboardInterrupt:
            print("Keyboard interrupt detected. Closing Socket.")
            mySocket.close()
        except socket.timeout:
            pass

    mySocket.close()
    print("Socket Closed")
Beispiel #12
0
from Emailer import Emailer

if __name__ == "__main__":
    email = Emailer()
    receiver = "*****@*****.**"
    dealDetail = {
        "brand": "kate spade",
        "description": "kate spade surprise sale",
        "hashcode": hash("kate spade surprise sale"),
        "link": "https://dealsea.com/view-deal/827333 ",
    }
    email.sendemail(dealDetail, receiver)
        command = r'"C:\Program Files (x86)\CollabNet\Subversion Client\svn.exe" co%s %s %s' \
                  % (rev, url, to)
        return command

    def CheckOut(self):
        self.logger = Logger()
        self.logger.CoolLog("Delete sources and Checkout")
        self.DeleteSources()
        command = self.FormCommand()
        self.doCheckOut(command)


if __name__ == "__main__":
    from ConfigParser import ConfigParser
    from ParametersParsing import EmailerParameters, GeneralParameters, RepoParameters

    configFile = "Parameters.conf"
    parentDir = os.path.abspath(
        os.path.join(os.path.dirname(__file__), os.pardir))
    configFile = os.path.join(parentDir, configFile)
    cfgParser = ConfigParser()
    cfgParser.read(configFile)

    emailerParameters = EmailerParameters(cfgParser)
    repoParameters = RepoParameters(cfgParser)
    generalParameters = GeneralParameters(cfgParser)

    svnWorker = SvnWorker(Emailer(emailerParameters), generalParameters,
                          repoParameters)
    svnWorker.CheckOut()
Beispiel #14
0
from Emailer import Emailer
from time import sleep

notes = [["test", "123"], ["jest","124"]]

my_emailer = Emailer()

for i in range(20):
	my_emailer.send_email(notes)
Beispiel #15
0
 def emailWithPdf(self, emailList, sms_list, subjectLine, emailContent,
                  pfile, cfile):
     sender = Emailer(emailList, sms_list, subjectLine, emailContent)
     sender.sendPdf(pfile, cfile)
    def run(self):
        '''
        Actually get ready to run... we defered initialization in order to
        configure signal handlers in __main__ but they should now be in place

        This corresponds to the transition from Start in FSM.odg see docs
        '''

        # Step 1 Do a bit of a dance to show we are running
        logging.info("Setting display color to wipe red")
        self.box.set_display_color_wipe(RED, 10)
        logging.info("Started PortalBoxApplication.run()")

        # Set 2 Figure out our identity
        mac_address = format(get_mac_address(), 'x')
        logging.info("Discovered Mac Address: %s", mac_address)

        # connect to backend database
        logging.info("Connecting to database on host %s", self.settings['db']['host'])
        try:
            logging.debug("Creating database instance")
            self.db = Database(self.settings['db'])
            logging.info("Connected to Database")
        except Exception as e:
            logging.error("{}".format(e))
            sys.exit(1)

        # be prepared to send emails
        try:
            logging.info("Creating emailer instance")
            self.emailer = Emailer(self.settings['email'])
            logging.info("Cached email settings")
        except Exception as e:
            # should be unreachable
            logging.error("{}".format(e))
            sys.exit(1)

        # give user hint we are makeing progress 
        logging.debug("Setting display color to wipe orange")
        self.box.set_display_color_wipe(ORANGE, 10)

        # determine what we are
        profile = (-1,)
        self.running = True
        while self.running and 0 > profile[0]:
            feed_watchdog("equipment_profile")
            logging.info("Trying to get equipment profile")
            profile = self.db.get_equipment_profile(mac_address)
            if 0 > profile[0]:
                sleep(5)

        # only run if we have role, which we might not if systemd asked us to
        # shutdown before we discovered a role
        if 0 < profile[0]:
            # profile:
            #   (int) equipment id
            #   (int) equipment type id
            #   (str) equipment type
            #   (int) location id
            #   (str) location
            #   (int) time limit in minutes
            self.equipment_id = profile[0]
            self.equipment_type_id = profile[1]
            self.equipment_type = profile[2]
            self.location = profile[4]
            self.timeout_period = profile[5]

            logging.info("Discovered identity. Type: %s(%s) Timeout: %s m",
                    self.equipment_type,
                    self.equipment_type_id,
                    self.timeout_period)
            self.db.log_started_status(self.equipment_id)

            logging.info("Setting display to wipe green")
            self.box.set_display_color_wipe(GREEN, 10)
            self.timeout_period *= 60 # python threading wants seconds, DB has minutes
            self.proxy_uid = -1
            self.training_mode = False
            logging.info("Starting to wait for access card")
            self.wait_for_access_card()
        else:
            logging.info("Running ending; did not discover identity.")
            sys.exit(1)
Beispiel #17
0
 def emailRecovery(self, emailList, sms_list, subjectLine, emailContent,
                   pfile, cfile):
     sender = Emailer(emailList, sms_list, subjectLine, emailContent)
     sender.sendPdfOnly(pfile, cfile)
Beispiel #18
0
def run_camera(valid_output, graph):
    camera_device = cv2.VideoCapture(CAMERA_INDEX)
    camera_device.set(cv2.CAP_PROP_FRAME_WIDTH, REQUEST_CAMERA_WIDTH)
    camera_device.set(cv2.CAP_PROP_FRAME_HEIGHT, REQUEST_CAMERA_HEIGHT)
    camera_device.set(cv2.CAP_PROP_FPS, REQUEST_CAMERA_FPS)

    actual_camera_width = camera_device.get(cv2.CAP_PROP_FRAME_WIDTH)
    actual_camera_height = camera_device.get(cv2.CAP_PROP_FRAME_HEIGHT)
    print ('actual camera resolution: ' + str(actual_camera_width) + ' x ' + str(actual_camera_height))

    if ((camera_device == None) or (not camera_device.isOpened())):
        print ('Could not open camera.  Make sure it is plugged in.')
        print ('Also, if you installed python opencv via pip or pip3 you')
        print ('need to uninstall it and install from source with -D WITH_V4L=ON')
        print ('Use the provided script: install-opencv-from_source.sh')
        return

    frame_count = 0
    match_count = 0
    #entrant = 0

    cv2.namedWindow(CV_WINDOW_NAME)

    found_match = 0

    Faked = False

    while True :
        # Read image from camera,
        ret_val, vid_image = camera_device.read()
        if (not ret_val):
            print("No image from camera, exiting")
            break

        frame_count += 1
        frame_name = 'camera frame ' + str(frame_count)



        if (not Faked):
            # run a single inference on the image and overwrite the
            # boxes and labels
            test_output = run_inference(vid_image, graph)

            matched_face = face_match(valid_output, test_output)
            if (matched_face != False):

                print('PASS!  File ' + matched_face + ' matches ')
                match_count += 1
                if (match_count >= 5 and match_count <= 7):
                    print('User Checked In!')
                    found_match = 2
                    if (match_count == 7):
                        #return
                        match_count = 0
                        Requestor().start()
                        excemptions = ['Michael', 'Chris L']
                        if matched_face not in excemptions:
                            fileName = '/home/tme/Desktop/Log/' + matched_face + str(datetime.datetime.now()) + '.png'
                            cv2.imwrite(fileName, vid_image)
                            emailMessage = Emailer(fileName, matched_face)
                            emailMessage.start()

                else:
                    found_match = 1

            else:
                found_match = 3
                print('FAIL!  File ' + frame_name + ' does not match ')
                match_count = 0
            #Uncomment next line to view the image sent to the graph
            #vid_image = preprocess_image(vid_image)

        overlay_on_image(vid_image, frame_name, found_match, matched_face)

        # check if the window is visible, this means the user hasn't closed
        # the window via the X button
        prop_val = cv2.getWindowProperty(CV_WINDOW_NAME, cv2.WND_PROP_ASPECT_RATIO)
        if (prop_val < 0.0):
            print('window closed')
            break

        # display the results and wait for user to hit a key
        cv2.imshow(CV_WINDOW_NAME, vid_image)
        raw_key = cv2.waitKey(1)
        if (raw_key != -1):
            if (handle_keys(raw_key) == False):
                print('user pressed Q')
                break
            if (handle_keys(raw_key) == 2):
                Faked = True
                print('PASS!  File ' + frame_name + ' matches ')
                match_count += 1
                if (match_count == 2):
                    print('User Checked In!')
                    found_match = 2
                elif (match_count == 3):
                    Faked = False
                    match_count = 0
                else:
                    found_match = 1

    if (found_match):
        cv2.imshow(CV_WINDOW_NAME, vid_image)
        cv2.waitKey(0)