old_contents: # -*- coding: utf-8 -*-
  u"""setup development directory
  
  :copyright: Copyright (c) 2020 RadiaSoft LLC.  All Rights Reserved.
  :license: http://www.apache.org/licenses/LICENSE-2.0.html
  """
  from __future__ import absolute_import, division, print_function
  from pykern.pkcollections import PKDict
  from pykern.pkdebug import pkdc, pkdlog, pkdp
  from pykern import pkconfig
  from pykern import pkio
  import pathlib
  
  
  def default_command():
      global cfg
  
      assert pkconfig.channel_in('dev'), \
          'Only to be used in dev. channel={}'.format(pkconfig.cfg.channel)
      cfg = pkconfig.init(
          proprietary_code_uri=(
              f'file://{pathlib.Path.home()}/src/radiasoft/rsconf/rpm',
              str,
              'root uri of RPMs',
          ),
      )
      _proprietary_codes()
  
  
  def _proprietary_codes():
      """Get proprietary RPMs and put it in the proprietary code dir
  
      Args:
        uri (str): where to get RPM (file:// or http://)
      """
      import urllib.request
      import sirepo.feature_config
      import sirepo.srdb
      import sirepo.sim_data
  
      for s in sirepo.feature_config.cfg().proprietary_sim_types:
          d = sirepo.srdb.proprietary_code_dir(s)
          if d.exists():
              continue
          urllib.request.urlretrieve(
              # POSIT: download/installers/rpm-code/dev-build.sh
              f'{cfg.proprietary_code_uri}/rscode-{s}-dev.rpm',
              pkio.mkdir_parent(d).join(
                  sirepo.sim_data.get_class(s).proprietary_code_rpm(),
              ),
          )
  
new_contents: # -*- coding: utf-8 -*-
  u"""setup development directory
  
  :copyright: Copyright (c) 2020 RadiaSoft LLC.  All Rights Reserved.
  :license: http://www.apache.org/licenses/LICENSE-2.0.html
  """
  from __future__ import absolute_import, division, print_function
  from pykern.pkcollections import PKDict
  from pykern.pkdebug import pkdc, pkdlog, pkdp
  from pykern import pkconfig
  from pykern import pkio
  import pathlib
  
  
  def default_command():
      global cfg
  
      assert pkconfig.channel_in('dev'), \
          'Only to be used in dev. channel={}'.format(pkconfig.cfg.channel)
      cfg = pkconfig.init(
          proprietary_code_uri=(
              f'file://{pathlib.Path.home()}/src/radiasoft/rsconf/rpm',
              str,
              'root uri of RPMs',
          ),
      )
      _proprietary_codes()
  
  
  def _proprietary_codes():
      """Get proprietary RPMs and put it in the proprietary code dir
  
      Args:
        uri (str): where to get RPM (file:// or http://)
      """
      import sirepo.feature_config
      import sirepo.sim_data
      import sirepo.srdb
      import urllib.error
      import urllib.request
  
      for s in sirepo.feature_config.cfg().proprietary_sim_types:
          r = pkio.mkdir_parent(
              sirepo.srdb.proprietary_code_dir(s),
          ).join(
              sirepo.sim_data.get_class(s).proprietary_code_rpm(),
          )
          # POSIT: download/installers/rpm-code/dev-build.sh
          u = f'{cfg.proprietary_code_uri}/rscode-{s}-dev.rpm'
          try:
              urllib.request.urlretrieve(u, r)
          except urllib.error.URLError as e:
              if not isinstance(e.reason, FileNotFoundError):
                  raise
              pkdlog('uri={} not found; mocking empty rpm={}', u, r)
              pkio.write_text(
                  r,
                  'mocked by sirepo.pkcli.setup_dev',
              )
  
subject: Fix #2893 mock empty rscode-myapp-dev.rpm when not there Probably ok to do this, because setup_dev is not run automatically. The user will get an error message when it is mocked.