~ubuntu-branches/ubuntu/lucid/jhbuild/lucid

« back to all changes in this revision

Viewing changes to jhbuild/frontends/autobuild.py

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort, Loic Minier, Emilio Pozuelo Monfort
  • Date: 2009-11-09 20:28:48 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20091109202848-m9ec7dmzptqtchtj
Tags: 2.28.0-1
[ Loic Minier ]
* Cleanups.
* Ship scripts.
* Don't set GNOME_MODULE as it equals the name of the source package.

[ Emilio Pozuelo Monfort ]
* New upstream release. Closes: #524504.
  - Use 'git rev-parse' rather than 'git-rev-parse'. Closes: #544642.
* Ship install-check. Closes: #441008.
* Uploaders list regenerated. Closes: #523542, #554071.
* debian/control.in,
  debian/rules:
  - Stop shipping a copy of subprocess.py. Require python >= 2.4.
  - Switch to python-support.
* debian/control.in:
  - Bump Standards-Version to 3.8.3, no changes needed.
  - Build depend on intltool >= 0.35.0.
  - Build depend on pkg-config, gnome-doc-utils and rarian-compat to build
    the documentation.
  - Make jhbuild arch any since install-check is a binary. Depend on
    ${shlibs:Depends}.
  - Recommend, and not suggest, git-core. Also recommend mercurial.
* debian/watch:
  - Added.
* debian/patches/01_import_from_pkgdatadir.patch:
  - Added, import jhbuild from pkgdatadir if everything else fails.
    This way we can ship the jhbuild private modules in /usr/sharejhbuild.
* debian/jhbuild.docs:
  - Removed, the necessary docs are now installed by the upstream Makefile.
* debian/rules:
  - Include autotools.mk and gnome.mk.
  - Remove all the manual build process, autotools.mk does everything now.
  - Install the jhbuild modules in /usr/share/jhbuild.
* debian/install:
  - Install the modulesets and patches from here since the upstream build
    system doesn't install them.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
from tinderbox import get_distro
36
36
from terminal import TerminalBuildScript, trayicon, t_bold, t_reset
 
37
import jhbuild.moduleset
37
38
 
38
39
def escape(string):
39
40
    return string.replace('&','&amp;').replace('<','&lt;').replace('>','&gt;')
68
69
                pass
69
70
            if i < ITERS-1:
70
71
                if self.verbose_timeout:
71
 
                    print >> sys.stderr, 'Server Error, retrying in %d seconds' % ((i+1)**2)
 
72
                    print >> sys.stderr, _('Server Error, retrying in %d seconds') % ((i+1)**2)
72
73
                time.sleep((i+1)**2)
73
74
            else:
74
75
                if self.verbose_timeout:
75
 
                    print >> sys.stderr, 'Server Error, aborting'
 
76
                    print >> sys.stderr, _('Server Error, aborting')
76
77
                raise e
77
78
            
78
79
 
87
88
        self.server = None
88
89
        self.modulefp = None
89
90
        self.phasefp = None
 
91
        self.modules = {}
90
92
 
91
93
        # cleanup environment
92
94
        os.environ['TERM'] = 'dumb'
96
98
                os.environ[k] = 'C'
97
99
 
98
100
        if self.verbose:
99
 
            self.trayicon = trayicon.TrayIcon()
 
101
            self.trayicon = trayicon.TrayIcon(config)
100
102
 
101
103
    def message(self, msg, module_num=-1, skipfp = False):
102
104
        '''Display a message to the user'''
122
124
        self.message('%s %s' % (action, action_target), module_num, skipfp = True)
123
125
 
124
126
    def execute(self, command, hint=None, cwd=None, extra_env=None):
125
 
        '''executes a command, and returns the error code'''
126
127
        kws = {
127
128
            'close_fds': True
128
129
            }
139
140
        kws['stdin'] = subprocess.PIPE
140
141
        kws['stdout'] = subprocess.PIPE
141
142
        kws['stderr'] = subprocess.PIPE
142
 
        if hint in ('cvs', 'svn'):
 
143
        if hint in ('cvs', 'svn', 'hg-update.py'):
143
144
            def format_line(line, error_output, fp=self.phasefp):
144
145
                if line[-1] == '\n': line = line[:-1]
145
146
                if self.verbose:
174
175
        try:
175
176
            p = subprocess.Popen(command, **kws)
176
177
        except OSError, e:
