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

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

Issue 12042069: Scripts to download files from google storage based on sha1 sums (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Removed gsutil/tests and gsutil/docs Created 7 years, 10 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
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

Powered by Google App Engine
This is Rietveld 408576698