当前位置: 首页>>代码示例>>Python>>正文


Python user.getRegistry函数代码示例

本文整理汇总了Python中subuserlib.classes.user.getRegistry函数的典型用法代码示例。如果您正苦于以下问题:Python getRegistry函数的具体用法?Python getRegistry怎么用?Python getRegistry使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getRegistry函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: verify

def verify(realArgs):
  options,arguments=parseCliArgs(realArgs)
  user = subuserlib.classes.user.User()
  try:
    with user.getRegistry().getLock() as LockFileHandle:
      subuserlib.verify.verify(user)
      user.getRegistry().commit()
  except subuserlib.portalocker.portalocker.LockException:
    sys.exit("Another subuser process is currently running and has a lock on the registry. Please try again later.")
开发者ID:ypid,项目名称:subuser,代码行数:9,代码来源:repair.py

示例2: describe

def describe(sysargs):
  """
  Describe subusers and images.
  
  >>> import describe #import self

  Describing a subuser prints its permissions.

  >>> describe.describe(["subuser","foo"])
  Subuser: foo
  ------------------
  Progam:
  foo:
   Description: 
   Maintainer: 
   Last update time(version): 0
   Executable: /usr/bin/foo

  Describing an image prints the default permissions for that image.

  >>> describe.describe(["image","foo"])
  foo:
   Description: 
   Maintainer: 
   Last update time(version): 0
   Executable: /usr/bin/foo

  Images can be refered to with their full paths as well.  Even remote images can be described.

  >>> describe.describe(["image","[email protected]"])
  foo:
   Description: 
   Maintainer: 
   Last update time(version): 0
   Executable: /usr/bin/foo
  """
  user = subuserlib.classes.user.User()
  (options,args) = parseCliArgs(sysargs)
  if len(args) < 2:
    print("Args: '"+"' '".join(args)+"'")
    print("Wrong number of arguments.")
    #parseCliArgs(["","subuser","describe","--help"])
  elif args[0] == "image":
    for image in args[1:]:
      subuserlib.resolve.resolveImageSource(user,image).describe()
  elif args[0] == "subuser":
    for subuser in  args[1:]:
      try:
        user.getRegistry().getSubusers()[subuser].describe()
      except KeyError:
        sys.exit("Subuser "+subuser+" does not exist.")
  else:
    print("Args: '"+"' '".join(args)+"'")
    print("Option not supported.")
开发者ID:xsongx,项目名称:subuser,代码行数:54,代码来源:describe.py

示例3: add

def add(user,name,url):
    repository = subuserlib.resolve.lookupRepositoryByURI(user,url)
    if repository:
      if type(repository.getName()) is int:
        sys.exit("A temporary repository with this url already exists.  Cannot add.  The ability to uprade temporary repositories to named repositories is a wanted feature.  Feal free to send a quality, well thought out, pull request.")
      else:
        sys.exit("The repository named:" +repository.getName()+" already has this URL.  Cannot add.")
    else:
      repository = subuserlib.classes.repository.Repository(user,name=name,gitOriginURI=url,gitCommitHash="master")
      user.getRegistry().getRepositories().addRepository(repository)
      user.getRegistry().commit()
开发者ID:marclaporte,项目名称:subuser,代码行数:11,代码来源:repository.py

示例4: run

def run(args):
    if len(args) == 1 or {"help", "-h", "--help"} & set(args):
        sys.exit(helpString)

    subuserName = args[1]
    argsToPassToImage = args[2:]

    user = subuserlib.classes.user.User()
    if subuserName in user.getRegistry().getSubusers():
        subuserlib.run.run(user.getRegistry().getSubusers()[subuserName], argsToPassToImage)
    else:
        sys.exit(subuserName + " not found.\n" + helpString)
开发者ID:marclaporte,项目名称:subuser,代码行数:12,代码来源:run.py

示例5: removeOldImages

