<commit_before>#
# Copyright (c) 2015 ThoughtWorks, Inc.
#
# Pixelated is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pixelated is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import ConfigParser
import os

config = ConfigParser.ConfigParser()
current_dir = os.path.dirname(os.path.abspath(__file__))
config_path = os.path.join(current_dir, '..', 'config.cfg')
config.read(config_path)
dispatcher_address = config.get('staging', 'dispatcher_address')


def url_home(port=None):
    # if port is not None:
    #     return 'https://localhost:%d' % port
    # else:
    #     return 'https://localhost'
    if port is not None:
        return '%s:%d' % (dispatcher_address, port)
    else:
        return dispatcher_address


def login_url():
    return url_home(port=8080) + '/auth/login'


def logout_url():
    return url_home(port=8080) + '/auth/logout'


def signup_url():
    return url_home() + '/signup'


def behave_email():
    return config.get('staging', 'behave_email')


def behave_password():
    return config.get('staging', 'behave_password')

def behave_testuser():
    return config.get('staging', 'behave_testuser')
<commit_msg>Autodetect host from env or hostname command<commit_after>#
# Copyright (c) 2015 ThoughtWorks, Inc.
#
# Pixelated is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pixelated is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import os
import subprocess

def detect_hostname():
    if os.environ.get('TESTHOST') is not None:
        return os.environ.get('TESTHOST')
    else:
        return subprocess.check_output(['hostname', '-d']).strip()

hostname = detect_hostname()

dispatcher_address = 'https://%s' % hostname


def url_home(port=None):
    if port is not None:
        return '%s:%d' % (dispatcher_address, port)
    else:
        return dispatcher_address


def login_url():
    return url_home(port=8080) + '/auth/login'


def logout_url():
    return url_home(port=8080) + '/auth/logout'


def signup_url():
    return url_home() + '/signup'


def behave_email():
    return '%s@%s' % (behave_testuser(), hostname)


def behave_password():
    return '<PASSWORD>'


def behave_testuser():
    return 'behave-testuser'

{'fraction_non_alphanumeric': 0.10598078710876975, 'fraction_numerical': 0.008057018903005888, 'mean_word_length': 4.012422360248447, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 3, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1997728', 'n_tokens_mistral': 992, 'n_tokens_neox': 951, 'n_words': 351}