Ejemplo n.º 1
0
    def _load_workflow(self, fname_snapshot):
        stype = splittype(fname_snapshot)[0]
        if stype == "odbc":
            import pyodbc

            addr = fname_snapshot[7:]
            parsed = addr.split('&')
            try:
                odbc, table, id_, log_id = parsed[:4]
            except TypeError:
                self.warning("Invalid ODBC source format. Here is the "
                             "template: odbc://<odbc data source spec>&"
                             "<table>&<id>&<log id>[&<optional name>]\n"
                             "<table> and <log id> may be empty (\"veles\" and"
                             " <id> value will be used).")
                return None
            if not table:
                table = "veles"
            if not log_id:
                log_id = id_
            if len(parsed) > 4:
                if len(parsed) > 5:
                    self.warning("Invalid ODBC source format")
                    return None
                name = parsed[-1]
            else:
                name = None
            try:
                return SnapshotterToDB.import_(odbc, table, id_, log_id, name)
            except pyodbc.Error as e:
                self.warning(
                    "Failed to load the snapshot from ODBC source: %s", e)
                return None
        elif stype in ("http", "https"):
            try:
                self.info("Downloading %s...", fname_snapshot)
                fname_snapshot = self.snapshot_file_name = wget.download(
                    fname_snapshot, root.common.dirs.snapshots)
                print()
                sys.stdout.flush()
            except:
                self.exception("Failed to fetch the snapshot at \"%s\"",
                               fname_snapshot)
                return None
        try:
            return SnapshotterToFile.import_(fname_snapshot)
        except FileNotFoundError:
            if fname_snapshot.strip() != "":
                self.warning("Workflow snapshot %s does not exist",
                             fname_snapshot)
            return None
Ejemplo n.º 2
0
    def _load_workflow(self, fname_snapshot):
        stype = splittype(fname_snapshot)[0]
        if stype == "odbc":
            import pyodbc

            addr = fname_snapshot[7:]
            parsed = addr.split('&')
            try:
                odbc, table, id_, log_id = parsed[:4]
            except TypeError:
                self.warning("Invalid ODBC source format. Here is the "
                             "template: odbc://<odbc data source spec>&"
                             "<table>&<id>&<log id>[&<optional name>]\n"
                             "<table> and <log id> may be empty (\"veles\" and"
                             " <id> value will be used).")
                return None
            if not table:
                table = "veles"
            if not log_id:
                log_id = id_
            if len(parsed) > 4:
                if len(parsed) > 5:
                    self.warning("Invalid ODBC source format")
                    return None
                name = parsed[-1]
            else:
                name = None
            try:
                return SnapshotterToDB.import_(odbc, table, id_, log_id, name)
            except pyodbc.Error as e:
                self.warning(
                    "Failed to load the snapshot from ODBC source: %s", e)
                return None
        elif stype in ("http", "https"):
            try:
                self.info("Downloading %s...", fname_snapshot)
                fname_snapshot = self.snapshot_file_name = wget.download(
                    fname_snapshot, root.common.dirs.snapshots)
                print()
                sys.stdout.flush()
            except:
                self.exception("Failed to fetch the snapshot at \"%s\"",
                               fname_snapshot)
                return None
        try:
            return SnapshotterToFile.import_(fname_snapshot)
        except FileNotFoundError:
            if fname_snapshot.strip() != "":
                self.warning("Workflow snapshot %s does not exist",
                             fname_snapshot)
            return None
Ejemplo n.º 3
0
def load_snapshot(path):
    try:
        return SnapshotterToFile.import_(path)
    except Exception as e:
        logging.critical("Failed to load the snapshot at %s", path)
        raise from_none(e)
Ejemplo n.º 4
0
def load_snapshot(path):
    try:
        return SnapshotterToFile.import_(path)
    except Exception as e:
        logging.critical("Failed to load the snapshot at %s", path)
        raise from_none(e)