コード例 #1
0
ファイル: mount_branch.py プロジェクト: JGOODYEARUCSD/ka-lite
    def setup_repo(self, server):
        """Set up the specified user's repo as a remote; return the directory it's set up in!"""
    
        if self.git_repo != "ka-lite":
            raise NotImplementedError("Only ka-lite repo has been implemented!")
        
        self.log.debug("Setting up %s %s %s" % (self.git_user, self.repo_branch, self.git_repo))
    
        # Create the branch directory
        self.branch_dir = os.path.realpath(server.base_dir + "/..")
        if os.path.exists(self.branch_dir):
            self.log.info("Mounting git to existing branch dir: %s" % self.branch_dir)
        else:
            self.log.info("Creating branch dir")
            os.makedirs(self.branch_dir)


        # clone the git repository
        os.chdir(self.branch_dir)
        # Directory exists, maybe it's already set up? 
        if os.path.exists(server.base_dir):
            os.chdir(server.base_dir)
            (_,stdout,stderr) = lexec("git remote -v")
            # It contains the desired repo; good enough. 
            # TODO(bcipolli): really should check if the repo is ORIGIN
            if -1 != stdout.find("%s/%s.git" % (self.git_user, self.git_repo)):
                self.log.warn("Not touching existing git repository @ %s" % self.repo_dir)
                return server.base_dir
    #        else:
    #            raise Exception(stderr)
            os.chdir(self.branch_dir) # return to branch dir
        
        self.log.info("Cloning %s/%s.git to %s" % (self.git_user, self.git_repo, server.base_dir))
        lexec("git clone [email protected]:%s/%s.git %s" % (self.git_user, self.git_repo, os.path.basename(server.base_dir)))
コード例 #2
0
ファイル: mount_branch.py プロジェクト: JGOODYEARUCSD/ka-lite
 def start_server(self):
     """By default, run allowing external access."""        
     cwd = os.getcwd()
     os.chdir(self.base_dir + "/kalite")
 
     lexec(self.pyexec() + " manage.py runcherrypyserver host=%s port=%d threads=5 daemonize=true pidfile=%s/kalite/runcherrypyserver.pid" % (self.hostname, self.port, self.base_dir))
 
     os.chdir(cwd)
コード例 #3
0
ファイル: mount_branch.py プロジェクト: foolchan2556/ka-lite
    def start_server(self):
        """By default, run allowing external access."""
        cwd = os.getcwd()
        os.chdir(self.base_dir + "/kalite")

        lexec(
            self.pyexec() +
            " manage.py runcherrypyserver host=%s port=%d threads=5 daemonize=true pidfile=%s/kalite/runcherrypyserver.pid"
            % (self.hostname, self.port, self.base_dir))

        os.chdir(cwd)
コード例 #4
0
ファイル: mount_branch.py プロジェクト: JGOODYEARUCSD/ka-lite
 def pyexec(self):
     """Return the path to the python executable"""
     
     if not self.__class__._pyexec:   
         (_,pyexec,_) = lexec("bash " + self.base_dir+"/python.sh", silent=True)
         self.__class__._pyexec = pyexec[:-1]
     return self.__class__._pyexec
コード例 #5
0
ファイル: mount_branch.py プロジェクト: foolchan2556/ka-lite
    def pyexec(self):
        """Return the path to the python executable"""

        if not self.__class__._pyexec:
            (_, pyexec, _) = lexec("bash " + self.base_dir + "/python.sh",
                                   silent=True)
            self.__class__._pyexec = pyexec[:-1]
        return self.__class__._pyexec
コード例 #6
0
ファイル: mount_branch.py プロジェクト: foolchan2556/ka-lite
    def setup_repo(self, server):
        """Set up the specified user's repo as a remote; return the directory it's set up in!"""

        if self.git_repo != "ka-lite":
            raise NotImplementedError(
                "Only ka-lite repo has been implemented!")

        self.log.debug("Setting up %s %s %s" %
                       (self.git_user, self.repo_branch, self.git_repo))

        #        self.docker.run_command("/playground/test_tools/mount_docker_branch.sh %s %s %s" % (self.git_user, self.git_repo, self.repo_branch))

        # Add the remote
        os.chdir(server.base_dir)

        self.log.info("Adding remote %s/%s.git to %s" %
                      (self.git_user, self.git_repo, server.base_dir))
        remote_url = "git://github.com/%s/%s.git" % (self.git_user,
                                                     self.git_repo)
        lexec("git remote add %s %s" % (self.git_user, remote_url))
        if not remote_url in lexec("git remote -v")[1]:
            raise Exception("Failed to add remote to git (%s)" % remote_url)

        # Merge in the remote branch
        lexec("git fetch %s" % self.git_user)
        lexec("git merge %s/%s" % (self.git_user, self.repo_branch))
        """
コード例 #7
0
ファイル: mount_branch.py プロジェクト: foolchan2556/ka-lite
    def setup_repo(self, server):
        """Set up the specified user's repo as a remote; return the directory it's set up in!"""

        if self.git_repo != "ka-lite":
            raise NotImplementedError(
                "Only ka-lite repo has been implemented!")

        self.log.debug("Setting up %s %s %s" %
                       (self.git_user, self.repo_branch, self.git_repo))

        # Create the branch directory
        self.branch_dir = os.path.realpath(server.base_dir + "/..")
        if os.path.exists(self.branch_dir):
            self.log.info("Mounting git to existing branch dir: %s" %
                          self.branch_dir)
        else:
            self.log.info("Creating branch dir")
            os.makedirs(self.branch_dir)

        # clone the git repository
        os.chdir(self.branch_dir)
        # Directory exists, maybe it's already set up?
        if os.path.exists(server.base_dir):
            os.chdir(server.base_dir)
            (_, stdout, stderr) = lexec("git remote -v")
            # It contains the desired repo; good enough.
            # TODO(bcipolli): really should check if the repo is ORIGIN
            if -1 != stdout.find("%s/%s.git" % (self.git_user, self.git_repo)):
                self.log.warn("Not touching existing git repository @ %s" %
                              self.repo_dir)
                return server.base_dir

    #        else:
    #            raise Exception(stderr)
            os.chdir(self.branch_dir)  # return to branch dir

        self.log.info("Cloning %s/%s.git to %s" %
                      (self.git_user, self.git_repo, server.base_dir))
        lexec(
            "git clone [email protected]:%s/%s.git %s" %
            (self.git_user, self.git_repo, os.path.basename(server.base_dir)))
コード例 #8
0
ファイル: mount_branch.py プロジェクト: JGOODYEARUCSD/ka-lite
    def call_command(self, command, params_string="", input=None):
        """Poor man's version of call_command"""
        
        cwd = os.getcwd()
        os.chdir(self.base_dir + "/kalite")
        
        cmd = self.pyexec() + " manage.py " + command + (" " + params_string if params_string else "")
        self.log.debug("Running '%s'" % cmd)
        out = lexec(cmd, input=input)
        
        os.chdir(cwd)

        return {
            "stdout": out[1],
            "stderr": out[2],
            "exit_code": out[0],
        }
