/usr/bin/jitsu is in juju-jitsu 0.20-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | #!/usr/bin/env python
#
# jitsu - external tools for working with juju
# Copyright 2012 Canonical Ltd. All Rights Reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import argparse
import os
import sys
from os.path import abspath, join, dirname, expanduser, isdir, isfile
from juju.control import JujuFormatter
subcommand_home = abspath(join(dirname(__file__),'..','sub-commands'))
if not isdir(subcommand_home):
subcommand_home="/usr/share/juju-jitsu/sub-commands"
sys.path.insert(0, subcommand_home) # Ensure the aiki subdirectory can be imported
from aiki.cli import add_command_help, get_commands
parser = argparse.ArgumentParser(
formatter_class=JujuFormatter,
description='External tools for working with Juju')
parser.add_argument('--version', action='version', version='%(prog)s 0.20')
# Create a mapping of commands to their details (such as their source
# directories); this two-step process enables user plugins to override
# existing commands
cmds = dict(get_commands(subcommand_home))
user_subcommands = expanduser("~/.juju-jitsu/plugins")
if isdir(user_subcommands):
cmds.update(get_commands(user_subcommands))
subparser = parser.add_subparsers(description = 'Subcommands for jitsu', dest='subcommand')
help_parser = subparser.add_parser('help',
description='Get detailed subcommand help',
help='get subcommand help')
help_parser.add_argument('help_subcommand', choices=sorted(cmds))
for cmd, details in sorted(cmds.iteritems()):
add_command_help(subparser, subcommand_home, cmd, details)
args, cmd_args = parser.parse_known_args()
run_cmd = args.subcommand
if args.subcommand == 'help':
run_cmd = args.help_subcommand
cmd_args = ['--help']
else:
cmd_args = sys.argv[2:]
def is_executable(path):
return isfile(path) and os.access(path, os.X_OK)
user_path = expanduser(join(user_subcommands, run_cmd))
if is_executable(user_path):
os.execv(user_path, [user_path] + cmd_args)
subcommand_path = join(subcommand_home, run_cmd)
if is_executable(subcommand_path):
os.execv(subcommand_path, [subcommand_path] + cmd_args)
os.execvp('juju', ['juju', run_cmd] + cmd_args)
|