Exemple #1
0
def main():
  parser = argparse.ArgumentParser(parents=[git.commands()], description='Helper to create designs')
  parser.add_argument('-doc', action='store_true', help='extended documentation in browser')
  parser.add_argument('-n', '--name', dest='name', default='', help='set design name and create structure (default name - current directory)')
  parser.add_argument('-v', '--version', dest='version', action='store_true', help='display package version')
  parser.add_argument('-tb', action = 'store_true', help = 'export project to active-hdl')
  parser.add_argument('-prog', action = 'store_true', help = 'run programmator')
  parser.add_argument('-edit', choices = ['default_build', 'toolchain'], help = 'edit default build.yaml file')
  args = parser.parse_args()

  if args.prog:
    if os.path.basename(os.getcwd()) == 'script':
      if not os.path.exists('../programmator'):
        os.mkdir('../programmator')
      os.chdir('../programmator')
    subprocess.Popen('python {}/Lib/site-packages/autohdl/programmator/programmator.py'.format(sys.prefix))
    sys.exit()

  if args.version:
    print 'autohdl version: ' + pkg_info.getVersion()
  elif args.doc:
    doc.handler('index')
  elif args.tb:
    hdlManager.kungfu()
  elif args.git:
    config = build.load()
    if not config:
      alog.info('Using default build.yaml (to see content: hdl.py -edit default_build)')
      config = build.default()
    config.update({'git':args.git})
    git.handle(config)
  elif args.edit:
    if args.edit == 'default_build':
      subprocess.Popen('notepad {}/Lib/site-packages/autohdl/data/build.yaml'.format(sys.prefix))
    elif args.edit == 'toolchain':
      subprocess.Popen('notepad {}/Lib/site-packages/autohdl_cfg/toolchain.yaml'.format(sys.prefix))
  else:
#    dsn = structure.Design(iName = args.name)
    dsn = structure.generate(path = args.name)
    git.initialize(args.name if args.name else '.')
    print dsn
Exemple #2
0
def handle(config):
  if config['git'] == 'upload':
    pathWas = os.getcwd()
    os.chdir(getGitRoot(pathWas))
    webdavSrcPath = config.get('webdavSrcPath')
    host = config.get('host')
    core = config.get('core')
    addr = 'http://{0}/{1}/{2}'.format(host, webdavSrcPath, core if core else '')
    upload('.', addr)
  elif config['git'] == 'cmd':
    gitPath = toolchain.Tool().get('git_sh')
    if gitPath:
      pathWas = os.getcwd()
      os.chdir(getGitRoot(pathWas))
      subprocess.call('{} --login -i'.format(gitPath))
#      os.chdir(pathWas)
  # pull & clone don't depend on root path
  elif config['git'] == 'pull':
    pull(config)
  elif  config['git'] == 'clone':
    clone(config)
  elif config['git'] == 'doc':
    doc.handler('git')