Skip to content
Snippets Groups Projects
Select Git revision
  • 07ebc1f4ed24d452f4675a4165a6ab6224b81a20
  • MCCS-163 default
  • main
  • sar-277-update-docs-with-examples-for-lrc
  • st-946-automate
  • sar_302-log-fix
  • sar-287_subarray_commands_to_lrc
  • sar_302-POC_await_sub_device_state
  • sat_302_fix_pipelines
  • sar-286_lrc_one_subarry_command
  • sar-286_lrc_improvements
  • sar-288-async-controller
  • sar-276-combine-tango-queue
  • sar-255_remove_nexus_reference
  • sar-275-add-LRC
  • sar-273-add-lrc-attributes
  • sar-272
  • sp-1106-marvin-1230525148-ska-tango-base
  • sp-1106-marvin-813091765-ska-tango-base
  • sar-255/Publish-package-to-CAR
  • mccs-661-device-under-test-fixture
  • mccs-659-pep257-docstring-linting
  • 0.11.3
  • 0.11.2
  • 0.11.1
  • 0.11.0
  • 0.10.1
  • 0.10.0
  • 0.9.1
  • 0.9.0
  • 0.8.1
  • 0.8.0
  • 0.7.2
  • 0.7.1
  • 0.7.0
  • 0.6.6
  • 0.6.5
  • 0.6.4
  • 0.6.3
  • 0.6.2
  • 0.6.1
  • 0.6.0
42 results

obs_device.rst

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    main.py 1.68 KiB
    from graph_creation.repo_processing import process_repos
    from neo4j import GraphDatabase
    import dotenv
    import os
    import gitlab
    import subprocess
    
    def clone_repos(repo_list: list[str], folder_name: str) -> None:
        """
        Given a list of relative paths to ASTRON GitLab repositories and the name of a folder,
        the mentioned repositories are cloned into the mentioned folder.
    
        Parameters:
        repo_list (list[str]): list of relative paths to ASTRON GitLab repositories
        folder_name (str): the name of the folder to clone the repos into
        """
        gl = gitlab.Gitlab('https://git.astron.nl')
        projects = gl.projects.list(iterator=True, get_all=True)
        for project in projects:
            repo_name = project.attributes['path_with_namespace']
            if repo_name in repo_list:
                git_url = project.ssh_url_to_repo
                subprocess.call(['git', 'clone', git_url, f'./{folder_name}/{repo_name}'])
    
    if __name__ == '__main__':
        relevant_repos = ['ldv/imaging_compress_pipeline']
        folder = 'repos'
        clone_repos(relevant_repos, folder)
    
        # Get the authentication details for Neo4j instance
        load_status = dotenv.load_dotenv("Neo4j-25ebc0db-Created-2024-11-17.txt")
        if load_status is False:
            raise RuntimeError('Environment variables not loaded.')
    
        URI = os.getenv("NEO4J_URI")
        AUTH = (os.getenv("NEO4J_USERNAME"), os.getenv("NEO4J_PASSWORD"))
    
        repo_paths = [f'{folder}/{path}' for path in relevant_repos]
        
        with GraphDatabase.driver(URI, auth=AUTH) as driver:
            driver.verify_connectivity()
            print("Connection established.")
            driver = GraphDatabase.driver(URI, auth=AUTH)
            process_repos(repo_paths, driver)
            driver.close()