def action_save_rules(self, login, password, path, params, session):

        session = byte_to_unicode_dict(session)

        if session.get('type') == FM.Module.HOME:
            return self.get_process_data(SaveRulesLocal, {
                "login": login.decode('UTF-8'),
                "password": password.decode('UTF-8'),
                "path": path.decode("UTF-8"),
                "params": byte_to_unicode_dict(params),
                "session": session
            })
        elif session.get('type') == FM.Module.FTP:
            return self.get_process_data(SaveRulesFtp, {
                "login": login.decode('UTF-8'),
                "password": password.decode('UTF-8'),
                "path": path.decode("UTF-8"),
                "params": byte_to_unicode_dict(params),
                "session": session
            })
        else:
            return self.get_process_data(SaveRulesWebDav, {
                "login": login.decode('UTF-8'),
                "password": password.decode('UTF-8'),
                "path": path.decode("UTF-8"),
                "params": byte_to_unicode_dict(params),
                "session": session
            })
    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
 def action_list_files(self, login, password, path, session):
     return self.get_process_data(ListFiles, {
         "login": login.decode('UTF-8'),
         "password": password.decode('UTF-8'),
         "path": path.decode("UTF-8"),
         "session": byte_to_unicode_dict(session)
     })
Example #4
0
 def action_init_session(self, login, password, path, session):
     return self.get_process_data(InitSession, {
         "login": login.decode('UTF-8'),
         "password": password.decode('UTF-8'),
         "path": path.decode('UTF-8') if path is not None else None,
         "session": byte_to_unicode_dict(session)
     })
Example #5
0
    def action_read_images(self, login, password, paths, session):

        return self.get_process_data(ReadImages, {
            "login": login.decode('UTF-8'),
            "password": password.decode('UTF-8'),
            "paths": byte_to_unicode_list(paths),
            "session": byte_to_unicode_dict(session)
        }, timeout=7200)
Example #6
0
    def action_make_dir(self, login, password, path, session):

        return self.get_process_data(MakeDir, {
            "login": login.decode('UTF-8'),
            "password": password.decode('UTF-8'),
            "path": path.decode("UTF-8"),
            "session": byte_to_unicode_dict(session)
        })
 def action_write_file(self, login, password, path, content, encoding, session):
     return self.get_process_data(WriteFile, {
         "login": login.decode('UTF-8'),
         "password": password.decode('UTF-8'),
         "path": path.decode("UTF-8"),
         "content": content.decode('UTF-8'),
         "encoding": encoding.decode('UTF-8'),
         "session": byte_to_unicode_dict(session)
     })
Example #8
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)
Example #9
0
    def action_rename_file(self, login, password, source_path, target_path, session):

        return self.get_process_data(RenameFile, {
            "login": login.decode('UTF-8'),
            "password": password.decode('UTF-8'),
            "source_path": source_path.decode("UTF-8"),
            "target_path": target_path.decode("UTF-8"),
            "session": byte_to_unicode_dict(session)
        })
    def action_upload_file(self, login, password, path, file_path, overwrite, session):

        return self.get_process_data(UploadFile, {
            "login": login.decode('UTF-8'),
            "password": password.decode('UTF-8'),
            "path": path.decode('UTF-8'),
            "file_path": file_path.decode('UTF-8'),
            "overwrite": overwrite,
            "session": byte_to_unicode_dict(session)
        }, timeout=7200)
Example #11
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
Example #12
0
    def action_extract_archive(self, login, password, status_id, params, session):
        try:
            self.logger.info("FM starting subprocess worker extract_archive %s %s", pprint.pformat(status_id),
                             pprint.pformat(login))

            p = Process(target=self.run_subprocess,
                        args=(self.logger, ExtractArchive, status_id.decode('UTF-8'), FM.Action.EXTRACT_ARCHIVE, {
                            "login": login.decode('UTF-8'),
                            "password": password.decode('UTF-8'),
                            "params": byte_to_unicode_dict(params),
                            "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
    def action_read_rules(self, login, password, path, session):

        session = byte_to_unicode_dict(session)

        if session.get('type') == FM.Module.HOME:
            return self.get_process_data(ReadRulesLocal, {
                "login": login.decode('UTF-8'),
                "password": password.decode('UTF-8'),
                "path": path.decode("UTF-8"),
                "session": session
            })
        else:
            return self.get_process_data(ReadRulesFtp, {
                "login": login.decode('UTF-8'),
                "password": password.decode('UTF-8'),
                "path": path.decode("UTF-8"),
                "session": session
            })
Example #14
0
    def action_find_files(self, login, password, status_id, params):
        try:
            self.logger.info("FM starting subprocess worker find_files %s %s", pprint.pformat(status_id),
                             pprint.pformat(login))

            p = Process(target=self.run_subprocess,
                        args=(self.logger, FindFiles, status_id.decode('UTF-8'), FM.Action.SEARCH_FILES, {
                            "login": login.decode('UTF-8'),
                            "password": password.decode('UTF-8'),
                            "params": byte_to_unicode_dict(params)
                        }))

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

            return result
Example #15
0
    def action_analyze_size(self, login, password, status_id, path, session):
        try:
            self.logger.info("FM starting subprocess worker analyze_size %s %s", pprint.pformat(status_id),
                             pprint.pformat(login))

            p = Process(target=self.run_subprocess,
                        args=(self.logger, AnalyzeSize, status_id.decode('UTF-8'), FM.Action.ANALYZE_SIZE, {
                            "login": login.decode('UTF-8'),
                            "password": password.decode('UTF-8'),
                            "path": path.decode('UTF-8'),
                            "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
Example #16
0
    def action_remove_files(self, login, password, status_id, paths, session):
        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),
                            "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
    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
Example #18
0
 def action_save_settings(self, login, password, params):
     return self.get_process_data(SaveSettings, {
         "login": login.decode('UTF-8'),
         "password": password.decode('UTF-8'),
         "params": byte_to_unicode_dict(params)
     })
Example #19
0
 def action_open_terminal(self, login, password, session):
     return self.get_process_data(OpenTerminal, {
         "login": login.decode('UTF-8'),
         "password": password.decode('UTF-8'),
         "session": byte_to_unicode_dict(session)
     })