
import os
import sys
import configparser

"""
To test the script, just export those variables and play with their values

export LAB=lab-free-electrons
export TREE=mainline
"""

config = configparser.ConfigParser()
config.read('labs.ini')

# Check if we need to stop here
if os.environ['TREE'] in config[os.environ['LAB']]['tree_blacklist'].split():
    print("Tree '%s' is blacklisted for lab '%s'" % (os.environ['TREE'], os.environ['LAB']))
    sys.exit(1)

print("Booting tree '%s' is allowed for lab '%s'" % (os.environ['TREE'], os.environ['LAB']))
sys.exit(0)



import os
import sys
import configparser

"""
To test the script, just export those variables and play with their values

export LAB=lab-free-electrons
export TREE=mainline
"""

config = configparser.ConfigParser()
config.read('labs.ini')

# Is the lab existing?
if os.environ['LAB'] not in config.sections():
    print("Unknown lab (%s). Allowing boot of %s." % (os.environ['LAB'], os.environ['TREE']))
    sys.exit(0)

# Is the tree blacklisted for this lab?
if os.environ['TREE'] in config[os.environ['LAB']]['tree_blacklist'].split():
    print("Tree '%s' is blacklisted for lab '%s'" % (os.environ['TREE'], os.environ['LAB']))
    sys.exit(1)

print("Booting tree '%s' is allowed for lab '%s'" % (os.environ['TREE'], os.environ['LAB']))
sys.exit(0)


Allow boots for unknown labs
jenkins: Allow boots for unknown labs

Signed-off-by: Florent Jacquet <692930aa2e4df70616939784b5b6c25eb1f2335c@free-electrons.com>

  
  import os
  import sys
  import configparser
  
  """
  To test the script, just export those variables and play with their values
  
  export LAB=lab-free-electrons
  export TREE=mainline
  """
  
  config = configparser.ConfigParser()
  config.read('labs.ini')
  
- # Check if we need to stop here
+ # Is the lab existing?
+ if os.environ['LAB'] not in config.sections():
+     print("Unknown lab (%s). Allowing boot of %s." % (os.environ['LAB'], os.environ['TREE']))
+     sys.exit(0)
+ 
+ # Is the tree blacklisted for this lab?
  if os.environ['TREE'] in config[os.environ['LAB']]['tree_blacklist'].split():
      print("Tree '%s' is blacklisted for lab '%s'" % (os.environ['TREE'], os.environ['LAB']))
      sys.exit(1)
  
  print("Booting tree '%s' is allowed for lab '%s'" % (os.environ['TREE'], os.environ['LAB']))
  sys.exit(0)
  
  
Allow boots for unknown labs
## Code Before:

import os
import sys
import configparser

"""
To test the script, just export those variables and play with their values

export LAB=lab-free-electrons
export TREE=mainline
"""

config = configparser.ConfigParser()
config.read('labs.ini')

# Check if we need to stop here
if os.environ['TREE'] in config[os.environ['LAB']]['tree_blacklist'].split():
    print("Tree '%s' is blacklisted for lab '%s'" % (os.environ['TREE'], os.environ['LAB']))
    sys.exit(1)

print("Booting tree '%s' is allowed for lab '%s'" % (os.environ['TREE'], os.environ['LAB']))
sys.exit(0)


## Instruction:
Allow boots for unknown labs
## Code After:

import os
import sys
import configparser

"""
To test the script, just export those variables and play with their values

export LAB=lab-free-electrons
export TREE=mainline
"""

config = configparser.ConfigParser()
config.read('labs.ini')

# Is the lab existing?
if os.environ['LAB'] not in config.sections():
    print("Unknown lab (%s). Allowing boot of %s." % (os.environ['LAB'], os.environ['TREE']))
    sys.exit(0)

# Is the tree blacklisted for this lab?
if os.environ['TREE'] in config[os.environ['LAB']]['tree_blacklist'].split():
    print("Tree '%s' is blacklisted for lab '%s'" % (os.environ['TREE'], os.environ['LAB']))
    sys.exit(1)

print("Booting tree '%s' is allowed for lab '%s'" % (os.environ['TREE'], os.environ['LAB']))
sys.exit(0)

