Ejemplo n.º 1
0
def getRegistry():
  """ Return a dictionary of the program registry: installed-programs.json
  registered items:
    - last-update-time
    - image-id
    Still Maintaining backwards compat with format: "programName" : "last-update-time",
  """
  programRegistry = {}
  programRegistryPath = paths.getProgramRegistryPath()
  if os.path.exists(programRegistryPath):
    with open(programRegistryPath, 'r') as file_f:
      programRegistry = json.load(file_f)

  #Maintaining backwards compat: to be soon removed
  if len(programRegistry) > 0:
    firstProgramName = programRegistry.keys()[0]
    if not isinstance(programRegistry[firstProgramName], dict):
      programNewRegistry = {}
      for programName, lastUpdateTime in programRegistry.iteritems():
        programNewRegistry[programName] = {}
        programNewRegistry[programName]['last-update-time'] = lastUpdateTime
        programNewRegistry[programName]['image-id'] = dockerImages.getImageID("subuser-"+programName)
      programRegistry = programNewRegistry
      #save the new one here once and for all
      setInstalledPrograms(programRegistry)
  return programRegistry
Ejemplo n.º 2
0
def getRegistry():
    """ Return a dictionary of the program registry: installed-programs.json
  registered attributes:
    - last-update-time
    - image-id
    - installed-from

See docs/installed-programs-dot-json-file-format.md

  """
    programRegistry = {}
    programRegistryPath = paths.getProgramRegistryPath()
    if os.path.exists(programRegistryPath):
        with open(programRegistryPath, 'r') as file_f:
            programRegistry = json.load(file_f)

    #Maintaining backwards compat: to be soon removed
    if len(programRegistry) > 0:
        firstProgramName = programRegistry.keys()[0]
        if not isinstance(programRegistry[firstProgramName], dict):
            newProgramRegistry = {}
            for programName, lastUpdateTime in programRegistry.iteritems():
                newProgramRegistry[programName] = {}
                newProgramRegistry[programName][
                    'last-update-time'] = lastUpdateTime
                newProgramRegistry[programName][
                    'image-id'] = dockerImages.getImageID("subuser-" +
                                                          programName)
            programRegistry = newProgramRegistry
            #save the new one here once and for all
            setInstalledPrograms(programRegistry)
    return programRegistry
Ejemplo n.º 3
0
def setInstalledPrograms(programRegistry):
  """ Passing this file a dictionary which maps program names to registered items writes that registry to disk, overwritting the previous one.
  registered items:
    - last-update-time
    - image-id
    """
  programRegistryPath = paths.getProgramRegistryPath()
  with open(programRegistryPath, 'w') as file_f:
    json.dump(programRegistry, file_f, indent=1, separators=(',', ': '))
Ejemplo n.º 4
0
def setInstalledPrograms(programRegistry):
    """ Passing this file a dictionary which maps program names to registered items writes that registry to disk, overwritting the previous one.
  registered items:
    - last-update-time
    - image-id
    """
    programRegistryPath = paths.getProgramRegistryPath()
    with open(programRegistryPath, 'w') as file_f:
        json.dump(programRegistry, file_f, indent=1, separators=(',', ': '))