Ejemplo n.º 1
0
 def check_coin_version(self):
     "check the Coin version"
     if sys.platform == "win32": return
     if not self.check_cmd_exists("coin-config"):
         sys.exit(1)
     print blue("Coin version..."),
     version = self.do_os_popen("coin-config --version")
     print blue("%s" % version)
     if not version.startswith('2.4'):
         print yellow("** Warning: Pivy has only been tested with Coin "
                      "versions 2.4.x.")
Ejemplo n.º 2
0
 def check_swig_version(self, swig):
     "check for the swig version"
     global SWIG_VERSION
     if not self.check_cmd_exists(swig):
         sys.exit(1)
     print blue("Checking for SWIG version..."),
     fd = os.popen4("%s -version" % swig)[1]
     version = fd.readlines()[1].strip().split(" ")[2]
     fd.close()
     print blue("%s" % version)
     SWIG_VERSION = version
     if not version in self.SUPPORTED_SWIG_VERSIONS:
         print yellow("Warning: Pivy has only been tested with the following " + \
                      "SWIG versions: %s." % " ".join(self.SUPPORTED_SWIG_VERSIONS))
Ejemplo n.º 3
0
 def printlevelstat(self, level, n=0):
     med = median((i.nleaves for i in level.itervalues()))
     self.logger.debug(output.green(' ' * n + "MED %f nleaves=%d len(k)=%d depth=%d"),
                                    med,
                                    level.nleaves,
                                    len(level.keys()),
                                    level.depth)
     for k, v in level.iteritems():
         nleaves = v.nleaves
         depth = v.depth
         if v and v.clusterable:
             self.logger.debug(
                     output.yellow(
                         ' ' * n + "K %s nleaves=%d r=%.2f depth=%d"),
                     k,
                     nleaves,
                     float(nleaves)/med,
                     depth)
         else:
             self.logger.debug(
                     output.green(
                         ' ' * n + "K %s nleaves=%d r=%.2f depth=%d"),
                     k,
                     nleaves,
                     float(nleaves)/med,
                     depth)
         if v:
             self.printlevelstat(v, n+1)
Ejemplo n.º 4
0
    def git_merge_all(self,
                      from_branch,
                      to_branch,
                      working_path='/var/release'):
        """
        Merge all Git Repositories from one branch into another.
        :param from_branch: What branch to merge from
        :param to_branch: What branch to merge into
        :param working_path:
        :return:
        """
        if not os.path.exists(working_path):
            # if path doesn't exist, create it:
            os.mkdir(working_path)

        os.chdir(working_path)

        for repo in self.config.repositories:
            os.chdir(working_path)
            out(1, blue("\n------- REPO: " + repo + " -------"))
            # see if the repo exists
            path = working_path + '/' + repo

            output = ''
            try:
                if not os.path.exists(path):
                    output += self.exec_shell('git clone ' + self.git_server +
                                              '/' + repo + '.git ' + path)

                    if 'Access denied.' in output:
                        out(2, yellow('skipped'))
                        continue

                os.chdir(path)

                output += self.exec_shell('git reset --hard HEAD')
                output += self.exec_shell(
                    'git checkout --force {}'.format(from_branch))
                output += self.exec_shell('git pull')
                output += self.exec_shell(
                    'git checkout --force {}'.format(to_branch))
                output += self.exec_shell('git pull')
                output += self.exec_shell('git merge {}'.format(from_branch))
                output += self.exec_shell(
                    'git push origin {}'.format(to_branch))

                for line in output.splitlines(True):
                    if line.startswith('error') or line.startswith('CONFLICT'):
                        out(2, red(line))
                    else:
                        out(2, green(line))

            except Exception as e:
                out(2, red('Error: '))
                out(2, red(output))
                out(2, red(e))
                return False
        return output
Ejemplo n.º 5
0
    def git_merge_all(self, from_branch, to_branch, working_path='/var/release'):
        """
        Merge all Git Repositories from one branch into another.
        :param from_branch: What branch to merge from
        :param to_branch: What branch to merge into
        :param working_path:
        :return:
        """
        if not os.path.exists(working_path):
            # if path doesn't exist, create it:
            os.mkdir(working_path)

        os.chdir(working_path)

        for repo in self.config.repositories:
            os.chdir(working_path)
            out(1, blue("\n------- REPO: " + repo + " -------"))
            # see if the repo exists
            path = working_path+'/'+repo

            output = ''
            try:
                if not os.path.exists(path):
                    output += self.exec_shell('git clone '+self.git_server+'/'+repo+'.git ' + path)

                    if 'Access denied.' in output:
                        out(2, yellow('skipped'))
                        continue

                os.chdir(path)

                output += self.exec_shell('git reset --hard HEAD')
                output += self.exec_shell('git checkout --force {}'.format(from_branch))
                output += self.exec_shell('git pull')
                output += self.exec_shell('git checkout --force {}'.format(to_branch))
                output += self.exec_shell('git pull')
                output += self.exec_shell('git merge {}'.format(from_branch))
                output += self.exec_shell('git push origin {}'.format(to_branch))

                for line in output.splitlines(True):
                    if line.startswith('error') or line.startswith('CONFLICT'):
                        out(2, red(line))
                    else:
                        out(2, green(line))

            except Exception as e:
                out(2, red('Error: '))
                out(2, red(output))
                out(2, red(e))
                return False
        return output
Ejemplo n.º 6
0
Inter-Organisational Intrusion Detection System (IOIDS)

Check README in the IOIDS folder for more information.

@author: Michael Pilgermann
@contact: mailto:[email protected]
@license: GPL (General Public License)
"""

import output
from sys import stdout

oneindent = ' ' * 3
SUCESS_POS = output.green('  OK  ')
SUCESS_NEG = output.red('FAILED')
SUCESS_SKIP = output.yellow(' SKIP ')
SUCESS_WARN = output.yellow('  !!  ')

COLUMN_SUCESS = 80
COLUMN_INPUT = 70
LENGTH_LINE = 89


def printAction(indent, text, linebreak = 0, out = stdout):
    """
    Prints a line for an action and puts the cursor on a predefined column.
    
    Usually, no line break is written, the line should be finished after performing an
    action using the function L{finishActionLine}.
    """
    print ((oneindent * indent) + text).ljust(COLUMN_SUCESS),
def svnwarn(message):
		sys.stderr.write(output.yellow("   SVN: ") + message + "\n")
def ewarn(message):
	sys.stderr.write(output.yellow(" * ") + message + "\n")
Ejemplo n.º 9
0
def logmw(s):
	m = output.yellow(" * ") + output.white(s)
	p(m)