Initial import 🐍

This commit is contained in:
3wc 2021-08-11 02:42:55 +02:00
commit 652cf38ffe
6 changed files with 97 additions and 0 deletions

5
README.md Normal file
View File

@ -0,0 +1,5 @@
# mailboop
Check email (IMAP) and boop snoots (Rocketchat).

0
mailboop/__init__.py Normal file
View File

39
mailboop/__main__.py Normal file
View File

@ -0,0 +1,39 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
import datetime
import os
from imap_tools import MailBox
def main():
# Server is the address of the imap server
print("connecting to imap server")
mb = MailBox(os.getenv("MAIL_SERVER"), 993).login(
os.getenv("MAIL_USER"), os.getenv("MAIL_PASSWORD")
)
# Fetch all emails
# Don't mark them as seen
# Set bulk=True to read them all into memory in one fetch
# (as opposed to in streaming which is slower but uses less memory)
print("downloading mailz")
messages = mb.fetch(limit=10, mark_seen=False,
bulk=True)
dates = [m.date for m in messages]
median_date = sorted(dates)[len(dates) // 2]
median_delta = datetime.now() - median_date.replace(tzinfo=None)
oldest_date = sorted(dates)[0]
oldest_delta = datetime.now() - oldest_date.replace(tzinfo=None)
print(f"Median email: recevied {median_date}, {median_delta} ago")
print(f"Oldest email: recevied {oldest_date}, {oldest_delta} ago")
from pdb import set_trace; set_trace()
if __name__ == "__main__":
main()

4
requirements-dev.txt Normal file
View File

@ -0,0 +1,4 @@
-r requirements.txt
black==21.7b0
flake8==3.9.2

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
rocketchat-API==1.16.0
imap-tools==0.45.0

47
setup.py Normal file
View File

@ -0,0 +1,47 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
import os
here = os.path.abspath(os.path.dirname(__file__))
README = open(os.path.join(here, 'README.md')).read()
setup(name='mailboop',
namespace_packages=['mailboop'],
version='0.0.1',
description='Check mail, boop snoots',
long_description=README,
#long_description=README + '\n\n' + CHANGES,
long_description_content_type='text/markdown',
author='3wc',
author_email='3wc.mailboop@doesthisthing.work',
# classifiers=[
# 'Programming Language :: Python',
# 'Programming Language :: Python :: 2.7',
# 'Programming Language :: Python :: 3.4',
# 'Programming Language :: Python :: 3.5',
# 'Programming Language :: Python :: 3.6',
# 'Programming Language :: Python :: 3.7',
# 'Programming Language :: Python :: 3.8',
# 'Programming Language :: Python :: Implementation :: CPython',
# 'Programming Language :: Python :: Implementation :: PyPy',
# 'Topic :: Terminals',
# 'Intended Audience :: Developers',
# 'Intended Audience :: System Administrators',
# 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
# ],
# url='https://github.com/Gandi/gandi.cli',
packages=find_packages(),
# cmdclass={'test': PyTest},
include_package_data=True,
zip_safe=False,
# install_requires=requires,
# tests_require=tests_require,
# extras_require=extras_require,
entry_points={
'console_scripts': [
'gandi = gandi.cli.__main__:main',
],
},
)