Esempio n. 1
0
def main():
    parser = argparse.ArgumentParser(
        description='Mount a FapTrack filesystem',
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('mountpoint', type=str, help='the mountpoint')
    parser.add_argument('--database',
                        '-d',
                        type=str,
                        help='the sqlite3 database file',
                        default='faptrack.db')
    parser.add_argument('--max_view_time',
                        '-m',
                        type=int,
                        help='the max view time to be recorded',
                        default=15 * 60)
    parser.add_argument('--logging',
                        '-l',
                        type=str,
                        choices=logging._nameToLevel.keys(),
                        default="WARNING",
                        help='the logging level')

    args = parser.parse_args()

    logging.basicConfig(format='%(asctime)s %(message)s',
                        level=logging._nameToLevel[args.logging])

    my_opts = set(pyfuse3.default_options)
    my_opts.add('allow_root')
    my_opts.discard('default_permissions')

    def conn_fac():
        return sqlite3.connect(args.database)

    pyfuse3.init(VirtualFS(trackFS(conn_fac, args.max_view_time * (10**9))),
                 args.mountpoint, my_opts)
    try:
        asyncio.run(pyfuse3.main())
    except:
        pyfuse3.close()
        raise

    pyfuse3.close()
Esempio n. 2
0
def main():
    options = parse_args()
    init_logging(options.debug)

    testfs = TestFs()
    fuse_options = set(pyfuse3.default_options)
    fuse_options.add('fsname=hello_asyncio')
    if options.debug_fuse:
        fuse_options.add('debug')
    pyfuse3.init(testfs, options.mountpoint, fuse_options)
    loop = asyncio.get_event_loop()
    try:
        loop.run_until_complete(pyfuse3.main())
    except:
        pyfuse3.close(unmount=False)
        raise
    finally:
        loop.close()

    pyfuse3.close()
Esempio n. 3
0
def main():
    args = parse_args()

    pngfs = pngFS(args)

    fuse_options = set(pyfuse3.default_options)
    fuse_options.add('fsname=pngFS')
    if args.fuse_debug:
        fuse_options.add('debug')

    pyfuse3.init(pngfs, args.mountpoint, fuse_options)

    try:
        asyncio.run(pyfuse3.main())
    except KeyboardInterrupt:
        pass

    pngfs.files.clean_files_without_parent()
    pngfs.write_to_png()

    pyfuse3.close()
Esempio n. 4
0
def main():
    options = parse_args()
    init_logging(options.debug)

    testfs = TestFs()
    fuse_options = set(pyfuse3.default_options)
    fuse_options.add('fsname=hello')
    if options.debug_fuse:
        fuse_options.add('debug')
    pyfuse3.init(testfs, options.mountpoint, fuse_options)
    loop = asyncio.get_event_loop()
    try:
        loop.run_until_complete(pyfuse3.main())
    except:
        print("Encountered error so will try to unmount")
        pyfuse3.close(unmount=True)
        raise
    else:
        print("Unmounted: exiting cleanly with out further unmount")
        pyfuse3.close(unmount=False)
    finally:
        loop.close()
Esempio n. 5
0
def main():
    options = parse_args(sys.argv[1:])
    init_logging(options.debug)
    operations = Operations(options.source)

    log.debug('Mounting...')
    fuse_options = set(pyfuse3.default_options)
    fuse_options.add('fsname=passthroughfs')
    if options.debug_fuse:
        fuse_options.add('debug')
    pyfuse3.init(operations, options.mountpoint, fuse_options)

    loop = asyncio.get_event_loop()
    try:
        loop.run_until_complete(pyfuse3.main())
    except:
        print("Encountered error so will try to unmount")
        pyfuse3.close(unmount=True)
        raise
    else:
        print("Unmounted: exiting cleanly with out further unmount")
        pyfuse3.close(unmount=False)
    finally:
        loop.close()
Esempio n. 6
0
                        help='Enable FUSE debugging output')

    return parser.parse_args()


if __name__ == '__main__':

    options = parse_args()
    init_logging(options.debug)
    operations = Operations()

    fuse_options = set(pyfuse3.default_options)
    fuse_options.add('fsname=tmpfs')
    fuse_options.discard('default_permissions')
    if options.debug_fuse:
        fuse_options.add('debug')
    pyfuse3.init(operations, options.mountpoint, fuse_options)

    loop = asyncio.get_event_loop()
    try:
        loop.run_until_complete(pyfuse3.main())
    except:
        print("Encountered error so will try to unmount")
        pyfuse3.close(unmount=True)
        raise
    else:
        print("Unmounted: exiting cleanly with out further unmount")
        pyfuse3.close(unmount=False)
    finally:
        loop.close()