Skip to content

Commit

Permalink
Merge 07e90ea into dfe015b
Browse files Browse the repository at this point in the history
  • Loading branch information
ElDeveloper committed Dec 7, 2016
2 parents dfe015b + 07e90ea commit d4c3c0d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 9 deletions.
27 changes: 24 additions & 3 deletions qiita_core/configuration_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from .exceptions import MissingConfigSection

with standard_library.hooks():
from configparser import ConfigParser
from configparser import ConfigParser, Error, NoOptionError


class ConfigurationManager(object):
Expand All @@ -35,7 +35,9 @@ class ConfigurationManager(object):
base_url: str
base URL for the website, in the form http://SOMETHING.com
base_data_dir : str
Path to the base directorys where all data file are stored
Path to the base directory where all data files are stored.
log_dir : str
Path to the directory where the log files are saved.
working_dir : str
Path to the working directory
max_upload_size : int
Expand Down Expand Up @@ -118,6 +120,11 @@ class ConfigurationManager(object):
The script used to start the plugins
plugin_dir : str
The path to the directory containing the plugin configuration files
Raises
------
Error
When an option is no longer available.
"""
def __init__(self):
# If conf_fp is None, we default to the test configuration file
Expand Down Expand Up @@ -157,7 +164,21 @@ def _get_main(self, config):
self.base_data_dir = config.get('main', 'BASE_DATA_DIR') or \
default_base_data_dir

self.log_path = config.get('main', 'LOG_PATH')
try:
log_path = config.get('main', 'LOG_PATH')
if log_path:
raise Error('The option LOG_PATH in the main section is no '
'longer supported, use LOG_DIR instead.')
except NoOptionError:
pass

self.log_dir = config.get('main', 'LOG_DIR')
if self.log_dir:
# if the option is a directory, it will exist
if not isdir(self.log_dir):
raise ValueError("The LOG_DIR (%s) option is required to be a "
"directory." % self.log_dir)

self.base_url = config.get('main', 'BASE_URL')

if not isdir(self.base_data_dir):
Expand Down
5 changes: 3 additions & 2 deletions qiita_core/support_files/config_test.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
# Change to FALSE in a production system
TEST_ENVIRONMENT = TRUE

# Absolute path to write log file to. If not given, no log file will be created
LOG_PATH =
# Absolute path to the directory where log files are saved. If not given, no
# log file will be created
LOG_DIR =

# Whether studies require admin approval to be made available
REQUIRE_APPROVAL = True
Expand Down
Binary file modified qiita_core/support_files/config_test_travis.cfg.enc
Binary file not shown.
4 changes: 2 additions & 2 deletions qiita_core/tests/test_configuration_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_init(self):
self.assertEqual(obs.conf_fp, self.conf_fp)
self.assertTrue(obs.test_environment)
self.assertEqual(obs.base_data_dir, "/tmp/")
self.assertEqual(obs.log_path, "/tmp/qiita.log")
self.assertEqual(obs.log_dir, "/tmp/")
self.assertEqual(obs.base_url, "https://localhost")
self.assertEqual(obs.max_upload_size, 100)
self.assertTrue(obs.require_approval)
Expand Down Expand Up @@ -201,7 +201,7 @@ def test_get_portal(self):
TEST_ENVIRONMENT = TRUE
# Absolute path to write log file to. If not given, no log file will be created
LOG_PATH = /tmp/qiita.log
LOG_DIR = /tmp/
# Whether studies require admin approval to be made available
REQUIRE_APPROVAL = True
Expand Down
5 changes: 3 additions & 2 deletions scripts/qiita
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,9 @@ def start(port, master):
r_client.delete('qiita-usernames')
r_client.zadd('qiita-usernames', **{u: 0 for u in qdb.user.User.iter()})

if qiita_config.log_path:
options.log_file_prefix = qiita_config.log_path
if qiita_config.log_dir:
options.log_file_prefix = join(qiita_config.log_dir,
'qiita_%d.log' % port)
options.logging = 'debug'
parse_command_line()
ssl_options = {"certfile": qiita_config.certificate_file,
Expand Down

0 comments on commit d4c3c0d

Please sign in to comment.