text: import sys, os
  import subprocess
  from utilix.rundb import pymongo_collection
  import re
  import time
  import datetime
  
  _date = sys.argv[1]
  date  = datetime.datetime(int(_date[:4]), int(_date[4:6]), int(_date[6:]))
  runs  = sys.argv[2:10]
  
  print(date, runs)
  
  if len(runs) != 0:
      if len(runs) != 8:
          check = False
          raise SystemExit('Not enough runs!')
      compare = True
  else:
      compare = False
  
  coll  = pymongo_collection()
  check = False
  runs_ = [ ]
  
  for i in [0,1,2,3]:
      query = {'mode':      'tpc_commissioning_pmtgain',
               'comments':  {'$elemMatch': {'comment': re.compile(f'.*SPE_calibration_step{i}.*')}},
               'tags.name': {'$not': {'$in': ['bad', 'messy']}},
               'start':     {'$gte': date, '$lt':  date + datetime.timedelta(days=1)}
              }
      cursor = list(coll.find(query, {'number': 1}))
      if len(cursor) == 0:
          print('SPE cursor 0 so check False')
          check = False
          break;
      else:
          check = True
      for run in cursor:
          runs_.append('0'+str(run['number']))
      print('runs_: ', runs_)
  
  for i in [0,1,2,3]:
      query = {'mode':      'tpc_commissioning_pmtgain',
               'comments':  {'$elemMatch': {'comment': re.compile(f'.*Gain_calibration_step{i}.*')}},
               'tags.name': {'$not': {'$in': ['bad', 'messy']}},
               'start':     {'$gte': date, '$lt':  date + datetime.timedelta(days=1)}
              }
      cursor = list(coll.find(query, {'number': 1}))
      if len(cursor) == 0:
          print('GAIN cursor 0 so check False')
          check = False
          break;
      else:
          check = True
      for run in cursor:
          runs_.append('0'+str(run['number']))
      print('runs_: ', runs_)
      
  print('Check: ', check) 
  
  if compare:
      print('Let\'s compare: ')
      if (runs == runs_): 
          check = True
      else: 
          check = False
      print('Check: ', check)    
  
  if check: sys.exit(1)
  else: sys.exit(0)
  