From cc034825744856b9936a518cef0215d9096a8f98 Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Fri, 16 Nov 2012 09:07:19 +0000 Subject: Port auto-install and send-patches to the new commands scheme --- (limited to 'scripts') diff --git a/scripts/shell/auto-install b/scripts/shell/auto-install deleted file mode 100755 index 327d46d..0000000 --- a/scripts/shell/auto-install +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/python - -from distutils.sysconfig import parse_makefile -import os -import shutil - -from gi.repository import Gio -from gi.repository import GLib - -shell_dir = os.path.abspath(os.path.dirname(__file__)) -scripts_dir = os.path.dirname(shell_dir) -root_dir = os.path.dirname(scripts_dir) -source_dir = os.path.join(root_dir, "source") -build_dir = os.path.join(root_dir, "build") - -monitors = [] - -def install(file): - dir = os.path.dirname(file.get_path()) - relative_path = os.path.relpath(dir, source_dir) - makefile_path = os.path.join(build_dir, relative_path, "Makefile") - makefile = parse_makefile(makefile_path) - - for variable in makefile: - if variable.endswith("_PYTHON"): - dir_variable = "%sdir" % variable.replace("_PYTHON", "") - install_dir = makefile[dir_variable] - shutil.copy(file.get_path(), install_dir) - -def changed_cb(monitor, file, other_file, event_flags): - if event_flags == Gio.FileMonitorEvent.CHANGED: - if file.get_path().endswith(".py"): - install(file) - -for root, dirs, files in os.walk(os.getcwd()): - for dir in dirs: - file = Gio.File.new_for_path(os.path.join(root, dir)) - monitor = file.monitor(Gio.FileMonitorFlags.NONE, None) - monitor.connect("changed", changed_cb) - - monitors.append(monitor) - -main_loop = GLib.MainLoop() -main_loop.run() diff --git a/scripts/shell/send-patches b/scripts/shell/send-patches deleted file mode 100755 index d420357..0000000 --- a/scripts/shell/send-patches +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/python - -import argparse -import os -import re -import subprocess -import sys - -GIT_CONFIG_SETUP = "sugar-build.send-patches.setup" - -shell_dir = os.path.abspath(os.path.dirname(__file__)) -scripts_dir = os.path.dirname(shell_dir) -root_dir = os.path.dirname(scripts_dir) -source_dir = os.path.join(root_dir, "source") - -def get_git_config(name, is_global=False): - args = ["git", "config"] - - if is_global: - args.append("--global") - - args.append(name) - - try: - return subprocess.check_output(args) - except subprocess.CalledProcessError: - return None - -def set_git_config(name, value): - return subprocess.check_output(["git", "config", name, value]) - -def unset_git_config(name): - try: - subprocess.check_output(["git", "config", "--unset", name]) - return True - except subprocess.CalledProcessError: - return False - -def get_from(): - name = get_git_config("user.name", is_global=True) - email = get_git_config("user.email", is_global=True) - - if not name or not email: - print "Please configure your name and email\n\n" \ - "git config --global user.name Your Name\n" \ - "git config --global user.email youremail@example.com" - sys.exit(1) - - return "%s <%s>" % (name, email) - -def get_module(): - for line in open("configure.ac"): - m = re.match("AC_INIT\((.+)\)", line) - if m: - return m.group(1).split(",")[-1][1:-1] - -def setup(): - print "Choose how to send email \n\n" \ - "1 Google account\n" \ - "2 Sugar Labs shell account\n" \ - "3 System sendmail" - - choice = None - - while choice not in ["1", "2", "3"]: - choice = raw_input("# ") - - if choice == "1": - print "\nEnter your user name" - smtpuser = raw_input("# ") - - set_git_config("sendemail.smtpencryption", "tls") - set_git_config("sendemail.smtpserver", "smtp.gmail.com") - set_git_config("sendemail.smtpserverport", "587") - set_git_config("sendemail.smtpuser", smtpuser) - elif choice == "2": - print "\nEnter your user name" - smtpuser = raw_input("# ") - - set_git_config("sendemail.smtpencryption", "tls") - set_git_config("sendemail.smtpserver", "smtp.sugarlabs.org") - set_git_config("sendemail.smtpserverport", "587") - set_git_config("sendemail.smtpuser", smtpuser) - elif choice == "3": - unset_git_config("sendemail.smtpencryption") - unset_git_config("sendemail.smtpserver") - unset_git_config("sendemail.smtpserverport") - unset_git_config("sendemail.smtpuser") - - set_git_config(GIT_CONFIG_SETUP, "true") - -if os.path.dirname(os.getcwd()) != source_dir: - print "The command must be run inside one of the source modules." - sys.exit(1) - -parser = argparse.ArgumentParser() -parser.add_argument("--setup", action="store_true", - help="interactive configuration") -parser.add_argument('rev_list', nargs='?', default='origin') - -args = parser.parse_args() - -if not get_git_config(GIT_CONFIG_SETUP) or args.setup: - setup() - -subprocess.call(["git", "send-email", - "-from", get_from(), - "-to", "sugar-devel ", - "--subject-prefix", "PATCH %s" % get_module(), - args.rev_list]) -- cgit v0.9.1