From 655681368292cdc06469ff82565992aadebe3936 Mon Sep 17 00:00:00 2001 From: Theo Chatzimichos Date: Nov 15 2017 19:24:10 +0000 Subject: bin/get_formulas.py: add argument to remove the /srv/salt symlinks --- diff --git a/bin/get_formulas.py b/bin/get_formulas.py index a7ba387..dba2e4b 100755 --- a/bin/get_formulas.py +++ b/bin/get_formulas.py @@ -71,6 +71,13 @@ def create_symlinks(DEST): os.symlink('%s/%s-formula/%s' % (DEST, formula, formula), FULL_PATH) +def remove_symlinks(): + for formula in FORMULAS.keys(): + FULL_PATH = '/srv/salt/%s' % formula + if os.path.islink(FULL_PATH): + os.unlink(FULL_PATH) + + def fetch_remote(remote, formula): from pygit2.errors import GitError import pygit2 @@ -158,6 +165,7 @@ parser.add_argument('-c', '--clone', action='store_true', help='Clone the formul parser.add_argument('--clone-from', nargs=1, help='Specify the git provider to clone from together with the namespace.') parser.add_argument('--clone-branch', nargs=1, help='Specify the branch to clone.') parser.add_argument('-s', '--symlink', action='store_true', help='Creates symlink from the specified destination to /srv/salt.') +parser.add_argument('--remove-symlinks', action='store_true', help='Removes all symlinks that were created in /srv/salt.') parser.add_argument('-r', '--add-remote', action='append', nargs='+', help='''Add the specified remotes on the local repositories. It can be passed multiple times. Usage: REMOTE_NAME USE_PREFIXES [GIT_PROVIDER_URL] [NAMESPACE]. - REMOTE is string @@ -180,6 +188,10 @@ if args.pull_requests: will_run = True check_open_pull_requests() +if args.remove_symlinks: + will_run = True + remove_symlinks() + # Every option below requires the --destination argument to be set if args.clone or args.symlink or args.clone_from or args.clone_branch or args.add_remote or args.update or args.push: will_run = True