Ejemplo n.º 1
0
    def action_create_copy(self, login, password, status_id, paths, session):
        try:
            self.logger.info("FM starting subprocess worker create_copy %s %s",
                             pprint.pformat(status_id), pprint.pformat(login))

            p = Process(target=self.run_subprocess,
                        args=(self.logger, CreateCopy,
                              status_id.decode('UTF-8'), FM.Action.CREATE_COPY,
                              {
                                  "login": login.decode('UTF-8'),
                                  "password": password.decode('UTF-8'),
                                  "paths": byte_to_unicode_list(paths),
                                  "session": byte_to_unicode_dict(session)
                              }))

            p.start()
            return {"error": False}

        except Exception as e:
            result = {
                "error": True,
                "message": str(e),
                "traceback": traceback.format_exc()
            }

            return result
Ejemplo n.º 2
0
    def action_read_images(self, login, password, paths):

        return self.get_process_data(ReadImages, {
            "login": login.decode('UTF-8'),
            "password": password.decode('UTF-8'),
            "paths": byte_to_unicode_list(paths),
        }, timeout=7200)
Ejemplo n.º 3
0
    def action_read_images(self, login, password, paths):

        return self.get_process_data(ReadImages, {
            "login": login.decode('UTF-8'),
            "password": password.decode('UTF-8'),
            "paths": byte_to_unicode_list(paths),
        }, timeout=7200)
Ejemplo n.º 4
0
    def action_download_files(self, login, password, paths, mode):

        return self.get_process_data(DownloadFiles, {
            "login": login.decode('UTF-8'),
            "password": password.decode('UTF-8'),
            "paths": byte_to_unicode_list(paths),
            "mode": mode.decode('UTF-8')
        }, timeout=7200)
Ejemplo n.º 5
0
    def action_copy_files(self, login, password, status_id, source, target,
                          paths, overwrite):
        try:
            self.logger.info("FM starting subprocess worker copy_files %s %s",
                             pprint.pformat(status_id), pprint.pformat(login))

            source = byte_to_unicode_dict(source)
            target = byte_to_unicode_dict(target)

            params = {
                "login": login.decode('UTF-8'),
                "password": password.decode('UTF-8'),
                "source": source,
                "target": target,
                "paths": byte_to_unicode_list(paths),
                "overwrite": overwrite
            }

            if source.get('type') == FM.Module.HOME and target.get(
                    'type') == FM.Module.HOME:
                self.logger.debug("params=%s" % params)
                p = Process(target=self.run_subprocess,
                            args=(self.logger, CopyLocal,
                                  status_id.decode('UTF-8'), FM.Action.COPY,
                                  params))
            elif source.get('type') == FM.Module.HOME and target.get(
                    'type') == FM.Module.FTP:
                p = Process(target=self.run_subprocess,
                            args=(self.logger, CopyToFtp,
                                  status_id.decode('UTF-8'), FM.Action.COPY,
                                  params))
            elif source.get('type') == FM.Module.HOME and target.get(
                    'type') == FM.Module.SFTP:
                p = Process(target=self.run_subprocess,
                            args=(self.logger, CopyToSftp,
                                  status_id.decode('UTF-8'), FM.Action.COPY,
                                  params))
            elif source.get('type') == FM.Module.HOME and target.get(
                    'type') == FM.Module.WEBDAV:
                p = Process(target=self.run_subprocess,
                            args=(self.logger, CopyToWebDav,
                                  status_id.decode('UTF-8'), FM.Action.COPY,
                                  params))
            else:
                raise Exception(
                    "Unable to get worker for these source and target")

            p.start()
            return {"error": False}

        except Exception as e:
            result = {
                "error": True,
                "message": str(e),
                "traceback": traceback.format_exc()
            }

            return result
Ejemplo n.º 6
0
    def action_download_files(self, login, password, paths, mode, session):

        return self.get_process_data(DownloadFiles, {
            "login": login.decode('UTF-8'),
            "password": password.decode('UTF-8'),
            "paths": byte_to_unicode_list(paths),
            "mode": mode.decode('UTF-8'),
            "session": byte_to_unicode_dict(session)
        }, timeout=7200)
Ejemplo n.º 7
0
    def action_download_files(self, login, password, paths, mode):

        params = {
            "login": login.decode('UTF-8'),
            "password": password.decode('UTF-8'),
            "paths": byte_to_unicode_list(paths),
            "mode": mode.decode('UTF-8'),
        }

        return self.get_process_data(DownloadFiles, params, timeout=7200)
