-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from elixir-europe/refactor_cli
Refactor cli
- Loading branch information
Showing
16 changed files
with
2,677 additions
and
1,729 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 |
---|---|---|
|
@@ -57,7 +57,7 @@ cover/ | |
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
**.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
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
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,71 @@ | ||
import configparser | ||
import pathlib | ||
|
||
|
||
def create_settings_file(settings_dir): | ||
""" | ||
Create a settings file with the specified log path and settings path. | ||
Args: | ||
settings_path (str): The path to the settings file. | ||
Returns: | ||
None | ||
""" | ||
log_path = settings_dir / "app.log" | ||
settings_path = settings_dir / "settings.ini" | ||
config = configparser.ConfigParser() | ||
config["logging"] = { | ||
"log_level": "ERROR", | ||
"log_file": log_path, | ||
"log_max_size": "1024", | ||
"log_max_files": "5", | ||
} | ||
|
||
config["webin"] = { | ||
"development-url": "https://wwwdev.ebi.ac.uk/ena/submit/webin/auth", | ||
"development-token-url": "https://wwwdev.ebi.ac.uk/ena/submit/webin/auth/token", | ||
"production-url": "https://www.ebi.ac.uk/ena/submit/webin/auth", | ||
"production-token-url": "https://www.ebi.ac.uk/ena/submit/webin/auth/token", | ||
} | ||
|
||
config["ena"] = { | ||
"development-url": "https://wwwdev.ebi.ac.uk/ena/submit/webin-v2/", | ||
"development-submission-url": "https://wwwdev.ebi.ac.uk/ena/submit/drop-box/submit/?auth=ENA", | ||
"production-url": "https://www.ebi.ac.uk/ena/submit/webin-v2/", | ||
"production-submission-url": "https://www.ebi.ac.uk/ena/submit/drop-box/submit/?auth=ENA", | ||
} | ||
|
||
config["biosamples"] = { | ||
"development-url": "https://wwwdev.ebi.ac.uk/biosamples/samples/", | ||
"development-submission-url": "https://wwwdev.ebi.ac.uk/biosamples/samples/", | ||
"production-url": "https://www.ebi.ac.uk/biosamples/samples/", | ||
"production-submission-url": "https://www.ebi.ac.uk/biosamples/samples/", | ||
} | ||
|
||
with open(settings_path, "w") as config_file: | ||
config.write(config_file) | ||
|
||
|
||
def generate_config(overwrite, mars_home_dir): | ||
""" | ||
Generate the configuration file for the MARS CLI. | ||
Returns: | ||
None | ||
""" | ||
settings_dir = ( | ||
pathlib.Path.home() / ".mars" | ||
if mars_home_dir == "HOME" | ||
else pathlib.Path(mars_home_dir) / ".mars" | ||
) | ||
|
||
if not settings_dir.exists(): | ||
settings_dir.mkdir() | ||
|
||
settings_path = settings_dir / "settings.ini" | ||
|
||
if settings_path.exists() and not overwrite: | ||
return | ||
|
||
create_settings_file(settings_dir) |
Oops, something went wrong.