Beispiel #1
0
    def run(self, color=True):
        """Enter in all package defined and Executing 'python setup.py' with
           user command.

        """
        import sys
        import os
        if color:
            try:
                from openalea.deploy.console import bold, red, green, \
                    color_terminal, nocolor, underline, purple
            except:
                try:
                    sys.path.insert(
                        0, os.path.join('deploy', 'src', 'openalea', 'deploy'))
                    from console import bold, red, green, \
                        color_terminal, nocolor, underline, purple
                except:
                    pass
            if not color_terminal():
                # Windows' poor cmd box doesn't understand ANSI sequences
                nocolor()
        else:
            bold = purple = red = green = underline = str

        print bold("Running multisetup version %s" % __revision__.split()[2])

        project_dir = self.curdir.basename()
        directories = [
            self.curdir.joinpath(package) for package in self.packages
        ]

        print 'Will process the following directories: ',
        for directory in directories:
            print bold(directory.basename()),
        print ''

        try:
            for directory in directories:
                try:
                    os.chdir(directory)
                    print underline('Entering %s package' %
                                    directory.basename())
                except OSError, e:
                    print underline('Entering %s package' %
                                    directory.basename()),
                    print red("cannot find this directory (%s)" %
                              directory.basename())
                    print e

                print 'Python exec : ', sys.executable

                #print underline('Entering %s package' % directory.basename())
                for cmd in self.commands:
                    setup_command = '%s setup.py %s ' % (sys.executable, cmd)
                    print "\tExecuting " + setup_command + '...processing',

                    #Run setup.py with user commands
                    outputs = None
                    errors = None
                    if self.verbose:
                        process = Popen(setup_command, shell=True)
                        status = process.wait()
                    else:
                        process = Popen(setup_command,
                                        stdout=PIPE,
                                        stderr=PIPE,
                                        shell=True)
                        #status = process.wait()
                        outputs, errors = process.communicate()
                    if process.returncode == 0:
                        print green('done')
                    else:
                        if not self.verbose:
                            print red('\tFailed. ( error code %s) ' %
                                      (process.returncode))
                            os.chdir(self.curdir)

                        if not self.force:
                            raise RuntimeError()

                    if 'pylint' in cmd:
                        if outputs is not None:
                            for x in outputs.split('\n'):
                                if x.startswith('Your code has been'):
                                    print purple('\t%s' % x)
                    if 'nosetests' in cmd:
                        if errors is not None:
                            for x in errors.split('\n'):
                                if x.startswith('TOTAL'):
                                    res = x.replace('TOTAL', 'Total coverage')
                                    res = " ".join(res.split())
                                    print purple('\t%s' % res)
                                if x.startswith('Ran'):
                                    print purple('\t%s' % x)
                                if x.startswith('FAILED'):
                                    print purple('\t%s' % x)

        except RuntimeError:
            sys.exit()

        os.chdir(self.curdir)
Beispiel #2
0
        help="specify the package section according to the GForge architecture")
    parser.add_option("-r", "--release", dest='release', default=None,
        help="specify therelease according to the GForge architecture")
    parser.add_option("-g", "--glob", dest='glob', default=None,
        help="glob for filenames to be uploaded")
    parser.add_option("-m", "--mode", dest='mode', default=None,
        help="mode in [add, query, remove]")

    try:
        (opts, args)= parser.parse_args()
    except Exception,e:
        parser.print_usage()
        print "Error while parsing args:", e
        raise e

    print bold("Running gforge_upload version %s" % __revision__.split()[2])
    if opts.non_interactive is True:
        print bold(red("You are running gforge_upload without interaction (-Y option)"))
        ok = raw_input(bold(red("We assume that you want to reply yes to all questions including file removal. Shall we continue ?")))
        if not ok:
            sys.exit(0)
 
    # Create the Uploader object
    uploader = Uploader(opts)
    uploader.run()



if __name__=='__main__' :
    main()
Beispiel #3
0
    def run(self, color=True):
        """Enter in all package defined and Executing 'python setup.py' with
           user command.

        """
        import sys
        import os
        if color:
            try:
                from openalea.deploy.console import bold, red, green, \
                    color_terminal, nocolor, underline, purple
            except:
                try:
                    sys.path.insert(0, os.path.join('deploy', 'src', 'openalea', 'deploy'))
                    from console import bold, red, green, \
                        color_terminal, nocolor, underline, purple
                except:
                    pass
            if not color_terminal():
                # Windows' poor cmd box doesn't understand ANSI sequences
                nocolor()
        else:
            bold = purple = red = green = underline = str

        print bold("Running multisetup version %s" % __revision__.split()[2])

        project_dir = self.curdir.basename()
        directories = [self.curdir.joinpath(package) for package in self.packages]

        print 'Will process the following directories: ',
        for directory in directories:
            print bold(directory.basename()),
        print ''

        try:
            for directory in directories:
                try:
                    os.chdir(directory)
                    print underline('Entering %s package'
                                    % directory.basename())
                except OSError, e:
                    print underline('Entering %s package'
                                    % directory.basename()),
                    print red("cannot find this directory (%s)"
                              % directory.basename())
                    print e

                print 'Python exec : ', sys.executable

                #print underline('Entering %s package' % directory.basename())
                for cmd in self.commands:
                    setup_command = '%s setup.py %s ' % (sys.executable, cmd)
                    print "\tExecuting " + setup_command + '...processing',

                    #Run setup.py with user commands
                    outputs = None
                    errors = None
                    if self.verbose:
                        process = Popen(setup_command,
                                        shell=True)
                        status = process.wait()
                    else:
                        process = Popen(setup_command, stdout=PIPE, stderr=PIPE,
                                        shell=True)
                        #status = process.wait()
                        outputs, errors = process.communicate()
                    if process.returncode == 0:
                        print green('done')
                    else:
                        if not self.verbose:
                            print red('\tFailed. ( error code %s) ' %
                                  (process.returncode))
                            os.chdir(self.curdir)

                        if not self.force:
                            raise RuntimeError()

                    if 'pylint' in cmd:
                        if outputs is not None:
                            for x in outputs.split('\n'):
                                if x.startswith('Your code has been'):
                                    print purple('\t%s' % x)
                    if 'nosetests' in cmd:
                        if errors is not None:
                            for x in errors.split('\n'):
                                if x.startswith('TOTAL'):
                                    res = x.replace('TOTAL', 'Total coverage')
                                    res = " ".join(res.split())
                                    print purple('\t%s' % res)
                                if x.startswith('Ran'):
                                    print purple('\t%s' % x)
                                if x.startswith('FAILED'):
                                    print purple('\t%s' % x)

        except RuntimeError:
            sys.exit()

        os.chdir(self.curdir)