Exemple #1
0
    def handle_authorized(self, *args, **options):
        logs = options["logs"]
        config = options["config"]
        app = options["app"]

        if not logs and not config and not app:
            raise CommandError(
                "Must specify at least one of --logs, --config, or --app.")

        diff = options["diff"]
        incr = options["incr"]

        try:
            path = registry.run("backup",
                                logs=logs,
                                config=config,
                                app=app,
                                diff=diff,
                                incr=incr,
                                out_path=options.get("output"))
            self.info("Backup successful. Stored at '%s'" % path)
        except Exception as exc:
            if options.get("traceback"):
                raise
            self.error("Unable to perform backup. Error was: %s" % exc)
Exemple #2
0
    def handle_collection(self, collection, *args, **options):
        output = options["output"]
        registry.initialize()

        try:
            filename = registry.run("export",
                                    mission=collection.mission,
                                    file_type=collection.file_type,
                                    filename=output,
                                    configuration=options["configuration"],
                                    data=options["data"])
            print "Exported collection %s to %s" % (collection, filename)
        except Exception as exc:
            raise CommandError(
                "Failed to export collection %s to %s. Error was: %s" %
                (collection, options["output"], exc))
Exemple #3
0
    def handle_collection(self, collection, *args, **options):
        if not options["urls"] and not options["all"]:
            raise CommandError("No location URLs specified.")

        if options.get("all"):
            urls = collection.locations.values_list("url", flat=True)
        else:
            urls = options["urls"]

        if not urls:
            raise CommandError("No URL locations specified.")

        for url in urls:
            try:
                print "Harvesting location %s of collection %s" % (
                    collection, url
                )
                failed_retrieve, failed_ingest = registry.run(
                    "harvest",
                    mission=collection.mission,
                    file_type=collection.file_type,
                    url=url
                )
                if failed_retrieve or failed_ingest:
                    print(
                        "Harvesting of location %s failed. Failed to "
                        "retrieve: %s. Failed to ingest: %s" % (
                            url,
                            ", ".join(failed_retrieve)
                            if failed_retrieve else "none",
                            ", ".join(failed_ingest)
                            if failed_ingest else "none",
                        )
                    )
                else:
                    print(
                        "Finished harvesting location %s of collection %s." % (
                            url, collection
                        )
                    )
            except Exception as exc:
                if options.get("traceback"):
                    raise
                raise CommandError(
                    "Failed to harvest location %s. Error was: %s" % (url, exc)
                )
Exemple #4
0
    def handle_collection(self, collection, *args, **options):
        output = options["output"]
        registry.initialize()

        try:
            filename = registry.run(
                "export",
                mission=collection.mission,
                file_type=collection.file_type,
                filename=output,
                configuration=options["configuration"],
                data=options["data"],
            )
            print "Exported collection %s to %s" % (collection, filename)
        except Exception as exc:
            raise CommandError(
                "Failed to export collection %s to %s. Error was: %s" % (collection, options["output"], exc)
            )
Exemple #5
0
    def handle_authorized(self, *args, **options):
        logs = options["logs"]
        config = options["config"]
        app = options["app"]

        if not logs and not config and not app:
            raise CommandError(
                "Must specify at least one of --logs, --config, or --app."
            )

        diff = options["diff"]
        incr = options["incr"]

        try:
            path = registry.run("backup",
                logs=logs, config=config, app=app, diff=diff, incr=incr,
                out_path=options.get("output")
            )
            self.info("Backup successful. Stored at '%s'" % path)
        except Exception as exc:
            if options.get("traceback"):
                raise
            self.error("Unable to perform backup. Error was: %s" % exc)
Exemple #6
0
    def handle_authorized(self, *args, **options):
        if len(args) > 2:
            raise CommandError("Too many files specified")
        elif not args:
            raise CommandError("Missing archive filename")

        filename = args[-1]

        mission = None
        file_type = None

        if len(args) == 2:
            mission, file_type = args[0].split("/")
        try:
            collection = registry.run("import",
                                      filename=filename,
                                      mission=mission,
                                      file_type=file_type)
            print "Sucessfully imported collection %s" % collection
        except Exception as exc:
            if options.get("traceback"):
                raise
            raise CommandError("Failed to import archive '%s'. Error was: %s" %
                               (filename, exc))