From be286e9ec58c69a79a2e2e25a3aa4d25424ba704 Mon Sep 17 00:00:00 2001
From: "valentin.emiya" <valentin.emiya@lif.univ-mrs.fr>
Date: Wed, 3 Jun 2020 20:14:31 +0200
Subject: [PATCH] update CI

---
 .gitlab-ci.yml                  |  7 ++----
 python/tffpy/tests/ci_config.py | 39 +++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 5 deletions(-)
 create mode 100644 python/tffpy/tests/ci_config.py

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8a0924b..9aeec41 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -7,9 +7,7 @@ tests:
         - cd python
         - pip3 install --no-deps ltfatpy madarrays yafe skpomade pandas
         - pip3 install --no-deps .
-        - python3 -c "from tffpy.utils import generate_config; generate_config()"
-        - pwd
-        - python3 -c "from configparser import ConfigParser; from pathlib import Path; config = ConfigParser(); config.read('/root/.config/tffpy.conf'); config.set('DATA', 'data_path', '/builds/skmad-suite/tff2020/data'); config.write(open('/root/.config/tffpy.conf', 'w'))"
+        - python3 tffpy/tests/ci_confi.py
         - pytest-3
 
 # generate the documentation
@@ -24,8 +22,7 @@ pages:
         - pip3 install --no-deps ltfatpy madarrays yafe skpomade pandas
         - pip3 install --no-deps .
         - python3 setup.py build_sphinx
-        - python3 -c "from tffpy.utils import generate_config; generate_config()"
-        - python3 -c "from configparser import ConfigParser; from pathlib import Path; config = ConfigParser(); config.read('/root/.config/tffpy.conf'); config.set('DATA', 'data_path', '/builds/skmad-suite/tff2020/data'); config.write(open('/root/.config/tffpy.conf', 'w'))"
+        - python3 tffpy/tests/ci_confi.py
         - cp -r build/sphinx/html public
     artifacts:
         paths:
diff --git a/python/tffpy/tests/ci_config.py b/python/tffpy/tests/ci_config.py
new file mode 100644
index 0000000..96d4d34
--- /dev/null
+++ b/python/tffpy/tests/ci_config.py
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+"""
+    Create configuration files for continuous integration.
+
+.. moduleauthor:: Valentin Emiya
+"""
+from configparser import ConfigParser
+from pathlib import Path
+import os
+
+from yafe.utils import ConfigParser as YafeConfigParser
+
+from tffpy.utils import get_config_file, generate_config
+
+if __name__ == '__main__':
+    config_file = get_config_file()
+    if not config_file.exists():
+        generate_config()
+        config = ConfigParser()
+        config.read(config_file)
+        data_path = Path(__file__).parent.parent / 'data'
+        print('Data path:', str(data_path))
+        config.set('DATA', 'data_path', str(data_path))
+        config.write(open(config_file, 'w'))
+
+    yafe_config_file = YafeConfigParser._config_path
+    print(yafe_config_file)
+    if not yafe_config_file.exists():
+        yafe_user_path = Path(os.path.expanduser('~')) / 'yafe_user_path'
+        yafe_logger_path = Path(os.path.expanduser('~')) / 'yafe_logger_path'
+        print(yafe_user_path)
+        print(yafe_logger_path)
+        yafe_user_path.mkdir(parents=True, exist_ok=True)
+        yafe_logger_path.mkdir(parents=True, exist_ok=True)
+        YafeConfigParser.generate_config()
+        yafe_config_parser = YafeConfigParser()
+        yafe_config_parser.set('USER', 'data_path', str(yafe_user_path))
+        yafe_config_parser.set('LOGGER', 'path', str(yafe_logger_path))
+        yafe_config_parser.write(open(yafe_config_file, 'w'))
-- 
GitLab