diff --git a/old_README.md b/old_README.md new file mode 100644 index 0000000..e7b1452 --- /dev/null +++ b/old_README.md @@ -0,0 +1,21 @@ +# nexus-sync + +a utility that allows you to manage your computers. + +*Main Idea* +server can send to every client "what to do". Centralized control for all clients. + +## Server-side + +- (to future) works in docker container +- accept connections on _some_ port with correct uuid from client +- works via API requests +- use _some_ database + +## Client-side + +- with _some_ period of time, send info to the server +- if server want client to execute some command + - decrease fetch time period + - execute command + - send result back to the server diff --git a/pyproject.toml b/pyproject.toml index e69de29..9437714 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -0,0 +1,28 @@ +[build-system] +requires = ["setuptools>=75.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "nexus_sync" +version = "0.1.0" +description = "A utility that allows you to manage your computers from a centralized server." +readme = "README.md" +license = { file = "LICENSE" } +requires-python = ">=3.11" +dependencies = [] + +[project.optional-dependencies] +dev = [ + "pytest>=8.0", + "black>=24.0", +] + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.black] +line-length = 100 +target-version = ["py311"] + +[tool.pytest.ini_options] +testpaths = ["tests"] diff --git a/src/nexus-sync/__init__.py b/src/nexus_sync/__init__.py similarity index 100% rename from src/nexus-sync/__init__.py rename to src/nexus_sync/__init__.py diff --git a/src/nexus-sync/client/__init__.py b/src/nexus_sync/client/__init__.py similarity index 100% rename from src/nexus-sync/client/__init__.py rename to src/nexus_sync/client/__init__.py diff --git a/src/nexus_sync/client/execute.py b/src/nexus_sync/client/execute.py new file mode 100644 index 0000000..ae21245 --- /dev/null +++ b/src/nexus_sync/client/execute.py @@ -0,0 +1,25 @@ +import shlex +import subprocess +from typing import Dict, Optional + + +def run(command: str, stdin: Optional[str] = None) -> Dict[str, str]: + process = _execute(command, stdin) + + return { + "stdout": process.stdout, + "stderr": process.stderr, + } + + +def _parse_command(command: str) -> list[str]: + # return command.split() + return shlex.split(command) + + +def _execute(command: str, stdin: Optional[str] = None) -> subprocess.CompletedProcess: + parsed_command = _parse_command(command) + result = subprocess.run( + parsed_command, input=stdin, text=True, capture_output=True, shell=True + ) + return result diff --git a/src/nexus-sync/common/__init__.py b/src/nexus_sync/common/__init__.py similarity index 100% rename from src/nexus-sync/common/__init__.py rename to src/nexus_sync/common/__init__.py diff --git a/src/nexus-sync/server/__init__.py b/src/nexus_sync/server/__init__.py similarity index 100% rename from src/nexus-sync/server/__init__.py rename to src/nexus_sync/server/__init__.py diff --git a/src/nexus_sync/server/__main__.py b/src/nexus_sync/server/__main__.py new file mode 100644 index 0000000..7b182bd --- /dev/null +++ b/src/nexus_sync/server/__main__.py @@ -0,0 +1,6 @@ +def main() -> None: + print("nexus-sync server") + + +if __name__ == "__main__": + main() diff --git a/tests/test_main.py b/tests/test_main.py new file mode 100644 index 0000000..c2f4f94 --- /dev/null +++ b/tests/test_main.py @@ -0,0 +1,7 @@ +""" +foobuzz test +""" + + +def test_foo(): + pass