Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: third_party/boto/pyami/scriptbase.py

Issue 12633019: Added boto/ to depot_tools/third_party (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Moved boto down by one Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/boto/pyami/launch_ami.py ('k') | third_party/boto/pyami/startup.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 import os
2 import sys
3 from boto.utils import ShellCommand, get_ts
4 import boto
5 import boto.utils
6
7 class ScriptBase:
8
9 def __init__(self, config_file=None):
10 self.instance_id = boto.config.get('Instance', 'instance-id', 'default')
11 self.name = self.__class__.__name__
12 self.ts = get_ts()
13 if config_file:
14 boto.config.read(config_file)
15
16 def notify(self, subject, body=''):
17 boto.utils.notify(subject, body)
18
19 def mkdir(self, path):
20 if not os.path.isdir(path):
21 try:
22 os.mkdir(path)
23 except:
24 boto.log.error('Error creating directory: %s' % path)
25
26 def umount(self, path):
27 if os.path.ismount(path):
28 self.run('umount %s' % path)
29
30 def run(self, command, notify=True, exit_on_error=False, cwd=None):
31 self.last_command = ShellCommand(command, cwd=cwd)
32 if self.last_command.status != 0:
33 boto.log.error('Error running command: "%s". Output: "%s"' % (comman d, self.last_command.output))
34 if notify:
35 self.notify('Error encountered', \
36 'Error running the following command:\n\t%s\n\nCommand o utput:\n\t%s' % \
37 (command, self.last_command.output))
38 if exit_on_error:
39 sys.exit(-1)
40 return self.last_command.status
41
42 def main(self):
43 pass
44
OLDNEW
« no previous file with comments | « third_party/boto/pyami/launch_ami.py ('k') | third_party/boto/pyami/startup.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698