Пример #1
0
def get_secrets_file():
    return get_install_dir() + "/secrets.json"
Пример #2
0
    parser.add_argument('--time', action='store',
        help="specify time to log")
    parser.add_argument('--log-tool', action='store',
        help="log a tool usage")
    parser.add_argument('--log-unknown-rfid', action='store_const', const=True,
        help="log an unknown user")

    # setup logging
    log.setLevel(logging.DEBUG)
    log_format = logging.Formatter("%(asctime)s - %(levelname)-8s - %(message)s")

    ch = logging.StreamHandler()
    ch.setFormatter(log_format)
    log.addHandler(ch)

    fh = logging.handlers.RotatingFileHandler(get_install_dir() + '/post.log', maxBytes=(1024*1024), backupCount=7)
    fh.setFormatter(log_format)
    log.addHandler(fh)

    args = parser.parse_args()

    # as this program gets run separately, if there is a network error 
    # lots can end up running, killing the Yun by eating memory
    file = "/tmp/post.lock"
    fd = open(file, 'w')
    try:
        fcntl.lockf(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
        log.debug("checked lock ok")
    except IOError:
        log.debug("another process is running with lock. quitting!")
        exit(1)