initial
This commit is contained in:
commit
1601d8a300
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.idea
|
||||||
|
.idea/**
|
||||||
|
poetry.lock
|
0
app/__init__.py
Normal file
0
app/__init__.py
Normal file
5
app/logger.py
Normal file
5
app/logger.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
logging.basicConfig(format="%(asctime)s | %(name)s | %(levelname)s | %(message)s")
|
||||||
|
logger = logging.getLogger(__package__)
|
||||||
|
logger.setLevel(logging.INFO)
|
38
main.py
Normal file
38
main.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import argparse
|
||||||
|
from app.logger import logger as l
|
||||||
|
import datetime as dt
|
||||||
|
import subprocess as proc
|
||||||
|
from scheduler import Scheduler
|
||||||
|
import time
|
||||||
|
|
||||||
|
delta = dt.timedelta(hours=3)
|
||||||
|
tz_msk = dt.timezone(offset=delta, name="MSK")
|
||||||
|
|
||||||
|
logger = l.getChild(__name__)
|
||||||
|
logger.warning("Starting")
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(__name__)
|
||||||
|
parser.add_argument("d", help="Directory to watch")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
directory = args.d
|
||||||
|
|
||||||
|
logger.info(f"Directory to watch: {directory}")
|
||||||
|
|
||||||
|
|
||||||
|
def c(command: str) -> list[str]:
|
||||||
|
return command.split(" ")
|
||||||
|
|
||||||
|
def _watcher() -> None:
|
||||||
|
g_status = proc.check_output(c("git status -s"))
|
||||||
|
if g_status is not None:
|
||||||
|
proc.run(c("git add ."))
|
||||||
|
now = time.ctime()
|
||||||
|
proc.run(c(f"git commit -m '{now}'"))
|
||||||
|
proc.run(c("git fetch"))
|
||||||
|
proc.run(c("git rebase"))
|
||||||
|
|
||||||
|
|
||||||
|
schedule = Scheduler(tzinfo=tz_msk)
|
||||||
|
schedule.minutely()
|
||||||
|
schedule.daily(dt.time(hour=7, minute=5, tzinfo=tz_msk), _watcher)
|
15
pyproject.toml
Normal file
15
pyproject.toml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
[tool.poetry]
|
||||||
|
name = "git-pusher"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = ""
|
||||||
|
authors = ["bvn13 <from.github@bvn13.me>"]
|
||||||
|
readme = "README.md"
|
||||||
|
|
||||||
|
[tool.poetry.dependencies]
|
||||||
|
python = "^3.12"
|
||||||
|
scheduler = "^0.8.7"
|
||||||
|
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["poetry-core"]
|
||||||
|
build-backend = "poetry.core.masonry.api"
|
Loading…
Reference in New Issue
Block a user