def set_env(user, name, value=None):
 lst = list_tab(user)
 for env in lst['env']:
  if (name == env['name']):
   if (value != env['value']):
    rm_env(user, name)
    jret = set_env(user, name, value)
    if (jret == 'new'):
     return 'updated'
    else:
     return jret
   return 'present'
 env = {'name': name, 'value': value}
 lst['env'].append(env)
 comdat = _write_cron_lines(user, _render_tab(lst))
 if comdat['retcode']:
  return comdat['stderr']
 return 'new'

def set_env ( user , name , value = None ) : lst = list_tab ( user ) for env in lst [ 'env' ] : if ( name == env [ 'name' ] ) : if ( value != env [ 'value' ] ) : rm_env ( user , name ) jret = set_env ( user , name , value ) if ( jret == 'new' ) : return 'updated' else : return jret return 'present' env = { 'name' : name , 'value' : value } lst [ 'env' ] . append ( env ) comdat = _write_cron_lines ( user , _render_tab ( lst ) ) if comdat [ 'retcode' ] : return comdat [ 'stderr' ] return 'new'
set up an environment variable in the crontab .