original_docstring: Check out snapshot from a json file, as specified by arguments in args.
  
      Return 0 on success, 1 on failure.
docstring: Check out snapshot from a json file, as specified by arguments in args.
  Return 0 on success, 1 on failure.
docstring_tokens: Check out snapshot from a json file as specified by arguments in args . Return 0 on success 1 on failure .
code: def checkout(args, filename):
      """Check out snapshot from a json file, as specified by arguments in args.
  
      Return 0 on success, 1 on failure."""
      LOGGER.debug('In subcommand checkout.')
      os.chdir(args.project)
      projectpath = os.getcwd()
      non_git_repos = []
  
      # open metadata.json, abort on error
      try:
          with open(filename, 'r') as metafile:
              json_object = json.load(metafile)
              LOGGER.info('Loaded json data from ' + filename)
              LOGGER.debug(json_object)
      except IOError as exc:
              LOGGER.error('Could not open file: ' + str(exc))
              return 1
  
      entry = check_for_snapshot_entry(args.name, json_object)
      if not entry:
          LOGGER.error('Snapshot entry ' + args.name + ' does not exist.')
          return 1
  
      # make sure all components have clean repos before actual operations,
      # skip non-git
      LOGGER.info('Making sure repos are clean: OF')
      os.chdir(entry['core']['path'])
      if validate_git_repo() != 0:
          LOGGER.error('OF git repo could not be validated successfully.')
          return 1
  
      LOGGER.info('Making sure repos are clean: addons')
      addons_path = os.path.join(os.getcwd(), 'addons')
      os.chdir(addons_path)
      for addon in entry['addons']:
              LOGGER.info('Processing addon ' + addon['name'])
              if addon['sha'] == 'non-git':
                  LOGGER.info('Skipping non-git addon ' + addon['name'])
                  non_git_repos.append(addon['name'])
              else:
                  os.chdir(addon['name'])
                  if validate_git_repo() != 0:
                      LOGGER.error(
                          addon['name'] +
                          ' git repo could not be validated successfully.')
                      return 1
                  os.chdir(addons_path)
  
      LOGGER.info('Checking out openFrameworks')
      LOGGER.info('Checking out ' + entry['core']['sha'] +
                  ' of ' + entry['core']['path'])
      os.chdir(projectpath)
      os.chdir(entry['core']['path'])
      # check for named refs to avoid unnecessarily detached heads
      refname = get_branchname(entry['core']['sha'])
      if subprocess.call(['git', 'checkout', refname]) != 0:
          LOGGER.error('An error occured checking out ' + entry['core']['path'])
          return 1
  
      LOGGER.info('Checking out addons')
      os.chdir(addons_path)
      for addon in entry['addons']:
              if addon['sha'] == 'non-git':
                  LOGGER.info('Skipping non-git addon ' + addon['name'])
              else:
                  LOGGER.info('Checking out ' + addon['sha'] +
                              ' of ' + addon['name'])
                  os.chdir(addon['name'])
                  # check for named refs to avoid unnecessarily detached heads
                  refname = get_branchname(addon['sha'])
                  if subprocess.call(['git', 'checkout', refname]) != 0:
                      LOGGER.error('An error occured checking out '
                                   + addon['name'])
                      return 1
                  os.chdir(addons_path)
      LOGGER.info('Finished checking out snapshot ' + entry['name'])
      if non_git_repos:
          LOGGER.warning('The following addons not under git control were ' +
                         'found. Correct code state cannot be guaranteed!')
          for item in non_git_repos:
              LOGGER.warning(str(item))
  
      return 0
code_tokens: def checkout ( args , filename ) : LOGGER . debug ( 'In subcommand checkout.' ) os . chdir ( args . project ) projectpath = os . getcwd ( ) non_git_repos = [ ] try : with open ( filename , 'r' ) as metafile : json_object = json . load ( metafile ) LOGGER . info ( 'Loaded json data from ' + filename ) LOGGER . debug ( json_object ) except IOError as exc : LOGGER . error ( 'Could not open file: ' + str ( exc ) ) return 1 entry = check_for_snapshot_entry ( args . name , json_object ) if not entry : LOGGER . error ( 'Snapshot entry ' + args . name + ' does not exist.' ) return 1 LOGGER . info ( 'Making sure repos are clean: OF' ) os . chdir ( entry [ 'core' ] [ 'path' ] ) if validate_git_repo ( ) != 0 : LOGGER . error ( 'OF git repo could not be validated successfully.' ) return 1 LOGGER . info ( 'Making sure repos are clean: addons' ) addons_path = os . path . join ( os . getcwd ( ) , 'addons' ) os . chdir ( addons_path ) for addon in entry [ 'addons' ] : LOGGER . info ( 'Processing addon ' + addon [ 'name' ] ) if addon [ 'sha' ] == 'non-git' : LOGGER . info ( 'Skipping non-git addon ' + addon [ 'name' ] ) non_git_repos . append ( addon [ 'name' ] ) else : os . chdir ( addon [ 'name' ] ) if validate_git_repo ( ) != 0 : LOGGER . error ( addon [ 'name' ] + ' git repo could not be validated successfully.' ) return 1 os . chdir ( addons_path ) LOGGER . info ( 'Checking out openFrameworks' ) LOGGER . info ( 'Checking out ' + entry [ 'core' ] [ 'sha' ] + ' of ' + entry [ 'core' ] [ 'path' ] ) os . chdir ( projectpath ) os . chdir ( entry [ 'core' ] [ 'path' ] ) refname = get_branchname ( entry [ 'core' ] [ 'sha' ] ) if subprocess . call ( [ 'git' , 'checkout' , refname ] ) != 0 : LOGGER . error ( 'An error occured checking out ' + entry [ 'core' ] [ 'path' ] ) return 1 LOGGER . info ( 'Checking out addons' ) os . chdir ( addons_path ) for addon in entry [ 'addons' ] : if addon [ 'sha' ] == 'non-git' : LOGGER . info ( 'Skipping non-git addon ' + addon [ 'name' ] ) else : LOGGER . info ( 'Checking out ' + addon [ 'sha' ] + ' of ' + addon [ 'name' ] ) os . chdir ( addon [ 'name' ] ) refname = get_branchname ( addon [ 'sha' ] ) if subprocess . call ( [ 'git' , 'checkout' , refname ] ) != 0 : LOGGER . error ( 'An error occured checking out ' + addon [ 'name' ] ) return 1 os . chdir ( addons_path ) LOGGER . info ( 'Finished checking out snapshot ' + entry [ 'name' ] ) if non_git_repos : LOGGER . warning ( 'The following addons not under git control were ' + 'found. Correct code state cannot be guaranteed!' ) for item in non_git_repos : LOGGER . warning ( str ( item ) ) return 0
short_docstring: Check out snapshot from a json file, as specified by arguments in args.
short_docstring_tokens: Check out snapshot from a json file as specified by arguments in args .
comment: """Check out snapshot from a json file, as specified by arguments in args.
  
      Return 0 on success, 1 on failure."""$SEP$# open metadata.json, abort on error$SEP$# make sure all components have clean repos before actual operations,$SEP$# skip non-git$SEP$# check for named refs to avoid unnecessarily detached heads$SEP$# check for named refs to avoid unnecessarily detached heads