This repository was archived by the owner on Aug 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
84e1c09
commit 3bda893
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |