make packaging easier in nixland

This commit is contained in:
stupidcomputer 2024-07-11 01:48:14 -05:00
parent 55c6f3a5f8
commit 71bbd86d98
6 changed files with 67 additions and 41 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
__pycache__/
config.json
result

2
default.nix Normal file
View File

@ -0,0 +1,2 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.callPackage ./derivation.nix {}

10
derivation.nix Normal file
View File

@ -0,0 +1,10 @@
{ lib, python3Packages }:
with python3Packages;
buildPythonApplication {
pname = "groupme_sync";
version = "1.0";
propagatedBuildInputs = [ websockets requests ];
src = ./.;
}

View File

@ -0,0 +1,39 @@
from sys import argv
import json
from .groupme import GroupMe
from .emailwrap import send_email
def main() -> None:
filename = argv[1]
with open(filename, "r") as file:
data = json.loads(file.read())
chats = GroupMe(data["token"])
for message in chats:
title = "[GroupMe] {} sent a message in {}".format(message["name"], message["group_name"])
body = """
Greetings,
{} sent a message in group {} -- it reads as follows:
{}
Much regards,
the internal beepboop.systems mail system
""".format(
message["name"],
message["group_name"],
message["text"]
)
send_email(
title=title,
body=body,
smtp_server=data["smtp_server"],
smtp_username=data["smtp_username"],
smtp_password=data["smtp_password"],
from_addr=data["from_addr"],
to_addr=data["to_addr"],
)
print(message)

View File

@ -1,41 +1,4 @@
from sys import argv
import json
from .groupme import GroupMe
from .emailwrap import send_email
def main() -> None:
filename = argv[1]
with open(filename, "r") as file:
data = json.loads(file.read())
chats = GroupMe(data["token"])
for message in chats:
title = "[GroupMe] {} sent a message in {}".format(message["name"], message["group_name"])
body = """
Greetings,
{} sent a message in group {} -- it reads as follows:
{}
Much regards,
the internal beepboop.systems mail system
""".format(
message["name"],
message["group_name"],
message["text"]
)
send_email(
title=title,
body=body,
smtp_server=data["smtp_server"],
smtp_username=data["smtp_username"],
smtp_password=data["smtp_password"],
from_addr=data["from_addr"],
to_addr=data["to_addr"],
)
print(message)
from . import main
if __name__ == "__main__":
main()

11
setup.py Normal file
View File

@ -0,0 +1,11 @@
from distutils.core import setup
setup(
name="groupme_sync",
version="0.0.1",
entry_points={
'console_scripts': [
'groupme_sync = groupme_sync:main',
]
}
)