示例#1
0
 def save(self):
     """ Save attributes of the repositories to disk. """
     userRepositoryListDict = {}
     for name, repository in self.userRepositories.iteritems():
         userRepositoryListDict[name] = {}
         userRepositoryListDict[name][
             "git-origin"] = repository.getGitOriginURI()
         userRepositoryListDict[name]["temporary"] = repository.isTemporary(
         )
     with open(self.userRepositoryListPath, 'w') as file_f:
         json.dump(userRepositoryListDict,
                   file_f,
                   indent=1,
                   separators=(',', ': '))
     repositoryStatesDotJsonPath = os.path.join(
         self.getUser().getConfig().getRegistryPath(),
         "repository-states.json")
     repositoryStates = {}
     for repoName, repository in self.iteritems():
         repositoryStates[repoName] = {}
         repositoryStates[repoName][
             "git-commit-hash"] = repository.getGitCommitHash()
     with open(repositoryStatesDotJsonPath,
               mode="w") as repositoryStatesDotJsonFile:
         json.dump(repositoryStates,
                   repositoryStatesDotJsonFile,
                   indent=1,
                   separators=(',', ': '))
示例#2
0
 def addRepository(self, repository):
     if not repository.isTemporary():
         self.getUser().getRegistry().logChange("Adding new repository " +
                                                repository.getDisplayName())
     else:
         self.getUser().getRegistry().logChange(
             "Adding new temporary repository " +
             repository.getDisplayName())
     self.userRepositories[repository.getName()] = repository
示例#3
0
 def removeRepository(self,name):
   try:
     repository = self.userRepositories[name]
   except KeyError:
     sys.exit("Cannot remove repository "+name+". Repository does not exist.")
   if not repository.isTemporary():
     self.getUser().getRegistry().logChange("Removing repository "+name)
   else:
     self.getUser().getRegistry().logChange("Removing temporary repository "+self[name].getGitOriginURI())
   del self.userRepositories[name]
示例#4
0
def add(user,name,url):
  repository = subuserlib.resolve.lookupRepositoryByURI(user,url)
  if repository:
    if repository.isTemporary():
      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()
示例#5
0
 def removeRepository(self, name):
     try:
         repository = self.userRepositories[name]
     except KeyError:
         sys.exit("Cannot remove repository " + name +
                  ". Repository does not exist.")
     if not repository.isTemporary():
         self.getUser().getRegistry().logChange("Removing repository " +
                                                name)
     else:
         self.getUser().getRegistry().logChange(
             "Removing temporary repository " + self[name].getDisplayName())
     del self.userRepositories[name]
示例#6
0
def add(user,name,url):
  repository = subuserlib.resolve.lookupRepositoryByURIOrPath(user,url)
  if repository:
    if repository.isTemporary():
      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:
    if url.startswith("/"):
      repository = subuserlib.classes.repository.Repository(user,name=name,sourceDir=url)
    else:
      repository = subuserlib.classes.repository.Repository(user,name=name,gitOriginURI=url,gitCommitHash="master")
    user.getRegistry().getRepositories().addRepository(repository)
    user.getRegistry().commit()
示例#7
0
  def save(self):
    """
    Save attributes of the repositories to disk.

    Note: This is done automatically for you when you ``commit()`` the registry.
    """
    userRepositoryListDict = {}
    for name,repository in self.userRepositories.items():
      userRepositoryListDict[name] = {}
      userRepositoryListDict[name]["git-origin"] = repository.getGitOriginURI()
      userRepositoryListDict[name]["temporary"] = repository.isTemporary()
    with open(self.userRepositoryListPath, 'w') as file_f:
      json.dump(userRepositoryListDict, file_f, indent=1, separators=(',', ': '))
    repositoryStatesDotJsonPath = os.path.join(self.getUser().getConfig().getRegistryPath(),"repository-states.json")
    repositoryStates = {}
    for repoName,repository in self.items():
      repositoryStates[repoName] = {}
      repositoryStates[repoName]["git-commit-hash"] = repository.getGitCommitHash()
    with open(repositoryStatesDotJsonPath,mode="w") as repositoryStatesDotJsonFile:
      json.dump(repositoryStates,repositoryStatesDotJsonFile, indent=1, separators=(',', ': '))
示例#8
0
    def save(self):
        """
    Save attributes of the repositories to disk.

    Note: This is done automatically for you when you ``commit()`` the registry.
    """
        userRepositoryListDict = {}
        for name, repository in self.userRepositories.items():
            userRepositoryListDict[name] = {}
            if repository.getGitOriginURI():
                userRepositoryListDict[name][
                    "git-origin"] = repository.getGitOriginURI()
            else:
                userRepositoryListDict[name][
                    "source-dir"] = repository.getRepoPath()
            userRepositoryListDict[name]["temporary"] = repository.isTemporary(
            )
        with open(self.userRepositoryListPath, 'w') as file_f:
            json.dump(userRepositoryListDict,
                      file_f,
                      indent=1,
                      separators=(',', ': '))
        repositoryStatesDotJsonPath = os.path.join(
            self.getUser().getConfig()["registry-dir"],
            "repository-states.json")
        repositoryStates = {}
        for repoName, repository in self.items():
            repositoryStates[repoName] = {}
            repositoryStates[repoName][
                "git-commit-hash"] = repository.getGitCommitHash()
        with open(repositoryStatesDotJsonPath,
                  mode="w") as repositoryStatesDotJsonFile:
            json.dump(repositoryStates,
                      repositoryStatesDotJsonFile,
                      indent=1,
                      separators=(',', ': '))
示例#9
0
 def addRepository(self,repository):
   if not repository.isTemporary():
     self.getUser().getRegistry().logChange("Adding new repository "+repository.getName())
   else:
     self.getUser().getRegistry().logChange("Adding new temporary repository "+repository.getGitOriginURI())
   self.userRepositories[repository.getName()] = repository