Beispiel #1
0
def test_installation(dir):
    print('Testing flow123d installation')
    if exec.run(join(dir, 'bin/flow123d'), '--help') is False:
        print('Command ended with error!, Installation was not successful!')
    else:
        print('Installation was successful!')
    print('=' * 80)
Beispiel #2
0
 def fetch(self):
     if not self.exists:
         self.create_repo()
     # fetch latest
     print('Fetching repository')
     result = exec.run('git fetch', cwd=self.cwd)
     print(result)
     return result
Beispiel #3
0
    def repo_exists(self):
        print('Testing repository')
        result = exec.run('git rev-parse --show-toplevel', cwd=self.cwd)
        print(result)
        if result is not False:
            print('Found repo root %s' % self.cwd)
        else:
            print('Repo does not exists, will be created')

        return result is not False
Beispiel #4
0
    def checkout(self, commit=None, branch=None):
        print('Switching to desired branch/commit')

        if commit:
            result = exec.run('git checkout -f', commit, cwd=self.cwd)
            print(result)
        else:
            result = exec.run('git checkout -f', branch, cwd=self.cwd)
            print(result)
            print('-' * 80)

            # pull latest
            print('Pulling latest changes')
            result = exec.run('git pull origin', branch, cwd=self.cwd)
            print(result)
            print('-' * 80)

            # checkout to branch again
            result = exec.run('git checkout -f', branch, cwd=self.cwd)
            print(result)
        return result
Beispiel #5
0
    def _fetch_details(self, sha):
        if sha not in self.details:
            command = 'git show -s --pretty=%H,%ce,%ct,%cr,%h ' + sha
            lines = exec.run(command,
                             cwd=self.git.cwd,
                             verbose=False,
                             raw=True).splitlines()
            for line in lines:
                if not str(line).strip():
                    break

                p = line.split(',')
                self.details[p[0]] = dict(
                    email=p[1],
                    timestamp=datetime.datetime.fromtimestamp(int(p[2])),
                    ago=p[3],
                    sha=p[0],
                    short=p[4])
Beispiel #6
0
    def commit_range(self, start, end, limit=None):
        if not start and not end:
            end = 'HEAD'
            dots = ''
        elif start and end:
            dots = '...'
        else:
            dots = ''

        max_count = '' if not limit else '--max-count=%d' % limit
        command = 'git rev-list {max_count} {start}{dots}{end}'.format(
            **locals())
        commits = [
            str(x).strip()
            for x in exec.run(command, cwd=self.cwd, raw=True).splitlines()
        ]
        commits.reverse()
        return Commits(self, commits)
Beispiel #7
0
def run_install(dir, module=None):
    print('Running install shell script')

    if module is None:
        if exec.run('which qsub', verbose=False) is False:
            module = 'local'
        else:
            module = 'pbs'
    print('Using module %s' % module)
    bin_dir = join(__root__, 'bin', module)

    # run script
    print('Executing install flow123d script')
    stream = None
    p = subprocess.Popen([join(bin_dir, 'install-flow123d.sh'), dir], stdout=stream, stderr=stream)
    p.wait()
    if p.returncode == 0:
        print('Script ended successfully')
    else:
        print('Script ended with error %d' % p.returncode)
    print('=' * 80)
Beispiel #8
0
 def print_state(self):
     print('Repository is in the following state:')
     print(exec.run('git branch', cwd=self.cwd))
     print(exec.run("git log -n 1", cwd=self.cwd))
     print(exec.run("git describe", cwd=self.cwd))
Beispiel #9
0
 def create_repo(self, url=flow123d_repo):
     result = exec.run('git clone ' + url, self.cwd)
     print(result)
     return result