177
 
            self.phasefp.write('<span class="error">Error: %s</span>\n' % escape(str(e)))
 
178
            self.phasefp.write('<span class="error">' + _('Error: %s') % escape(str(e)) + '</span>\n')
178
179
            raise CommandError(str(e))
179
180
 
180
181
        cmds.pprint_output(p, format_line)
181
182
        if p.returncode != 0:
182
 
            raise CommandError('Error running %s' % command, p.returncode)
 
183
            raise CommandError(_('Error running %s') % command, p.returncode)
183
184
 
184
185
    def start_build(self):
185
186
        self.server = ServerProxy(self.xmlrpc_report_url, allow_none = True)
206
207
            self.build_id = self.server.start_build(info)
207
208
        except xmlrpclib.ProtocolError, e:
208
209
            if e.errcode == 403:
209
 
                print >> sys.stderr, 'ERROR: Wrong credentials, please check username/password'
 
210
                print >> sys.stderr, _('ERROR: Wrong credentials, please check username/password')
210
211
                sys.exit(1)
211
212
            raise
212
213
 
213
214
        
214
215
        if self.verbose:
215
 
            s = 'Starting Build #%s' % self.build_id
 
216
            s = _('Starting Build #%s') % self.build_id
216
217
            print s
217
218
            print '=' * len(s)
218
219
            print ''
226
227
 
227
228
    def start_module(self, module):
228
229
        if self.verbose:
229
 
            print '\n%s**** Starting module %s ****%s' % (t_bold, module, t_reset)
 
230
            print '\n%s' % t_bold + _('**** Starting module %s ****' % module) + t_reset
230
231
        self.server.start_module(self.build_id, module)
231
232
        self.current_module = module
232
233
        self.modulefp = StringIO()
237
238
        self.modulefp = None
238
239
        self.server.end_module(self.build_id, module, compress_data(log), failed)
239
240
 
240
 
    def start_phase(self, module, state):
241
 
        self.server.start_phase(self.build_id, module, state)
 
241
    def start_phase(self, module, phase):
 
242
        self.server.start_phase(self.build_id, module, phase)
242
243
        if self.verbose:
243
 
            TerminalBuildScript.start_phase(self, module, state)
 
244
            TerminalBuildScript.start_phase(self, module, phase)
244
245
        self.phasefp = StringIO()
245
246
 
246
247
 
247
 
    def end_phase(self, module, state, error):
 
248
    def end_phase(self, module, phase, error):
248
249
        log = fix_encoding(self.phasefp.getvalue())
249
250
        self.phasefp = None
250
 
        self.server.end_phase(self.build_id, module, state, compress_data(log), error)
251
 
 
252
 
    def handle_error(self, module, state, nextstate, error, altstates):
 
251
 
 
252
        if phase == 'test':
 
253
            if self.modules == {}:
 
254
                self.modules = jhbuild.moduleset.load_tests(self.config)
 
255
 
 
256
            if module in self.modules.modules.keys() \
 
257
                   and self.modules.modules[module].test_type == 'ldtp':
 
258
                self._upload_logfile(module)
 
259
        self.server.end_phase(self.build_id, module, phase, compress_data(log), error)
 
260
 
 
261
    def handle_error(self, module, phase, nextphase, error, altphases):
253
262
        '''handle error during build'''
254
 
        print 'handle error!'
 
263
        print 'FIXME: handle error! (failed build: %s: %s)' % (module, error)
255
264
        return 'fail'
256
265
 
 
266
    def _upload_ldtp_logfile (self, module):
 
267
        test_module = self.modules.modules[module]
 
268
        src_dir =  test_module.get_srcdir()
 
269
        if not os.path.exists (os.path.join(src_dir,'run.xml')):
 
270
            return
 
271
        logfile = test_module.get_ldtp_log_file (os.path.join(src_dir,'run.xml'))
 
272
        if not os.path.exists (logfile):
 
273
            return
 
274
        self._upload_logfile (module, logfile, 'application/x-ldtp+xml')
 
275
 
 
276
    def _upload_logfile (self, module, logfile, mimetype):
 
277
        log = open (logfile, 'r')
 
278
        basename = os.path.basename (logfile)
 
279
        self.server.attach_file (self.build_id, module, 'test', basename,
 
280
                                 compress_data(log.read()), mimetype)
 
281
        log.close()
257
282
 
258
283
BUILD_SCRIPT = AutobuildBuildScript