Exemple #1
0
def main():
    parser = OptionParser(usage='usage: %prog [options] <scan_folder>')
    parser.add_option("-a", "--auto-tag-tail", dest="auto_tag_tail", default=False, action="store_true",
                help="Automatically add the 'leaf' folder-name to the tags")
    parser.add_option("-w", "--auto-tag-word", dest="auto_tag_words", default=[], action="append", metavar="WORD",
                help="If WORD appears anywhere as folder-name in the files path, add it to the tag list. This option can be specified as many times you want.")
    parser.add_option("-v", "--verbose", dest="verbose", default=False, action="store_true",
                help="Verbose output to stdout")
    parser.add_option("-p", "--purge", dest="purge", default=False, action="store_true",
                help="Automatically purge files from the database which have disappeared from disk.")
    parser.add_option("-q", "--quiet", dest="quiet", default=False, action="store_true",
                help="Suppresses informational messages from output (overrides -v)")
    parser.add_option("-d", "--dsn", dest="dsn",
                      help="The database DSN", default=CONF.get('database', 'dsn'))

    (options, args) = parser.parse_args()

    if options.verbose:
        CONSOLE_HANDLER.setLevel(logging.DEBUG)
    if options.quiet:
        CONSOLE_HANDLER.setLevel(logging.WARNING)

    if options.dsn:
        set_dsn(options.dsn)
    else:
        print LOG.fatal("No DSN specified!")
        return 9

    if not args:
        LOG.critical("No query specified!")
        print parser.print_usage()
        sys.exit(9)

    sess = Session()

    try:
        update_nodes_from_query(sess, args[0], None,
                options.auto_tag_tail, options.auto_tag_words, options.purge)
    except KeyboardInterrupt:
        response = raw_input("Operation cancelled by user. Commit results? [Y/n] ")
        if not response.strip() or response.strip().lower() == 'y':
            sess.commit()
            LOG.info('Successfully committed')


    sess.close()
    print "Rescan finished"
Exemple #2
0
def main():
    parser = OptionParser(usage='usage: %prog [options] <scan_folder>')
    parser.add_option("-s", "--since", dest="since", default=None,
                            help="Only scan file that changed after this date (format: YYYY-MM-DD)")
    parser.add_option("-n", "--no-insert", dest="no_insert", default=False, action='store_true',
                            help="Do not insert or update new nodes. This may be usefule if you only want to remove old entries, or calculate the md5 sums")
    parser.add_option("-p", "--purge", dest="purge", default=False, action="store_true",
                help="Remove orphans after scan. WARNING: this removes file not available on disk! If you work with removable devices, the device should be mounted and available before running this. Otherwise all files on from that device will be removed from the index!")
    parser.add_option("-m", "--md5", dest="md5", default=False, action="store_true",
                help="Calculate md5sums after scan. This can take a long time, but is necessary to detect moves & duplictates")
    parser.add_option("-a", "--auto-tag-tail", dest="auto_tag_tail", default=False, action="store_true",
                help="Automatically add the 'leaf' folder-name to the tags")
    parser.add_option("-w", "--auto-tag-word", dest="auto_tag_words", default=[], action="append", metavar="WORD",
                help="If WORD appears anywhere as folder-name in the files path, add it to the tag list. This option can be specified as many times you want.")
    parser.add_option("-v", "--verbose", dest="verbose", default=False, action="store_true",
                help="Verbose output to stdout")
    parser.add_option("-q", "--quiet", dest="quiet", default=False, action="store_true",
                help="Suppresses informational messages from output (overrides -v)")
    parser.add_option("-d", "--dsn", dest="dsn",
                      help="The database DSN", default=CONF.get('database', 'dsn'))

    (options, args) = parser.parse_args()

    if options.verbose:
        CONSOLE_HANDLER.setLevel(logging.DEBUG)
    if options.quiet:
        CONSOLE_HANDLER.setLevel(logging.WARNING)

    if options.dsn:
        set_dsn(options.dsn)
    else:
        print LOG.fatal("No DSN specified!")
        return 9

    if options.since:
        try:
            options.since = datetime.strptime(options.since, "%Y-%m-%d")
        except Exception, exc:
            LOG.error(exc)
            options.since = None
