Skip to content
Merged

Dev #19

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,4 @@
> python 3.8 or later

### Architecture Diagram


* TODO
![architecture_diagram](architecture_diagram/FileAutomation.drawio.png)
85 changes: 85 additions & 0 deletions architecture_diagram/FileAutomation.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<mxfile host="app.diagrams.net" modified="2023-07-13T04:00:40.424Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.67" etag="2szSJXuQgFZ1HzYYzrte" version="21.6.2" type="google">
<diagram name="第 1 页" id="Jpz3dCIcWTPvWLjc5otT">
<mxGraphModel grid="1" page="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="u5LzlINuKhh52FWJw6I0-1" value="" style="rounded=0;whiteSpace=wrap;html=1;dashed=1;" vertex="1" parent="1">
<mxGeometry x="40" y="30" width="1070" height="1110" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-2" value="File Automation" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;" vertex="1" parent="1">
<mxGeometry x="405" y="50" width="190" height="30" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-3" value="" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="80" y="130" width="410" height="340" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-4" value="" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="80" y="660" width="410" height="340" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-5" value="Local" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;" vertex="1" parent="1">
<mxGeometry x="237.5" y="130" width="95" height="30" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-6" value="Remote" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;" vertex="1" parent="1">
<mxGeometry x="237.5" y="670" width="95" height="30" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-7" value="" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="620" y="660" width="410" height="340" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-8" value="Utils" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;" vertex="1" parent="1">
<mxGeometry x="777.5" y="670" width="95" height="30" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-9" value="Dir module" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="221.25" y="190" width="127.5" height="50" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-10" value="File module" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="221.25" y="260" width="127.5" height="50" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-11" value="Zip module" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="221.25" y="340" width="127.5" height="50" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-12" value="" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="101.25" y="700" width="368.75" height="290" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-13" value="Google drive" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;" vertex="1" parent="1">
<mxGeometry x="237.5" y="710" width="95" height="30" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-14" value="Delete module" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="120" y="750" width="127.5" height="50" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-15" value="Dir module" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="286" y="750" width="127.5" height="50" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-16" value="Download module" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="120" y="830" width="127.5" height="50" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-17" value="Search module" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="286" y="830" width="127.5" height="50" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-18" value="Share module" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="120" y="910" width="127.5" height="50" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-19" value="Upload module" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="286" y="910" width="127.5" height="50" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-20" value="Log module" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="650" y="750" width="127.5" height="50" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-21" value="Remote module" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="872.5" y="750" width="127.5" height="50" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-22" value="Executor module" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="650" y="830" width="127.5" height="50" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-23" value="Project module" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="872.5" y="830" width="127.5" height="50" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-25" value="Scheduler module" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="650" y="910" width="127.5" height="50" as="geometry" />
</mxCell>
<mxCell id="u5LzlINuKhh52FWJw6I0-27" value="File module" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="872.5" y="910" width="127.5" height="50" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
Binary file added architecture_diagram/FileAutomation.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "automation_file_dev"
version = "0.0.12"
version = "0.0.15"
authors = [
{ name = "JE-Chen", email = "zenmailman@gmail.com" },
]
Expand Down Expand Up @@ -34,4 +34,4 @@ classifiers = [
"Homepage" = "https://github.com/JE-Chen/Integration-testing-environment"

[tool.setuptools.packages]
find = { namespaces = false }
find = { namespaces = false }
16 changes: 16 additions & 0 deletions docs/.readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Optionally build your docs in additional formats such as PDF
formats:
- pdf

# Optionally set the version of Python and requirements required to build your docs
python:
version: "3.8"
install:
- requirements: docs/requirements.txt
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
5 changes: 5 additions & 0 deletions docs/source/API/api_index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FileAutomation API Documentation
----

.. toctree::
:maxdepth: 4
6 changes: 6 additions & 0 deletions docs/source/Eng/eng_index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
====================================
FileAutomation English Documentation
====================================

.. toctree::
:maxdepth: 4
6 changes: 6 additions & 0 deletions docs/source/Zh/zh_index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
====================================
FileAutomation 繁體中文 文件
====================================

.. toctree::
:maxdepth: 4
51 changes: 51 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys

sys.path.insert(0, os.path.abspath('.'))

# -- Project information -----------------------------------------------------

project = 'FileAutomation'
copyright = '2020 ~ 2023, JE-Chen'
author = 'JE-Chen'

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autosectionlabel"
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
17 changes: 17 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FileAutomation
----

.. toctree::
:maxdepth: 4


----

RoadMap

----

* Project Kanban
* https://github.com/orgs/Integration-Automation/projects/2/views/1

----
20 changes: 11 additions & 9 deletions file_automation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
from file_automation.local.dir.dir_process import copy_dir, rename_dir, create_dir, remove_dir_tree
from file_automation.local.file.file_process import copy_file, remove_file, rename_file, copy_specify_extension_file, \
copy_all_file_to_dir
from file_automation.local.dir.dir_process import copy_dir, rename_dir, create_dir, remove_dir_tree
from file_automation.local.zip.zip_process import zip_dir, zip_file, zip_info, zip_file_info, set_zip_password, \
read_zip_file, unzip_file, unzip_all

from file_automation.remote.google_drive.delete.delete_manager import drive_delete_file
from file_automation.remote.google_drive.dir.folder_manager import drive_add_folder
from file_automation.remote.google_drive.download.download_file import drive_download_file, \
drive_download_file_from_folder
from file_automation.remote.google_drive.driver_instance import driver_instance
from file_automation.remote.google_drive.search.search_drive import \
drive_search_all_file, drive_search_field, drive_search_file_mimetype
from file_automation.remote.google_drive.upload.upload_to_driver import \
drive_upload_dir_to_folder, drive_upload_to_folder, drive_upload_dir_to_drive, drive_upload_to_drive
from file_automation.remote.google_drive.dir.folder_manager import drive_add_folder
from file_automation.remote.google_drive.share.share_file import \
drive_share_file_to_anyone, drive_share_file_to_domain, drive_share_file_to_user
from file_automation.remote.google_drive.delete.delete_manager import drive_delete_file
from file_automation.remote.google_drive.download.download_file import drive_download_file, drive_download_file_from_folder
from file_automation.remote.google_drive.upload.upload_to_driver import \
drive_upload_dir_to_folder, drive_upload_to_folder, drive_upload_dir_to_drive, drive_upload_to_drive
from file_automation.utils.executor.action_executor import execute_action, execute_files, add_command_to_executor
from file_automation.utils.json.json_file import read_action_json
from file_automation.utils.file_process.get_dir_file_list import get_dir_files_as_list
from file_automation.utils.json.json_file import read_action_json
from file_automation.utils.project.create_project_structure import create_project_dir

__all__ = [
"copy_file", "rename_file", "remove_file", "copy_all_file_to_dir", "copy_specify_extension_file",
"copy_dir", "create_dir", "remove_dir_tree", "zip_dir", "zip_file", "zip_info",
Expand All @@ -25,5 +27,5 @@
"drive_upload_dir_to_folder", "drive_upload_to_folder", "drive_upload_dir_to_drive", "drive_upload_to_drive",
"drive_add_folder", "drive_share_file_to_anyone", "drive_share_file_to_domain", "drive_share_file_to_user",
"drive_delete_file", "drive_download_file", "drive_download_file_from_folder", "execute_action", "execute_files",
"add_command_to_executor", "read_action_json", "get_dir_files_as_list"
"add_command_to_executor", "read_action_json", "get_dir_files_as_list", "create_project_dir"
]
25 changes: 23 additions & 2 deletions file_automation/utils/executor/action_executor.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import builtins
import types
from inspect import getmembers, isbuiltin
from typing import Union, Any

from file_automation.local.dir.dir_process import copy_dir, create_dir, remove_dir_tree
from file_automation.local.file.file_process import copy_file, remove_file, rename_file, copy_specify_extension_file, \
copy_all_file_to_dir, create_file
from file_automation.local.zip.zip_process import zip_dir, zip_file, zip_info, zip_file_info, set_zip_password, \
read_zip_file, unzip_file, unzip_all
from file_automation.remote.google_drive.driver_instance import driver_instance
from file_automation.remote.google_drive.delete.delete_manager import drive_delete_file
from file_automation.remote.google_drive.dir.folder_manager import drive_add_folder
from file_automation.remote.google_drive.download.download_file import drive_download_file, \
drive_download_file_from_folder
from file_automation.remote.google_drive.driver_instance import driver_instance
from file_automation.remote.google_drive.search.search_drive import \
drive_search_all_file, drive_search_field, drive_search_file_mimetype
from file_automation.remote.google_drive.share.share_file import \
Expand All @@ -24,6 +25,7 @@
from file_automation.utils.json.json_file import read_action_json
from file_automation.utils.logging.loggin_instance import file_automation_logger
from file_automation.utils.package_manager.package_manager_class import package_manager
from file_automation.utils.scheduler.extend_apscheduler import scheduler_manager


class Executor(object):
Expand Down Expand Up @@ -66,10 +68,19 @@ def __init__(self):
"drive_delete_file": drive_delete_file,
"drive_download_file": drive_download_file,
"drive_download_file_from_folder": drive_download_file_from_folder,
# execute
# Execute
"execute_action": self.execute_action,
"execute_files": self.execute_files,
"add_package_to_executor": package_manager.add_package_to_executor,
# Scheduler
"scheduler_event_trigger": self.scheduler_event_trigger,
"remove_blocking_scheduler_job": scheduler_manager.remove_blocking_job,
"remove_nonblocking_scheduler_job": scheduler_manager.remove_nonblocking_job,
"start_blocking_scheduler": scheduler_manager.start_block_scheduler,
"start_nonblocking_scheduler": scheduler_manager.start_nonblocking_scheduler,
"start_all_scheduler": scheduler_manager.start_all_scheduler,
"shutdown_blocking_scheduler": scheduler_manager.shutdown_blocking_scheduler,
"shutdown_nonblocking_scheduler": scheduler_manager.shutdown_nonblocking_scheduler,
}
# get all builtin function and add to event dict
for function in getmembers(builtins, isbuiltin):
Expand Down Expand Up @@ -136,6 +147,16 @@ def execute_files(self, execute_files_list: list) -> list:
execute_detail_list.append(self.execute_action(read_action_json(file)))
return execute_detail_list

def scheduler_event_trigger(
self, function: str, id: str = None, args: Union[list, tuple] = None,
kwargs: dict = None, scheduler_type: str = "nonblocking", wait_type: str = "secondly",
wait_value: int = 1, **trigger_args: Any) -> None:
if scheduler_type == "nonblocking":
scheduler_event = scheduler_manager.nonblocking_scheduler_event_dict.get(wait_type)
else:
scheduler_event = scheduler_manager.blocking_scheduler_event_dict.get(wait_type)
scheduler_event(self.event_dict.get(function), id, args, kwargs, wait_value, **trigger_args)


executor = Executor()
package_manager.executor = executor
Expand Down
Loading