diff options
author | Milo Casagrande <milo@ubuntu.com> | 2013-01-22 14:58:32 +0100 |
---|---|---|
committer | Milo Casagrande <milo@ubuntu.com> | 2013-01-22 14:58:32 +0100 |
commit | 59714937019a44830977973111e9b0def7b1d647 (patch) | |
tree | f414d461c5bd57d295656b517530bcf9116bce37 | |
parent | e4488630768e8624def0bcbe79282c4eda083e4b (diff) |
Added assume_yes option to setup process, fixed print statements.
-rw-r--r-- | scripts/rhodecode-setup | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/scripts/rhodecode-setup b/scripts/rhodecode-setup index 0af375e..60b74ff 100644 --- a/scripts/rhodecode-setup +++ b/scripts/rhodecode-setup @@ -198,10 +198,7 @@ def setup_directories(data_dir, repos_dir, rhodecode_usr): def execute_command(cmd_args, work_dir=os.getcwd(), with_sudo=True, - input_str=None, - stderr=subprocess.PIPE, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE): + input_str=None): """Runs the command passed. :param cmd_args: List of command and options to run. @@ -222,15 +219,12 @@ def execute_command(cmd_args, if input_str: process = subprocess.Popen(cmd_args, cwd=work_dir, - stderr=stderr, - stdin=stdin) - p_out, p_err = process.communicate(input=input_str) + stdin=subprocess.PIPE) + process.communicate(input=input_str) else: process = subprocess.Popen(cmd_args, - cwd=work_dir, - stderr=stderr, - stdout=stdout) - p_out, p_err = process.communicate() + cwd=work_dir) + process.communicate() if process.returncode != 0: print "Error executing the following command: %s" % " ".join(cmd_args) sys.exit(1) @@ -399,11 +393,11 @@ def install_rhodecode(work_dir): :type str """ cmd_args = ["python", "setup.py", "install"] - execute_command(cmd_args, work_dir=work_dir, with_sudo=True) + execute_command(cmd_args, work_dir=work_dir) def setup_rhodecode(rhodecode_dir, config_file, git_repos, admin_usr, - admin_pwd, admin_email, user=None): + admin_pwd, admin_email, user=None, assume_yes=False): """Sets up RhodeCode instance. :param rhodecode_dir: The directory where RhodeCode code was checked out. @@ -418,7 +412,10 @@ def setup_rhodecode(rhodecode_dir, config_file, git_repos, admin_usr, :type str :param user: The user to run the process as. :type str + :param assume_yes: If answers should be automated. Default False. + :type bool """ + input_str = None usr_arg = "--user=%s" % admin_usr pwd_arg = "--password=%s" % admin_pwd email_arg = "--email=%s" % admin_email @@ -433,7 +430,9 @@ def setup_rhodecode(rhodecode_dir, config_file, git_repos, admin_usr, cmd_args.append(email_arg) cmd_args.append(repos) - execute_command(cmd_args, work_dir=rhodecode_dir, stderr=None) + if assume_yes: + input_str = "Y" + execute_command(cmd_args, work_dir=rhodecode_dir, input_str=input_str) def install_upstart_conf(no_celery): @@ -482,7 +481,7 @@ def print_install_report(args, home_dir, config_file): :param args: The command line arguments. """ print "\n\nRhodeCode Linaro Installation Report\n" - print "\nRhodeCode Information" + print "\nRhodeCode Information\n" print "\tCode cloned from: %s" % args.rhodecode_git_url print "\tInstallation Dir: %s" % home_dir print "\tConfiguration file: %s" % config_file @@ -565,7 +564,8 @@ if __name__ == '__main__': args.rhodecode_admin_usr, args.rhodecode_admin_pwd, args.rhodecode_admin_email, - args.rhodecode_usr) + args.rhodecode_usr, + args.assume_yes) install_upstart_conf(args.no_celery) |