コード例 #9
0
ファイル: mount_branch.py プロジェクト: JGOODYEARUCSD/ka-lite
 def select_branch(self, server):
     if server.base_dir:
         cwd = os.getcwd()
         os.chdir(server.base_dir)
 
     # Get the current list of branches
     lexec("git fetch")
 
     # List the branches
     (_,stdout,_) = lexec("git branch")
 
     # Branch doesn't exist; create it
     if -1 == stdout.find("%s\n" % self.repo_branch): # note: this is a CRAPPY match!
         self.log.info("Connecting to branch %s" % self.repo_branch)
         lexec("git checkout -t origin/%s" % self.repo_branch)
     else:
         self.log.info("Changing to branch %s" % self.repo_branch)
         lexec("git checkout %s" % self.repo_branch)
         lexec("git pull origin %s" % self.repo_branch)
     
     # switch directory back
     if repo_dir:
         os.chdir(cwd)
コード例 #10
0
ファイル: mount_branch.py プロジェクト: foolchan2556/ka-lite
    def call_command(self, command, params_string="", input=None):
        """Poor man's version of call_command"""

        cwd = os.getcwd()
        os.chdir(self.base_dir + "/kalite")

        cmd = self.pyexec() + " manage.py " + command + (" " + params_string if
                                                         params_string else "")
        self.log.debug("Running '%s'" % cmd)
        out = lexec(cmd, input=input)

        os.chdir(cwd)

        return {
            "stdout": out[1],
            "stderr": out[2],
            "exit_code": out[0],
        }
コード例 #11
0
ファイル: mount_branch.py プロジェクト: foolchan2556/ka-lite
    def select_branch(self, server):
        if server.base_dir:
            cwd = os.getcwd()
            os.chdir(server.base_dir)

        # Get the current list of branches
        lexec("git fetch")

        # List the branches
        (_, stdout, _) = lexec("git branch")

        # Branch doesn't exist; create it
        if -1 == stdout.find(
                "%s\n" % self.repo_branch):  # note: this is a CRAPPY match!
            self.log.info("Connecting to branch %s" % self.repo_branch)
            lexec("git checkout -t origin/%s" % self.repo_branch)
        else:
            self.log.info("Changing to branch %s" % self.repo_branch)
            lexec("git checkout %s" % self.repo_branch)
            lexec("git pull origin %s" % self.repo_branch)

        # switch directory back
        if repo_dir:
            os.chdir(cwd)
コード例 #12
0
ファイル: mount_branch.py プロジェクト: JGOODYEARUCSD/ka-lite
    def setup_repo(self, server):
        """Set up the specified user's repo as a remote; return the directory it's set up in!"""
        
        if self.git_repo != "ka-lite":
            raise NotImplementedError("Only ka-lite repo has been implemented!")
    
        self.log.debug("Setting up %s %s %s" % (self.git_user, self.repo_branch, self.git_repo))
    
#        self.docker.run_command("/playground/test_tools/mount_docker_branch.sh %s %s %s" % (self.git_user, self.git_repo, self.repo_branch))
    
        # Add the remote        
        os.chdir(server.base_dir)
    
        self.log.info("Adding remote %s/%s.git to %s" % (self.git_user, self.git_repo, server.base_dir))
        remote_url = "git://github.com/%s/%s.git" % (self.git_user, self.git_repo)
        lexec("git remote add %s %s" % (self.git_user, remote_url));
        if not remote_url in lexec("git remote -v")[1]:
            raise Exception("Failed to add remote to git (%s)" % remote_url)
    
        # Merge in the remote branch
        lexec("git fetch %s" % self.git_user)
        lexec("git merge %s/%s" % (self.git_user, self.repo_branch))
        
        """