def health_process(self, update_queue):
        print("Starting health process")
        config_params = ConfigReader().parse_vars(["INIT_QUEUE"])

        watcher = Watcher(config_params["INIT_QUEUE"], update_queue)

        watcher.start()
Exemplo n.º 2
0
def main():
    config = configparser.ConfigParser()

    config.read("config.ini")

    #check_for_log_dir(config)
    w = Watcher(config)
    w.run()
Exemplo n.º 3
0
    def solve(self):
        if DEBUG:
            self._intialize_watcher()
            self._set_watcher_current_state()
            Watcher.update()
            input()

        self.unnasigned = list(self.tanks.values())

        self.unnasigned.reverse()

        status = self._solve_recursive()

        if not status:
            return None
        return self._gen_output()
Exemplo n.º 4
0
    def run_watcher(self, watcher: Watcher):
        """Run a watcher and create a ChangeEvent with information about whether the site changed

        Args:
            watcher (Watcher): The watcher to check status for

        Returns:
            ChangeEvent: Information about whether the site changed
        """
        logging.info(f'Now Running Watcher for {watcher.name}')
        change = ChangeEvent()
        # Grab the HTML and calculate the MD5 for it
        new_html = watcher.get_html()
        new_md5 = calculate_md5(new_html)

        # Make sure that if it's the first run we don't alert a change
        if watcher.md5 is None:
            watcher.md5 = new_md5

        # If the page was changed since the last check
        if new_md5 != watcher.md5:
            logging.debug(f'Found new MD5! {new_md5}')
            # Get the white/black-listed words from the HTML
            whitelisted = search_wordlist(watcher.whitelist, new_html)
            blacklisted = search_wordlist(watcher.blacklist, new_html)

            # Set the ChangeEvent values
            change.did_change = True
            change.new_whitelisted = [
                word for word in whitelisted
                if word not in watcher.previous_whitelisted
            ]
            change.new_blacklisted = [
                word for word in blacklisted
                if word not in watcher.previous_blacklisted
            ]

            # Set the watcher values
            watcher.md5 = new_md5
            watcher.previous_whitelisted = whitelisted
            watcher.previous_blacklisted = blacklisted
        return change
Exemplo n.º 5
0
    def _intialize_watcher(self):
        Watcher.open(self.height, self.width, 640)
        for row_num, number in enumerate(self.num_rows):
            Watcher.set_row_number(True, row_num, number)

        for col_num, number in enumerate(self.num_cols):
            Watcher.set_col_number(True, col_num, number)

        for tank in self.tanks.values():
            for row_tiles in tank.tiles_row:
                for tile in row_tiles:
                    for i in range(tile.x, tile.x + tile.width):
                        Watcher.set_cell_tank(tile.y, i, tank.id)
Exemplo n.º 6
0
    def _set_watcher_current_state(self):
        for tank in self.tanks.values():
            for row_tiles in tank.tiles_row:
                for tile in row_tiles:
                    for i in range(tile.x, tile.x + tile.width):
                        Watcher.set_cell_matter(tile.y, i, tile.filled)

        for row_num, number in enumerate(self.current_sum_rows):
            Watcher.set_row_number(False, row_num, number)

        for col_num, number in enumerate(self.current_sum_cols):
            Watcher.set_col_number(False, col_num, number)
Exemplo n.º 7
0
def read_watchers_from_config(watchers_list: list):
    """Parse the supplied json into a list of Watcher objects.

    Args:
        watchers_list (list): List of watcher objects from the config file

    Returns:
        list: List of the configurations as Watcher objects
    """
    logging.debug('Creating Watcher objects...')
    watcher_objects = []
    for watcher_item in watchers_list:
        try:
            watcher_objects.append(Watcher(watcher_item))
        except InvalidWatcherConfiguration:
            logging.error(f'Invalid Configuration ({watcher_item.name})!')
    number_of_watchers = len(watcher_objects)
    logging.info(f'Created {number_of_watchers} watchers')
    return watcher_objects
Exemplo n.º 8
0
def main():
    w = Watcher()
    w.run()
Exemplo n.º 9
0
# 関連外部ライブラリ
from flask import Blueprint
from flask_uploads import UploadSet, DATA, DOCUMENTS
from flask import jsonify, request

# 内部ライブラリ
sys.path.insert(0,
                os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from engine.facenet.facenet_engine import FacenetEngine
from database.db_utilities import DBUtility
from watcher.watcher import Watcher

# Instance generation
facenet = FacenetEngine()
db_util = DBUtility()
watcher = Watcher()

uploads = Blueprint('uploads', __name__)
files = UploadSet('files', DATA + DOCUMENTS)

SAVING_IMAGE_FOLDER_NAME = "images"

# Debug mode
DEBUG_MODE = True


@uploads.route("/api/uploads", methods=['POST'])
def upload_binary():
    """
    Upload binary image API with format: <personName>_<image_source>
    And Post encode data to database
Exemplo n.º 10
0
    parser.add_argument('--output', nargs='?', default="output",
            help='default output folder')
    parser.add_argument('--input', nargs='?', help='file to be rendered')

if __name__ == "__main__":
    init_args()
    args = vars(parser.parse_args())

    if not os.path.exists(args['config']):
        sys.exit(-1)
 
    if not os.path.exists(args['output']):
        os.mkdir(args['output'])   
 
    Watcher.output_folder = args['output']
    Renderer.output_folder = args['output']


    if args['action'] == 'watch':
        config = Watcher.parse(json.loads("".join(open(args['config'], 'r').readlines())))
        watchers = [Watcher(conf) for conf in config]
        processes = [watcher.start() for watcher in watchers]

            # join all process
        for process in processes:
            process.join()

    elif args['action'] == 'render':
        renderer = Renderer()
        renderer.renders(paths=glob.glob(args['input']))