Skip to content

Commit

Permalink
Merge pull request #35 from shlomiLan/develop
Browse files Browse the repository at this point in the history
develop
  • Loading branch information
mergify[bot] committed Feb 1, 2019
2 parents 1db7a82 + 1b02b5b commit 3a6b933
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 143 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ repos:
hooks:
- id: black
language_version: python3.7
args: [--skip-string-normalization]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v1.2.3
hooks:
Expand Down
38 changes: 22 additions & 16 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,28 @@
@task()
def init_app(c, env=None):
# Prevent execute this function more than once
if not os.environ.get('APP_SETTINGS'):
if not os.environ.get("APP_SETTINGS"):
# Load the basic configs
env_vars = load_yaml_from_file(os.path.join(BASEDIR, 'resources', 'settings.yml'))
env_vars = load_yaml_from_file(
os.path.join(BASEDIR, "resources", "settings.yml")
)

for name, data in env_vars.items():
set_env_var(c, name, data.get('value'), env, data.get('is_protected', False))
set_env_var(
c, name, data.get("value"), env, data.get("is_protected", False)
)


@task(init_app)
def run_app(c, env=None):
run(c, 'python -m tvsort_sl.app', False)
run(c, "python -m tvsort_sl.app", False)


def run(c, command, with_venv=True):
if with_venv:
command = '{} && {}'.format(get_venv_action(), command)
command = "{} && {}".format(get_venv_action(), command)

print('Running: {}'.format(command))
print("Running: {}".format(command))
c.run(command)


Expand All @@ -36,43 +40,45 @@ def set_env_var(c, name, value, env, is_protected=True):
if isinstance(value, dict):
value = json.dumps(value)

if env == 't':
if env == "t":
command = "travis env set {} '{}'".format(name, value)
if not is_protected:
command = '{} --public'.format(command)
command = "{} --public".format(command)

if command:
run(c, command, False)

else:
print(f'Set local var: {name}={value}')
print(f"Set local var: {name}={value}")
os.environ[name] = value


def load_yaml_from_file(file_path):
with open(file_path, 'r') as stream:
with open(file_path, "r") as stream:
return yaml.safe_load(stream)


def is_unix():
return os.name == 'posix'
return os.name == "posix"


def get_venv_action():
if is_unix():
return f'source {BASEDIR}/venv/bin/activate'
return f"source {BASEDIR}/venv/bin/activate"
else:
return f'{BASEDIR}\\venv\\Scripts\\activate'
return f"{BASEDIR}\\venv\\Scripts\\activate"


@task(init_app)
def test(c, cov=False, file=None):
# cov - if to use coverage, file - if to run specific file

command = 'pytest -s --disable-pytest-warnings'
command = "pytest -s -p no:warnings"
if cov:
command = '{} --cov=slots_tracker_server --cov-report term-missing'.format(command)
command = "{} --cov=slots_tracker_server --cov-report term-missing".format(
command
)
if file:
command = '{} {}'.format(command, file)
command = "{} {}".format(command, file)

run(c, command)
12 changes: 6 additions & 6 deletions tvsort_sl/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@


def send_email(subject, content):
sg = sendgrid.SendGridAPIClient(apikey=os.environ.get("SENDGRID_API_KEY"))
from_email = Email(name="TV sort", email="tvsortsl@gmail.com")
to_email = Email(name="TV sort", email="tvsortsl@gmail.com")
content = Content("text/plain", content)
sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY'))
from_email = Email(name='TV sort', email='tvsortsl@gmail.com')
to_email = Email(name='TV sort', email='tvsortsl@gmail.com')
content = Content('text/plain', content)
mail = Mail(from_email, subject, to_email, content)
sand_box = os.environ.get("SAND_BOX")
sand_box = os.environ.get('SAND_BOX')

if sand_box == "true":
if sand_box == 'true':
mail_settings = MailSettings()
mail_settings.sandbox_mode = SandBoxMode(True)
mail.mail_settings = mail_settings
Expand Down
5 changes: 0 additions & 5 deletions tvsort_sl/settings/conf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,3 @@
MOVE_FILES: True

DUMMY_FILE_NAME: 'dummy.txt'

# extensions
EXTENSIONS:
COMPRESS: ['r00', 'rar', 'zip']
GARBAGE: ['nfo', 'txt', 'db', 'pdf', 'jpg', 'png', 'srt', 'dat', 'vob', 'ds_store', 'exe']

0 comments on commit 3a6b933

Please sign in to comment.