Sha256: e452de9a779de582df507a56491e1212c0335a8f1b817087834154071690401b

Contents?: true

Size: 1.39 KB

Versions: 55

Compression:

Stored size: 1.39 KB

Contents

import os
import sys
from boto.utils import ShellCommand, get_ts
import boto
import boto.utils

class ScriptBase:

    def __init__(self, config_file=None):
        self.instance_id = boto.config.get('Instance', 'instance-id', 'default')
        self.name = self.__class__.__name__
        self.ts = get_ts()
        if config_file:
            boto.config.read(config_file)

    def notify(self, subject, body=''):
        boto.utils.notify(subject, body)

    def mkdir(self, path):
        if not os.path.isdir(path):
            try:
                os.mkdir(path)
            except:
                boto.log.error('Error creating directory: %s' % path)

    def umount(self, path):
        if os.path.ismount(path):
            self.run('umount %s' % path)

    def run(self, command, notify=True, exit_on_error=False, cwd=None):
        self.last_command = ShellCommand(command, cwd=cwd)
        if self.last_command.status != 0:
            boto.log.error('Error running command: "%s". Output: "%s"' % (command, self.last_command.output))
            if notify:
                self.notify('Error encountered', \
                        'Error running the following command:\n\t%s\n\nCommand output:\n\t%s' % \
                        (command, self.last_command.output))
            if exit_on_error:
                sys.exit(-1)
        return self.last_command.status

    def main(self):
        pass
        

Version data entries

55 entries across 55 versions & 3 rubygems

Version Path
libv8-7.8.279.23.0beta1 vendor/depot_tools/third_party/boto/pyami/scriptbase.py
libv8-7.4.288.28.0beta1 vendor/depot_tools/third_party/boto/pyami/scriptbase.py
libv8-7.3.492.27.3beta1 vendor/depot_tools/third_party/boto/pyami/scriptbase.py
libv8-7.3.492.27.1 vendor/depot_tools/third_party/boto/pyami/scriptbase.py
libv8-7.3.492.27.0 vendor/depot_tools/third_party/boto/pyami/scriptbase.py
libv8-7.3.492.27.0beta1 vendor/depot_tools/third_party/boto/pyami/scriptbase.py
libv8-6.7.288.46.1 vendor/depot_tools/third_party/boto/pyami/scriptbase.py
libv8-6.7.288.46.0 vendor/depot_tools/third_party/boto/pyami/scriptbase.py
libv8-6.7.288.46.1beta0 vendor/depot_tools/third_party/boto/pyami/scriptbase.py
libv8-6.3.292.48.1 vendor/depot_tools/third_party/boto/pyami/scriptbase.py
libv8-6.3.292.48.0 vendor/depot_tools/third_party/boto/pyami/scriptbase.py
libv8-6.3.292.48.0beta2 vendor/depot_tools/third_party/boto/pyami/scriptbase.py
libv8-6.3.292.48.0beta1 vendor/depot_tools/third_party/boto/pyami/scriptbase.py
libv8-6.2.414.42.1 vendor/depot_tools/third_party/boto/pyami/scriptbase.py
libv8-6.2.414.42.0 vendor/depot_tools/third_party/boto/pyami/scriptbase.py
libv8-6.2.414.42.0beta1 vendor/depot_tools/third_party/boto/pyami/scriptbase.py
libv8-6.0.286.54.3 vendor/depot_tools/third_party/boto/pyami/scriptbase.py
libv8-6.0.286.54.2 vendor/depot_tools/third_party/boto/pyami/scriptbase.py
libv8-6.0.286.54.1 vendor/depot_tools/third_party/boto/pyami/scriptbase.py
libv8-6.0.286.54.0 vendor/depot_tools/third_party/boto/pyami/scriptbase.py