Ejemplo n.º 8
0
    def action_copy_files(self, login, password, status_id, source, target, paths, overwrite):
        try:
            self.logger.info("FM starting subprocess worker copy_files %s %s source=%s target=%", pprint.pformat(status_id),
                             pprint.pformat(login))

            self.logger.info("source before %s" % source)

            source = byte_to_unicode_dict(source)
            target = byte_to_unicode_dict(target)

            self.logger.info("source after %s" % source)

            params = {
                "login": login.decode('UTF-8'),
                "password": password.decode('UTF-8'),
                "source": source,
                "target": target,
                "paths": byte_to_unicode_list(paths),
                "overwrite": overwrite
            }

            if source.get('type') == FM.Module.WEBDAV and target.get('type') == FM.Module.HOME:
                p = Process(target=self.run_subprocess,
                            args=(self.logger, CopyFromWebDav, status_id.decode('UTF-8'), FM.Action.COPY, params))
            elif source.get('type') == FM.Module.WEBDAV and target.get('type') == FM.Module.FTP:
                p = Process(target=self.run_subprocess,
                            args=(self.logger, CopyFromWebDavToFtp, status_id.decode('UTF-8'), FM.Action.COPY, params))
            elif source.get('type') == FM.Module.WEBDAV and target.get('type') == FM.Module.SFTP:
                p = Process(target=self.run_subprocess,
                            args=(self.logger, CopyFromWebDavToSftp, status_id.decode('UTF-8'), FM.Action.COPY, params))
            elif (source.get('type') == FM.Module.WEBDAV and target.get('type') == FM.Module.WEBDAV) and (
                        source.get('server_id') == target.get('server_id')):
                p = Process(target=self.run_subprocess,
                            args=(self.logger, CopyWebDav, status_id.decode('UTF-8'), FM.Action.COPY, params))
            elif (source.get('type') == FM.Module.WEBDAV and target.get('type') == FM.Module.WEBDAV) and (
                        source.get('server_id') != target.get('server_id')):
                p = Process(target=self.run_subprocess,
                            args=(self.logger, CopyBetweenWebDav, status_id.decode('UTF-8'), FM.Action.COPY, params))
            else:
                raise Exception("Unable to get worker for these source and target")

            p.start()
            return {"error": False}

        except Exception as e:
            result = {
                "error": True,
                "message": str(e),
                "traceback": traceback.format_exc()
            }

            return result
Ejemplo n.º 9
0
    def action_move_files(self, login, password, status_id, source, target, paths, overwrite):
        try:
            self.logger.info("FM starting subprocess worker move_files %s %s", pprint.pformat(status_id),
                             pprint.pformat(login))

            source = byte_to_unicode_dict(source)
            target = byte_to_unicode_dict(target)

            params = {
                "login": login.decode('UTF-8'),
                "password": password.decode('UTF-8'),
                "source": source,
                "target": target,
                "paths": byte_to_unicode_list(paths),
                "overwrite": overwrite
            }

            if source.get('type') == FM.Module.HOME and target.get('type') == FM.Module.HOME:
                p = Process(target=self.run_subprocess,
                            args=(self.logger, MoveLocal, status_id.decode('UTF-8'), FM.Action.MOVE, params))
            elif source.get('type') == FM.Module.HOME and target.get('type') == FM.Module.FTP:
                p = Process(target=self.run_subprocess,
                            args=(self.logger, MoveToFtp, status_id.decode('UTF-8'), FM.Action.MOVE, params))
            elif source.get('type') == FM.Module.HOME and target.get('type') == FM.Module.SFTP:
                p = Process(target=self.run_subprocess,
                            args=(self.logger, MoveToSftp, status_id.decode('UTF-8'), FM.Action.MOVE, params))
            elif source.get('type') == FM.Module.HOME and target.get('type') == FM.Module.WEBDAV:
                p = Process(target=self.run_subprocess,
                            args=(self.logger, MoveToWebDav, status_id.decode('UTF-8'), FM.Action.MOVE, params))
            else:
                raise Exception("Unable to get worker for these source and target")

            p.start()
            return {"error": False}

        except Exception as e:
            result = {
                "error": True,
                "message": str(e),
                "traceback": traceback.format_exc()
            }

            return result
Ejemplo n.º 10
0
    def action_remove_files(self, login, password, status_id, paths):
        try:
            self.logger.info("FM starting subprocess worker remove_files %s %s", pprint.pformat(status_id),
                             pprint.pformat(login))

            p = Process(target=self.run_subprocess,
                        args=(self.logger, RemoveFiles, status_id.decode('UTF-8'), FM.Action.REMOVE, {
                            "login": login.decode('UTF-8'),
                            "password": password.decode('UTF-8'),
                            "paths": byte_to_unicode_list(paths)
                        }))
            p.start()
            return {"error": False}
        except Exception as e:
            result = {
                "error": True,
                "message": str(e),
                "traceback": traceback.format_exc()
            }

            return result
Ejemplo n.º 11
0
    def action_remove_files(self, login, password, status_id, paths):
        try:
            self.logger.info("FM starting subprocess worker remove_files %s %s", pprint.pformat(status_id),
                             pprint.pformat(login))

            p = Process(target=self.run_subprocess,
                        args=(self.logger, RemoveFiles, status_id.decode('UTF-8'), FM.Action.REMOVE, {
                            "login": login.decode('UTF-8'),
                            "password": password.decode('UTF-8'),
                            "paths": byte_to_unicode_list(paths)
                        }))
            p.start()
            return {"error": False}
        except Exception as e:
            result = {
                "error": True,
                "message": str(e),
                "traceback": traceback.format_exc()
            }

            return result
Ejemplo n.º 12
0
    def action_create_copy(self, login, password, status_id, paths, session):
        try:
            self.logger.info("FM starting subprocess worker create_copy %s %s", pprint.pformat(status_id),
                             pprint.pformat(login))

            p = Process(target=self.run_subprocess,
                        args=(self.logger, CreateCopy, status_id.decode('UTF-8'), FM.Action.CREATE_COPY, {
                            "login": login.decode('UTF-8'),
                            "password": password.decode('UTF-8'),
                            "paths": byte_to_unicode_list(paths),
                            "session": byte_to_unicode_dict(session)
                        }))

            p.start()
            return {"error": False}

        except Exception as e:
            result = {
                "error": True,
                "message": str(e),
                "traceback": traceback.format_exc()
            }

            return result