starcluster.commands.shell

Package starcluster :: Package commands :: Module shell |
[hide private]
[frames] | no frames]

# Source Code for Module starcluster.commands.shell

     1  #!/usr/bin/env python
     2  import sys
     3
     4  from starcluster import utils
     5  from starcluster.logger import log
     6
     7  from base import CmdBase
     8
     9
    10 -class CmdShell(CmdBase):
    11      """
    12      shell
    13
    14      Load an interactive IPython shell configured for starcluster development
    15
    16      The following objects are automatically available at the prompt:
    17
    18          cfg - starcluster.config.StarClusterConfig instance
    19          ec2 - starcluster.awsutils.EasyEC2 instance
    20          s3 - starcluster.awsutils.EasyS3 instance
    21
    22      All starcluster modules are automatically imported in the IPython session
    23      along with the boto and paramiko modules
    24      """
    25      names = ['shell', 'sh']
    26
    27 -    def execute(self, args):
    28          local_ns = dict(cfg=self.cfg, ec2=self.ec2, s3=self.s3, cm=self.cm)
    29          import starcluster
    30          local_ns.update(dict(starcluster=starcluster))
    31          modules = [(starcluster.__name__ + '.' + i, i) \
    32                     for i in starcluster.__all__]
    33          modules += [('boto', 'boto'), ('paramiko', 'paramiko')]
    34          for fullname, modname in modules:
    35              log.info('Importing module %s' % modname)
    36              try:
    37                  __import__(fullname)
    38                  local_ns[modname] = sys.modules[fullname]
    39              except ImportError, e:
    40                  log.error("Error loading module %s: %s" % (modname, e))
    41          utils.ipy_shell(local_ns=local_ns)
    42