GithubHelp home page GithubHelp logo

jeffbass / imagehub Goto Github PK

View Code? Open in Web Editor NEW
21.0 7.0 15.0 1.05 MB

Receive and save images from multiple Raspberry Pi's

License: MIT License

Shell 2.42% Python 97.58%
python raspberry-pi pyzmq zmq opencv-python

imagehub's People

Contributors

jeffbass avatar sbkirby avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

imagehub's Issues

AttributeError: module 'signal' has no attribute 'SIGALRM'

This following error occurs with Windows 10:

Traceback (most recent call last):
  File "imagehub\imagehub\imagehub.py", line 41, in main
    with Patience(hub.patience):
  File "C:\Stephens_Folder\Programming\Home_Monitor\imagehub\imagehub\tools\utils.py", line 63, in __enter__
    signal.signal(signal.SIGALRM, self.raise_timeout)
AttributeError: module 'signal' has no attribute 'SIGALRM'
2020-08-05 08:31:47,888 ~ Exiting imagehub.py

A work-around (not a fix) for this error can be made to utils.py. Add the following line of code to the import section of utils.py.

from sys import platform

Next, replace the __enter__ and __exit__ functions of class Patience section with the following:

    def __enter__(self):
        if platform != "win32":
            signal.signal(signal.SIGALRM, self.raise_timeout)
            signal.alarm(self.seconds)
        else:
            pass

    def __exit__(self, *args):
        if platform != "win32":
            signal.alarm(0)    # disable alarm
        else:
            pass

Note: This will allow you to run imagehub.py on a Windows platform, but it will not function as a normal, and may result in some unusual behavior of the imagehub.

Changing the naming convention of the event log files

For an overview of the yin-yang-ranch distributed computer vision pipeline design, see this repo. The essence of the design is that multiple imagenodes send images and event messages to each imagehub. The imagehub uses Python logging to save the imagenode event messages since it is easy to use and allows easy rotation of log files. In the current version of imagehub, the RotatingFileHandler file handler is used, which means that the log files are named like this at each rotation:

        current (today)  imagehub.log
        previous log     imagehub.log.1
        previous log     imagehub.log.2
        previous log     imagehub.log.3

As my development of the librarian code progresses, the current naming convention for the event log files presents 2 problems:

  1. It is not easy to find the event text lines for a specific date; the log files have to be searched.
  2. The librarian uses rsync for backups of imagehub data, since it is very good at efficiently backing up only what changes. But with the current RotatingFileHandler, all the log files are backed up every time because every existing log file is renumbered at each rotation.

To address these problems, I am changing the imagehub logging to use the TimedRotatingFileHandler. This is what the log files will look like after the change:

        current (today)  imagehub.log
        previous log     imagehub.log.2020-10-22
        previous log     imagehub.log.2020-10-21
        previous log     imagehub.log.2020-10-20

It solves both of the above problems, and, frankly, it should have been done that way from the start. For anyone currently using imagehub and using a program that reads the event log files, this change will require that those programs be modified.

The actual code change is simple and only involves changing 2 lines in the logging section of imagehub.py. Here is the existing code:

    handler = logging.handlers.RotatingFileHandler(hub.logfile,
        maxBytes=99000, backupCount=995)

which becomes:

    handler = logging.handlers.TimedRotatingFileHandler(hub.logfile,
        when='midnight', backupCount=995)

My existing librarian code has been changed and I'll be testing it for a few more weeks. The new imagehub code will be merged into the master branch when the librarian testing is done. This issue is a heads up to anyone currently using imagehub that the change is coming. Feel free to comment.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.