def removeOldImages(user):
  """
  Remove images that are installed, but are not associated with any subusers.

 >>> remove_old_images = __import__("remove-old-images")#import self
 >>> import subuserlib.classes.user,subuserlib.subuser
 >>> user = subuserlib.classes.user.User()
 >>> user.getRegistry().getSubusers().keys()
 [u'foo']
 >>> subuserlib.subuser.add(user,"bar","[email protected]:///home/travis/remote-test-repo")
 Adding new temporary repository file:///home/travis/remote-test-repo
 Adding subuser bar [email protected]:///home/travis/remote-test-repo
 Verifying subuser configuration.
 Verifying registry consistency...
 Unregistering any non-existant installed images.
 Checking if images need to be updated or installed...
 Installing bar ...
 Installed new image for subuser bar
 Running garbage collector on temporary repositories...
 >>> user.getRegistry().getSubusers().keys()
 [u'foo', 'bar']
 >>> [i.getImageSourceName() for i in user.getInstalledImages().values()]
 [u'foo', u'bar']
 >>> subuserlib.subuser.remove(user,"bar")
 Removing subuser bar
  If you wish to remove the subusers image, issue the command $ subuser remove-old-images
 Verifying subuser configuration.
 Verifying registry consistency...
 Unregistering any non-existant installed images.
 Checking if images need to be updated or installed...
 Running garbage collector on temporary repositories...
 >>> [i.getImageSourceName() for i in user.getInstalledImages().values()]
 [u'foo', u'bar']
 >>> remove_old_images.removeOldImages(user)
 Verifying subuser configuration.
 Verifying registry consistency...
 Unregistering any non-existant installed images.
 Checking if images need to be updated or installed...
 Running garbage collector on temporary repositories...
 Removing uneeded temporary repository: file:///home/travis/remote-test-repo
 >>> [i.getImageSourceName() for i in user.getInstalledImages().values()]
 [u'foo']
  """
  for installedImageId,installedImage in user.getInstalledImages().iteritems():
    imageInUse = False
    for _,subuser in user.getRegistry().getSubusers().iteritems():
      if subuser.getImageId() == installedImageId:
        imageInUse = True
    if not imageInUse:
      installedImage.removeDockerImage()
  subuserlib.verify.verify(user)
  user.getRegistry().commit()
开发者ID:takluyver,项目名称:subuser,代码行数:52,代码来源:remove-old-images.py

示例6: run

def run(args):
  if len(args) == 1 or args[1] == "--help":
    print(helpString)
    sys.exit()

  subuserName = args[1]
  argsToPassToImage = args[2:]

  user = subuserlib.classes.user.User()
  if subuserName in user.getRegistry().getSubusers():
    user.getRegistry().getSubusers()[subuserName].getRuntime(os.environ).run(argsToPassToImage)
  else:
    sys.exit(subuserName + " not found.\n"+helpString)
开发者ID:akovalyov,项目名称:subuser,代码行数:13,代码来源:run.py

示例7: list

def list(sysargs):
  """
  List various things: image sources, subusers, ect.

  >>> import sys
  >>> import list #import self
  >>> list.list([sys.argv[0]]+["list","available"])
  Images available for instalation from the repo: default
  foo:
   Description: 
   Maintainer: 
   Last update time(version): 0
   Executable: /usr/bin/foo
  >>> list.list([sys.argv[0]]+["list","subusers"])
  The following subusers are registered.
  Subuser: foo
  ------------------
  Progam:
  foo:
   Description: 
   Maintainer: 
   Last update time(version): 0
   Executable: /usr/bin/foo
  >>> list.list([sys.argv[0]]+["list","subusers","--short"])
  foo
  """
  options,args = parseCliArgs(sysargs)
 
  if len(args)==0:
    sys.exit("Nothing to list. Issue this command with the -h argument for help.")
  
  user = subuserlib.classes.user.User()
  
  if 'available' in args:
    for repoName,repository in user.getRegistry().getRepositories().iteritems():
      if not options.short:
        print("Images available for instalation from the repo: " + repoName)
      for imageName,imageSource in repository.iteritems():
        if options.short:
          print(imageName)
        else:
          imageSource.describe()
  
  if 'subusers' in args:
    if not options.short:
      print("The following subusers are registered.")
    for name,subuser in user.getRegistry().getSubusers().iteritems():
      if options.short:
        print(name)
      else:
        subuser.describe()
开发者ID:takluyver,项目名称:subuser,代码行数:51,代码来源:list.py

示例8: add

def add(user,subuserName,imageSourceIdentifier):
  try:
    try:
      imageSource = subuserlib.resolve.resolveImageSource(user,imageSourceIdentifier)
    except KeyError as keyError:
      sys.exit("Could not add subuser.  The image source "+imageSourceIdentifier+" does not exist.")
    user.getRegistry().logChange("Adding subuser "+subuserName+" "+imageSourceIdentifier)
    user.getRegistry().getSubusers()[subuserName] = subuserlib.classes.subuser.Subuser(user,subuserName,imageSource,None,False)
    subuserlib.verify.verify(user)
    user.getRegistry().commit()
  except subuserlib.classes.dockerDaemon.ImageBuildException as e:
    print("Adding subuser failed.")
    print(str(e))
    subuserlib.update.checkoutNoCommit(user,"HEAD")
开发者ID:takluyver,项目名称:subuser,代码行数:14,代码来源:subuser.py

示例9: setExecutableShortcutInstalled

def setExecutableShortcutInstalled(user,subuserName,installed):
  if installed:
    user.getRegistry().logChange("Creating shortcut for subuser "+subuserName)
  else:
    user.getRegistry().logChange("Removing shortcut for subuser "+subuserName)
  user.getRegistry().getSubusers()[subuserName].setExecutableShortcutInstalled(installed)
  subuserlib.verify.verify(user)
  user.getRegistry().commit()
开发者ID:takluyver,项目名称:subuser,代码行数:8,代码来源:subuser.py

示例10: run

