import os from subprocess import call from gitlab import Gitlab # Register a connection to a gitlab instance, using its URL and a user private token gl = Gitlab('http://gitlab.example.com', 'dasidIOsOJISI092812ihas') groupsToSkip = ['youDontWantThisGroup'] gl.auth() # Connect to get the current user gitBasePathRelative = "git/" gitBasePathRelativeAbsolut = os.path.expanduser("~/" + gitBasePathRelative) os.makedirs(gitBasePathRelativeAbsolut,exist_ok=True) for p in gl.projects.list(all=True): if not any(p.namespace.path in s for s in groupsToSkip): pathToFolder = gitBasePathRelative + p.namespace.name + "/" + p.name commandArray = ["mr", "config", pathToFolder, "checkout=git clone '" + p.ssh_url_to_repo + "' '" + p.name + "'"] call(commandArray) os.chdir(gitBasePathRelativeAbsolut) call(["mr", "update"])