def main():
    options = parse_options()

    logging.basicConfig(level=options.loglevel, format="%(name)s: %(message)s")

    tracker = tinyarchive.tracker.Tracker(options.tracker)

    for task in tracker.admin_list():
        prefix = os.path.join(options.output_directory, task["id"])
        if os.path.exists(prefix + ".json") or os.path.exists(prefix + ".txt.gz"):
            raise Exception("Target file already exists for task %s" % task["id"])

        with open(prefix + ".json", "w") as fileobj:
            json.dump(task, fileobj, sort_keys=True, indent=4)
        with open(prefix + ".txt.gz", "w") as fileobj:
            fileobj.write(tracker.admin_fetch(task))

        tracker.admin_delete(task)

    if options.cleanup:
        tracker.admin_cleanup()
def main():
    options = parse_options()

    logging.basicConfig(level=options.loglevel, format="%(name)s: %(message)s")

    tracker = tinyarchive.tracker.Tracker(options.tracker)

    for task in tracker.admin_list():
        prefix = os.path.join(options.output_directory, task["id"])
        if os.path.exists(prefix + ".json") or os.path.exists(prefix +
                                                              ".txt.gz"):
            raise Exception("Target file already exists for task %s" %
                            task["id"])

        with open(prefix + ".json", "w") as fileobj:
            json.dump(task, fileobj, sort_keys=True, indent=4)
        with open(prefix + ".txt.gz", "w") as fileobj:
            fileobj.write(tracker.admin_fetch(task))

        tracker.admin_delete(task)

    if options.cleanup:
        tracker.admin_cleanup()
Exemple #3
0
#!/usr/bin/env python

# TinyArchive - A tiny web archive
# Copyright (C) 2012 David Triendl
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import json
import uuid

import tinyarchive.tracker

tracker = tinyarchive.tracker.Tracker("http://tracker.tinyarchive.org/v1/")
tracker.admin_cleanup()