def main():
    parser = OptionParser(usage='usage: %prog [options] <scan_folder>')
    parser.add_option(
        "-s",
        "--since",
        dest="since",
        default=None,
        help="Only scan file that changed after this date (format: YYYY-MM-DD)"
    )
    parser.add_option(
        "-n",
        "--no-insert",
        dest="no_insert",
        default=False,
        action='store_true',
        help=
        "Do not insert or update new nodes. This may be usefule if you only want to remove old entries, or calculate the md5 sums"
    )
    parser.add_option(
        "-p",
        "--purge",
        dest="purge",
        default=False,
        action="store_true",
        help=
        "Remove orphans after scan. WARNING: this removes file not available on disk! If you work with removable devices, the device should be mounted and available before running this. Otherwise all files on from that device will be removed from the index!"
    )
    parser.add_option(
        "-m",
        "--md5",
        dest="md5",
        default=False,
        action="store_true",
        help=
        "Calculate md5sums after scan. This can take a long time, but is necessary to detect moves & duplictates"
    )
    parser.add_option(
        "-a",
        "--auto-tag-tail",
        dest="auto_tag_tail",
        default=False,
        action="store_true",
        help="Automatically add the 'leaf' folder-name to the tags")
    parser.add_option(
        "-w",
        "--auto-tag-word",
        dest="auto_tag_words",
        default=[],
        action="append",
        metavar="WORD",
        help=
        "If WORD appears anywhere as folder-name in the files path, add it to the tag list. This option can be specified as many times you want."
    )
    parser.add_option("-v",
                      "--verbose",
                      dest="verbose",
                      default=False,
                      action="store_true",
                      help="Verbose output to stdout")
    parser.add_option(
        "-q",
        "--quiet",
        dest="quiet",
        default=False,
        action="store_true",
        help="Suppresses informational messages from output (overrides -v)")
    parser.add_option("-d",
                      "--dsn",
                      dest="dsn",
                      help="The database DSN",
                      default=CONF.get('database', 'dsn'))

    (options, args) = parser.parse_args()

    if options.verbose:
        CONSOLE_HANDLER.setLevel(logging.DEBUG)
    if options.quiet:
        CONSOLE_HANDLER.setLevel(logging.WARNING)

    if options.dsn:
        set_dsn(options.dsn)
    else:
        print LOG.fatal("No DSN specified!")
        return 9

    if options.since:
        try:
            options.since = datetime.strptime(options.since, "%Y-%m-%d")
        except Exception, exc:
            LOG.error(exc)
            options.since = None
Exemple #4
0
    try:
        result = result.order_by( [Node.mimetype != 'other/directory', Node.uri ] )
    except Exception, exc:
        LOG.info(exc)

    if index > len(result)-1:
        return jsonify(dict(
            url = None
            ))

    return jsonify(dict(
        url = url_for('download', path=result[index].path)
        ))

@app.route("/fullscreen/<path:query>")
def fullscreen(query):
    """
    Displays an entry in a fullscreen view
    """

    return render_template("fullscreen.html",
            query = query,
            )

if __name__ == "__main__":
    app.debug = True
    logging.basicConfig(level=logging.DEBUG)
    set_dsn("postgresql://*****:*****@localhost:5432/filemeta")
    app.run(host="0.0.0.0", port=8181, threaded=True)
Exemple #5
0
def main():
    parser = OptionParser(usage='usage: %prog [options] <scan_folder>')
    parser.add_option(
        "-a",
        "--auto-tag-tail",
        dest="auto_tag_tail",
        default=False,
        action="store_true",
        help="Automatically add the 'leaf' folder-name to the tags")
    parser.add_option(
        "-w",
        "--auto-tag-word",
        dest="auto_tag_words",
        default=[],
        action="append",
        metavar="WORD",
        help=
        "If WORD appears anywhere as folder-name in the files path, add it to the tag list. This option can be specified as many times you want."
    )
    parser.add_option("-v",
                      "--verbose",
                      dest="verbose",
                      default=False,
                      action="store_true",
                      help="Verbose output to stdout")
    parser.add_option(
        "-p",
        "--purge",
        dest="purge",
        default=False,
        action="store_true",
        help=
        "Automatically purge files from the database which have disappeared from disk."
    )
    parser.add_option(
        "-q",
        "--quiet",
        dest="quiet",
        default=False,
        action="store_true",
        help="Suppresses informational messages from output (overrides -v)")
    parser.add_option("-d",
                      "--dsn",
                      dest="dsn",
                      help="The database DSN",
                      default=CONF.get('database', 'dsn'))

    (options, args) = parser.parse_args()

    if options.verbose:
        CONSOLE_HANDLER.setLevel(logging.DEBUG)
    if options.quiet:
        CONSOLE_HANDLER.setLevel(logging.WARNING)

    if options.dsn:
        set_dsn(options.dsn)
    else:
        print LOG.fatal("No DSN specified!")
        return 9

    if not args:
        LOG.critical("No query specified!")
        print parser.print_usage()
        sys.exit(9)

    sess = Session()

    try:
        update_nodes_from_query(sess, args[0], None, options.auto_tag_tail,
                                options.auto_tag_words, options.purge)
    except KeyboardInterrupt:
        response = raw_input(
            "Operation cancelled by user. Commit results? [Y/n] ")
        if not response.strip() or response.strip().lower() == 'y':
            sess.commit()
            LOG.info('Successfully committed')

    sess.close()
    print "Rescan finished"