Commit 231555df authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

RF: Re-organise code into more formal package structure

parent 40ceedb9
#!/usr/bin/env python
#
# __init__.py -
# __init__.py - Miscellaneous functions used throughout fsl_ci.
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
......
......@@ -18,7 +18,7 @@ import networkx as nx
import jinja2 as j2
import yaml
from fsl_ci_utils.gitlab_api import (http_request, download_file)
from fsl_ci.gitlab import (http_request, download_file)
def gen_recipe_path(project_path):
......
......@@ -13,7 +13,7 @@ import functools as ft
import urllib.parse as urlparse
import urllib.request as urlrequest
from fsl_ci_utils import (is_valid_project_version,
from fsl_ci import (is_valid_project_version,
USERNAME,
EMAIL)
......@@ -79,7 +79,7 @@ def parse_link_header(header, get='next'):
url = url.strip('<>')
return url
except Exception as e:
except Exception:
pass
return None
......
......@@ -15,7 +15,7 @@ import urllib.error as urlerror
import yaml
from fsl_ci_utils.gitlab_api import (get_project_metadata,
from fsl_ci.gitlab import (get_project_metadata,
set_project_metadata,
list_project_branches,
download_file,
......@@ -28,7 +28,7 @@ from fsl_ci_utils.gitlab_api import (get_project_metadata,
protect_branch,
open_merge_request,
trigger_pipeline)
from fsl_ci_utils.conda import is_standard_recipe_path
from fsl_ci.conda import is_standard_recipe_path
SERVER_URL = 'https://git.fmrib.ox.ac.uk'
......@@ -152,10 +152,12 @@ def set_variables(project_path,
if project_path is not None:
create_or_update_variable(
project_path, server, token, 'FSL_CI_API_TOKEN', ci_token, masked=True)
project_path, server, token, 'FSL_CI_API_TOKEN',
ci_token, masked=True)
if recipe_path is not None:
create_or_update_variable(
recipe_path, server, token, 'FSL_CI_API_TOKEN', ci_token, masked=True)
recipe_path, server, token, 'FSL_CI_API_TOKEN',
ci_token, masked=True)
create_or_update_variable(
recipe_path, server, token, 'FSLCONDA_RECIPE', 1)
......
......@@ -17,19 +17,19 @@ from unittest import mock
import jinja2 as j2
from fsl_ci_utils import (USERNAME,
from fsl_ci import (USERNAME,
EMAIL,
indir,
tempdir,
sprun)
from fsl_ci_utils.gitlab_api import (project_exists,
from fsl_ci.gitlab import (project_exists,
list_project_branches,
create_repository,
get_project_version,
open_merge_request)
from fsl_ci_utils.conda import gen_recipe_path
from fsl_ci.conda import gen_recipe_path
import fsl_project_dependencies as fsldeps
import fsl_ci.utils.fsl_project_dependencies as fsldeps
SERVER_URL = 'https://git.fmrib.ox.ac.uk'
......@@ -368,7 +368,8 @@ def create_cpp_recipe_template(project_path,
meta = {
'template_name' : recipe_name,
'template_repository' : gen_repository_url(project_path, server),
'template_repository' : gen_repository_url(project_path,
server),
'template_recipe_repository' : gen_repository_url(recipe_path, server),
'exes' : exes
......
......@@ -14,7 +14,7 @@ import sys
import shlex
import shutil
from fsl_ci_utils import (tempdir, indir)
from fsl_ci import (tempdir, indir)
DEPENDENCY_REPLACEMENTS = {
......
......@@ -22,15 +22,14 @@ import argparse
import itertools as it
import urllib.parse as urlparse
from fsl_ci_utils.gitlab_api import (get_projects_in_namespace,
from fsl_ci.gitlab import (get_projects_in_namespace,
download_file,
lookup_project_tags,
get_divergence)
from fsl_ci_utils.conda import (Package,
from fsl_ci.conda import (Package,
load_meta_yaml,
get_channel_packages,
load_packages_from_recipe_repositories,
build_dependency_graph)
load_packages_from_recipe_repositories)
SERVER_URL = 'https://git.fmrib.ox.ac.uk'
......@@ -111,7 +110,7 @@ def get_project_info(project_repo, server, token):
if len(tags) > 0: tag = tags[0]
else: tag = MISSING
# the project repo is probably not on gitlab (e.g. on github)
except Exception as e:
except Exception:
pass
return {
......
......@@ -13,7 +13,7 @@ import textwrap as tw
import sys
import argparse
from fsl_ci_utils.gitlab_api import (create_or_update_variable,
from fsl_ci.gitlab import (create_or_update_variable,
delete_variable)
......
......@@ -14,8 +14,8 @@ import argparse
import multiprocessing.dummy as mp
import fsl_ci_utils.gitlab_api as gitlab
from fsl_ci_utils.gitlab_api import (trigger_job,
import fsl_ci.gitlab as gitlab
from fsl_ci.gitlab import (trigger_job,
find_latest_job,
trigger_pipeline,
wait_on_pipeline)
......@@ -41,8 +41,9 @@ def trigger_build(project, server, token, production):
variables = {'STAGING' : 'true'}
try:
pipeline = trigger_pipeline(project, 'master', server, token, variables)
except:
pipeline = trigger_pipeline(
project, 'master', server, token, variables)
except Exception:
return None
pid = pipeline['id']
......@@ -52,7 +53,7 @@ def trigger_build(project, server, token, production):
try:
status = wait_on_pipeline(project, pid, server, token)
except:
except Exception:
return None
print(f'Build pipeline for {project} has finished: {status}')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment