From 679eb281556efe188de9075a26bf0c606364f3b4 Mon Sep 17 00:00:00 2001 From: Sascha Silbe Date: Wed, 22 Sep 2010 13:39:29 +0000 Subject: remove unused and probably broken scripts --- diff --git a/scripts/check.py b/scripts/check.py deleted file mode 100644 index fbdac23..0000000 --- a/scripts/check.py +++ /dev/null @@ -1,142 +0,0 @@ -import os -import sys -from optparse import make_option -import random -import signal -import subprocess -import time - -from jhbuild.commands import Command, register_command -import jhbuild.config - -scripts_dir = os.path.dirname(__file__) -data_dir = os.path.join(scripts_dir, 'data') -pylintrc_path = os.path.join(data_dir, 'pylintrc') - -def check_display(display): - result = subprocess.call(['xdpyinfo', '-display', ':%d' % display], - stdout=open(os.devnull, "w"), - stderr=open(os.devnull, "w")) - return result == 0 - -class UICheck(object): - def start(self): - self._mainloop = gobject.MainLoop() - self._exit_code = 0 - - self._start_shell() - - gobject.idle_add(self._start_ui_check_cb) - - self._mainloop.run() - - return self._exit_code - - def _start_shell(self): - print 'Launch the shell.' - - env = os.environ - env['SUGAR_PROFILE'] = 'uicheck' - env['SUGAR_PROFILE_NAME'] = 'uicheck' - - args = ['dbus-launch', '--exit-with-session', 'sugar'] - shell_process = subprocess.Popen(args, env=env) - - def _ui_check_exit_cb(self, pid, condition): - self._exit_code = os.WEXITSTATUS(condition) - self._mainloop.quit() - - def _ui_check_read_cb(self, fd, condition): - sys.stdout.write(os.read(fd, 1024)) - return True - - def _start_ui_check_cb(self): - print 'Launch UI check.' - - pid, stdin, stdout, stderr = gobject.spawn_async( - ['sugar-ui-check'], standard_output=True, standard_error=True, - flags=gobject.SPAWN_SEARCH_PATH | gobject.SPAWN_DO_NOT_REAP_CHILD) - - gobject.io_add_watch(stdout, gobject.IO_IN, self._ui_check_read_cb) - gobject.io_add_watch(stderr, gobject.IO_IN, self._ui_check_read_cb) - - gobject.child_watch_add(pid, self._ui_check_exit_cb) - -class cmd_check(Command): - - name = 'check' - usage_args = '' - - def __init__(self): - Command.__init__(self, [ - make_option('-t', '--type', action='store', - dest='type', default=None, - help='specify the check type') - ]) - - def start_virtual_x(self): - result = None - - for port in range(100, 1000): - if not check_display(port): - try: - p = subprocess.Popen(['Xvnc', '-ac', ':%d' % port], - stdout=open(os.devnull, "w"), - stderr=subprocess.STDOUT) - - tries = 10 - while tries > 0: - if check_display(port): - os.environ['DISPLAY'] = ':%d' % port - return p.pid - else: - tries -= 1 - time.sleep(0.1) - except OSError: - break - - print 'Cannot execute virtual X, will use the default display.' - return None - - def lint(self, module): - vx_pid = self.start_virtual_x() - try: - subprocess.call(['pylint', module, '--rcfile=%s' % pylintrc_path]) - finally: - os.kill(vx_pid, signal.SIGTERM) - - def check_ui(self, config): - vx_pid = self.start_virtual_x() - try: - result = UICheck().start() - finally: - os.kill(vx_pid, signal.SIGTERM) - - return result - - def check_pylint(self, config): - self.lint('sugar') - self.lint('jarabe') - - ext_path = os.path.join(config.prefix, 'share', 'sugar', 'extensions') - jhbuild.config.addpath('PYTHONPATH', ext_path) - - self.lint('cpsection') - self.lint('deviceicon') - - def run(self, config, options, args): - result = 0 - - if not options.type or options.type == 'pylint': - self.check_pylint(config) - if not options.type or options.type == 'ui': - result = self.check_ui(config) - - return result - -try: - import gobject - - register_command(cmd_check) -except ImportError: - print 'Disable check, pygobject is not installed.' diff --git a/scripts/clear.py b/scripts/clear.py deleted file mode 100644 index cc25e34..0000000 --- a/scripts/clear.py +++ /dev/null @@ -1,18 +0,0 @@ -import os -import shutil - -from jhbuild.commands import Command, register_command - -class cmd_clear(Command): - - name = 'clear' - usage_args = '' - - def run(self, config, options, args): - if os.path.exists(config.checkoutroot): - shutil.rmtree(config.checkoutroot) - - if os.path.exists(config.prefix): - shutil.rmtree(config.prefix) - -register_command(cmd_clear) diff --git a/scripts/main.py b/scripts/main.py deleted file mode 100644 index 4f3d1f8..0000000 --- a/scripts/main.py +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/env python -# jhbuild - a build script for GNOME 1.x and 2.x -# Copyright (C) 2001-2006 James Henstridge -# -# main.py: parses command line arguments and starts the build -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -import sys, os, errno -import optparse -import traceback - -import gettext -localedir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../mo')) -gettext.install('jhbuild', localedir=localedir, unicode=True) -import __builtin__ -__builtin__.__dict__['N_'] = lambda x: x - -import jhbuild.commands -from jhbuild.errors import UsageError, FatalError -from jhbuild.utils.cmds import get_output -from jhbuild.moduleset import warn_local_modulesets - -import bundlemodule -import depscheck -import clear - -from config import Config - -if sys.platform == 'darwin': - # work around locale.getpreferredencoding() returning an empty string in - # Mac OS X, see http://bugzilla.gnome.org/show_bug.cgi?id=534650 and - # http://bazaar-vcs.org/DarwinCommandLineArgumentDecoding - sys.platform = 'posix' - try: - import locale - finally: - sys.platform = 'darwin' -else: - import locale - -try: - _encoding = locale.getpreferredencoding() - assert _encoding -except (locale.Error, AssertionError): - _encoding = 'ascii' - -def uencode(s): - if type(s) is unicode: - return s.encode(_encoding, 'replace') - else: - return s - -def uprint(*args): - '''Print Unicode string encoded for the terminal''' - for s in args[:-1]: - print uencode(s), - s = args[-1] - print uencode(s) - -__builtin__.__dict__['uprint'] = uprint -__builtin__.__dict__['uencode'] = uencode - -def help_commands(option, opt_str, value, parser): - thisdir = os.path.abspath(os.path.dirname(__file__)) - - # import all available commands - for fname in os.listdir(os.path.join(thisdir, 'commands')): - name, ext = os.path.splitext(fname) - if not ext == '.py': - continue - try: - __import__('jhbuild.commands.%s' % name) - except ImportError: - pass - - uprint(_('JHBuild commands are:')) - commands = [(x.name, x.doc) for x in jhbuild.commands.get_commands().values()] - commands.sort() - for name, description in commands: - uprint(' %-15s %s' % (name, description)) - print - uprint(_('For more information run "jhbuild --help"')) - parser.exit() - -def main(base_dir, args): - parser = optparse.OptionParser( - usage=_('%prog [ -f config ] command [ options ... ]'), - description=_('Build a set of modules from diverse repositories in correct dependency order (such as GNOME).')) - parser.disable_interspersed_args() - parser.add_option('--help-commands', action='callback', - callback=help_commands, - help=_('Information about available jhbuild commands')) - parser.add_option('-f', '--file', action='store', metavar='CONFIG', - type='string', dest='configfile', - default=os.environ.get("JHBUILDRC", os.path.join(os.environ['HOME'], '.jhbuildrc')), - help=_('use a non default configuration file')) - parser.add_option('-m', '--moduleset', action='store', metavar='URI', - type='string', dest='moduleset', default=None, - help=_('use a non default module set')) - parser.add_option('--no-interact', action='store_true', - dest='nointeract', default=False, - help=_('do not prompt for input')) - - options, args = parser.parse_args(args) - - try: - config = Config(base_dir, options.configfile) - except FatalError, exc: - sys.stderr.write('sugar-jhbuild: %s\n' % exc.args[0].encode(_encoding, 'replace')) - sys.exit(1) - - if options.moduleset: config.moduleset = options.moduleset - if options.nointeract: config.interact = False - - if not args or args[0][0] == '-': - command = 'build' # default to cvs update + compile - else: - command = args[0] - args = args[1:] - - if command == 'run' and len(args) == 0: - args.append('sugar-emulator') - - warn_local_modulesets(config) - - try: - rc = jhbuild.commands.run(command, config, args) - except UsageError, exc: - sys.stderr.write('sugar-jhbuild %s: %s\n' % (command, exc.args[0].encode(_encoding, 'replace'))) - parser.print_usage() - sys.exit(1) - except FatalError, exc: - sys.stderr.write('sugar-jhbuild %s: %s\n' % (command, exc.args[0].encode(_encoding, 'replace'))) - sys.exit(1) - except KeyboardInterrupt: - uprint(_('Interrupted')) - sys.exit(1) - except EOFError: - uprint(_('EOF')) - sys.exit(1) - except IOError, e: - if e.errno != errno.EPIPE: - raise - sys.exit(0) - if rc: - sys.exit(rc) - diff --git a/scripts/report.py b/scripts/report.py deleted file mode 100644 index 3617ee2..0000000 --- a/scripts/report.py +++ /dev/null @@ -1,186 +0,0 @@ -import os -import urllib -import csv -import smtplib -from optparse import make_option -import StringIO - -from jhbuild.commands import Command, register_command -import jhbuild.moduleset - -def _get_ticket_uri(number): - return 'http://dev.laptop.org/ticket/' + number - -def _send_mail(sender, from_address, to_address, subject, text): - msg = 'From: %s<%s>\nTo: %s\nSubject: %s\n%s' % \ - (sender, from_address, to_address, subject, text) - - server = smtplib.SMTP('localhost') - server.sendmail(from_address, to_address, msg) - server.quit() - -class TextWriter(object): - def __init__(self, out): - self.out = out - - def write_headline(self, headline): - self.out.write('= ' + headline + ' =\n\n') - - def write_tickets(self, tickets, compact=False): - for ticket in tickets: - number = ticket['number'] - summary = ticket['summary'] - if compact: - self.out.write('* #%s %s\n' % (number, summary)) - else: - self.out.write(summary + '\n') - self.out.write(_get_ticket_uri(number) + '\n\n') - - if compact: - self.out.write('\n') - - def write_testcases(self, testcases): - for number, testcase in testcases: - self.out.write('#%s\n\n%s\n\n\n' % (number, testcase)) - -class ReviewsReport(object): - def __init__(self, config): - self._requested = {} - self._approved = {} - self._rejected = {} - self._state_path = os.path.join(config.get_user_path(), 'reviews') - - def generate(self): - f = urllib.urlopen('http://dev.laptop.org/query?' \ - 'format=csv&' \ - 'component=sugar&' \ - 'component=datastore&' \ - 'component=presence-service&' \ - 'component=journal-activity&' \ - 'col=id&col=summary&col=keywords&' \ - 'keywords=~r%2B&keywords=~r-&keywords=~r%3F') - - reader = csv.reader(f) - reader.next() - - for row in reader: - number = row[0] - keyword = row[2] - - ticket = { 'number' : row[0], - 'summary' : row[1] } - - if 'r?' in keyword: - ticket['review_state'] = 'r?' - self._requested[number] = ticket - if 'r+' in keyword: - ticket['review_state'] = 'r+' - self._approved[number] = ticket - if 'r-' in keyword: - ticket['review_state'] = 'r-' - self._rejected[number] = ticket - - f.close() - - def write(self, writer): - old_requested, old_approved, old_rejected = self._load() - - requested = self._diff_tickets(old_requested, self._requested) - approved = self._diff_tickets(old_approved, self._approved) - rejected = self._diff_tickets(old_rejected, self._rejected) - - if requested: - writer.write_headline('New requests') - writer.write_tickets(requested) - - if approved: - writer.write_headline('Approved requests') - writer.write_tickets(approved) - - if rejected: - writer.write_headline('Rejected requests') - writer.write_tickets(rejected) - - def save(self): - s = json.write([self._requested, self._approved, self._rejected]) - - f = open(os.path.join(self._state_path), 'w') - f.write(s) - f.close() - - def _load(self): - path = os.path.join(self._state_path) - if os.path.exists(path): - f = open(path, 'r') - result = json.read(f.read()) - f.close() - - return result - else: - return ({}, {}, {}) - - def _diff_tickets(self, old, new): - diff = [] - for number, ticket in new.items(): - if number in old: - old_ticket = old[number] - if old_ticket['review_state'] != ticket['review_state']: - diff.append(ticket) - else: - diff.append(ticket) - - return diff - -class cmd_report(Command): - - name = 'report' - usage_args = '' - - def __init__(self): - Command.__init__(self, [ - make_option('-t', '--type', action='store', - dest='type', default=None, - help='specify the report type'), - make_option('-s', '--sendto', action='append', - dest='sendto', default=None, - help='send report to the specified mail address') - ]) - - def run(self, config, options, args): - report_types = [ 'reviews' ] - - if options.type not in report_types: - print 'Available reports:\n' + '\n'.join(report_types) - return 1 - - if options.type == 'reviews': - report = ReviewsReport(config) - - report.generate() - - out = StringIO.StringIO() - report.write(TextWriter(out)) - text = out.getvalue() - out.close() - - if options.sendto: - if text: - print 'Sending to ' + ', '.join(options.sendto) - - for to_address in options.sendto: - _send_mail('Release Team', - 'mpgritti@gmail.com', to_address, - 'Reviews report', text) - else: - print 'Empty report, do not send' - else: - print text - - report.save() - -try: - import json - - register_command(cmd_report) -except ImportError: - print 'Disable report, json-py is not installed.' -- cgit v0.9.1