def run(args):
    if len(args) == 1 or args[1] == "-h" or args[1] == "--help":
        print(helpString)
        sys.exit()

    subuserName = args[1]
    argsToPassToImage = args[2:]

    user = subuserlib.classes.user.User()
    user.getRegistry().setLogOutputVerbosity(0)
    if subuserName in user.getRegistry().getSubusers():
        runtime = user.getRegistry().getSubusers()[subuserName].getRuntime(os.environ)
        if runtime:
            runtime.run(argsToPassToImage)
        else:
            sys.exit(
                "The subuser's image failed to build. Please use the subuser update log and subuser repair commands for more information."
            )
    else:
        sys.exit(subuserName + " not found.\n" + helpString)
开发者ID:peter1000,项目名称:subuser,代码行数:20,代码来源:run.py

示例11: dryRun

def dryRun(args):
  """
  Print the command that would have been run if this wasn't a dry run.

  >>> dry_run = __import__("dry-run")
  >>> dry_run.dryRunTestSetup()
  >>> dry_run.dryRun([sys.argv[0]]+["foo"])
  docker 'run' '-i' '-t' '--rm' '--workdir=/home/travis/test-home' '-v=/home/travis/test-home/.subuser/homes/foo:/home/travis/test-home:rw' '-e' 'HOME=/home/travis/test-home' '--net=none' '--user=1000' '1' '/usr/bin/foo'
  """
  if len(args) == 1 or {"help","-h","--help"} & set(args):
    sys.exit(helpString)

  subuserName = args[1]
  argsToPassToImage = args[2:]

  user = subuserlib.classes.user.User()
  if subuserName in user.getRegistry().getSubusers():
    print(subuserlib.run.getPrettyCommand(user.getRegistry().getSubusers()[subuserName],argsToPassToImage))
  else:
    sys.exit(subuserName + " not found.\n"+helpString)
开发者ID:marclaporte,项目名称:subuser,代码行数:20,代码来源:dry-run.py

示例12: runCommand

def runCommand(sysargs):
  """
  Describe subusers and images.
  """
  user = subuserlib.classes.user.User()
  (options,args) = parseCliArgs(sysargs)
  if len(args) < 2:
    subuserlib.print.printWithoutCrashing("Nothing to describe. Use -h for help.")
  elif args[0] == "image":
    for image in args[1:]:
      subuserlib.resolve.resolveImageSource(user,image).describe()
  elif args[0] == "subuser":
    for subuser in  args[1:]:
      try:
        user.getRegistry().getSubusers()[subuser].describe()
      except KeyError:
        sys.exit("Subuser "+subuser+" does not exist.")
  else:
    subuserlib.print.printWithoutCrashing("Args: '"+"' '".join(args)+"'")
    subuserlib.print.printWithoutCrashing("Option not supported.")
开发者ID:awesome-docker,项目名称:subuser,代码行数:20,代码来源:describe.py

示例13: testImages

def testImages(realArgs):
  """
  Test the given images.
  """
  options,args = parseCliArgs(realArgs)

  user = subuserlib.classes.user.User()

  try:
    with user.getRegistry().getLock() as lockFileHandler:
      subuserlib.testImages.testImages(user=user,sourceRepoId=args[0],imageSourceNames=args[1:])
  except subuserlib.portalocker.portalocker.LockException:
    sys.exit("Another subuser process is currently running and has a lock on the registry. Please try again later.")
开发者ID:xsongx,项目名称:subuser,代码行数:13,代码来源:test-images.py

示例14: remove

def remove(user,subuserName):
  if subuserName in user.getRegistry().getSubusers():
    user.getRegistry().logChange("Removing subuser "+subuserName)
    del user.getRegistry().getSubusers()[subuserName]
    subuserlib.verify.verify(user)
    user.getRegistry().commit()
  else:
    sys.exit("Cannot remove: subuser "+subuserName+" does not exist.")
开发者ID:marclaporte,项目名称:subuser,代码行数:8,代码来源:subuser.py

示例15: dryRun

def dryRun(args):
    if len(args) == 0 or {"help", "-h", "--help"} & set(args):
        print(helpString)
        sys.exit()
    subuserName = args[0]
    argsToPassToImage = args[1:]
    user = subuserlib.classes.user.User()
    if subuserName in user.getRegistry().getSubusers():
        subuser = user.getRegistry().getSubusers()[subuserName]
        print("The image will be prepared using the Dockerfile:")
        print(subuser.getRunReadyImage().generateImagePreparationDockerfile())
        print("The command to launch the image is:")
        print(subuser.getRuntime(os.environ).getPrettyCommand(argsToPassToImage))
    else:
        availableSubusers = ",".join(user.getRegistry().getSubusers().keys())
        sys.exit(
            subuserName
            + " not found.\n"
            + helpString
            + "\n"
            + "The following subusers are available for use:"
            + availableSubusers
        )
开发者ID:talwrii,项目名称:subuser,代码行数:23,代码来源:subuser-dry-run.py


注:本文中的subuserlib.classes.user.getRegistry函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。