Skip to content
This repository was archived by the owner on Aug 25, 2022. It is now read-only.

Commit

Permalink
Package creation
Browse files Browse the repository at this point in the history
  • Loading branch information
ionutfilip committed Jan 24, 2019
1 parent 84e1c09 commit 3bda893
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
34 changes: 34 additions & 0 deletions mailustart/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import tenacity
from tenacity import retry
import logging as log
import socket
import jinja2
import os



@retry(
stop=tenacity.stop_after_attempt(100),
wait=tenacity.wait_random(min=2, max=5),
before=tenacity.before_log(log.getLogger("tenacity.retry"), log.DEBUG),
before_sleep=tenacity.before_sleep_log(log.getLogger("tenacity.retry"), log.INFO),
after=tenacity.after_log(log.getLogger("tenacity.retry"), log.DEBUG)
)

def resolve(host):
try:
hostname, port = host.split(":")
except ValueError:
hostname = host
logger = log.getLogger("resolve()")
logger.info(hostname)
ip_addr = socket.gethostbyname(hostname)
try:
return ip_addr + ":" + port
except:
return ip_addr

def convert(src, dst):
logger = log.getLogger("convert()")
logger.debug("Source: %s, Destination: %s", src, dst)
open(dst, "w").write(jinja2.Template(open(src).read()).render(**os.environ))
11 changes: 11 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from setuptools import setup

setup(name='mailustart',
version='0.1',
description='Common functions used by Mailu\'s start.py',
url='https://github.com/Mailu/MailuStart',
author='Ionut Filip',
author_email='[email protected]',
license='MIT',
packages=['mailustart'],
zip_safe=False)

0 comments on commit 3bda893

Please sign in to comment.