Sfoglia il codice sorgente

brew: added safeguards in script and changed default branch to 'master'

shin- 12 anni fa
parent
commit
6178dc7f1b
3 ha cambiato i file con 17 aggiunte e 5 eliminazioni
  1. 1 1
      contrib/brew/README.md
  2. 8 2
      contrib/brew/brew/brew.py
  3. 8 2
      contrib/brew/docker-brew

+ 1 - 1
contrib/brew/README.md

@@ -8,7 +8,7 @@ docker-brew is a command-line tool used to build the docker standard library.
 1. Install the easy_install tool (`sudo apt-get install python-setuptools`
 for Debian)
 1. Install the python package manager, `pip` (`easy_install pip`)
-1. Run the following command: `pip install -r requirements.txt`
+1. Run the following command: `sudo pip install -r requirements.txt`
 1. You should now be able to use the `docker-brew` script as such.
 
 ## Basics

+ 8 - 2
contrib/brew/brew/brew.py

@@ -7,7 +7,7 @@ import docker
 import git
 
 DEFAULT_REPOSITORY = 'git://github.com/dotcloud/docker'
-DEFAULT_BRANCH = 'library'
+DEFAULT_BRANCH = 'master'
 
 logger = logging.getLogger(__name__)
 logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
@@ -36,7 +36,13 @@ def build_library(repository=None, branch=None, namespace=None, push=False,
     if not dst_folder:
         logger.info('Cloning docker repo from {0}, branch: {1}'.format(
             repository, branch))
-        dst_folder = git.clone_branch(repository, branch)
+        try:
+            dst_folder = git.clone_branch(repository, branch)
+        except Exception as e:
+            logger.exception(e)
+            logger.error('Source repository could not be fetched. Check '
+                'that the address is correct and the branch exists.')
+            return
     for buildfile in os.listdir(os.path.join(dst_folder, 'library')):
         if buildfile == 'MAINTAINERS':
             continue

+ 8 - 2
contrib/brew/docker-brew

@@ -1,9 +1,15 @@
 #!/usr/bin/env python
 
 import argparse
+import sys
 
-import brew
-
+try:
+    import brew
+except ImportError as e:
+    print str(e)
+    print 'Please install the required dependencies first'
+    print 'sudo pip install -r requirements.txt'
+    sys.exit(1)
 
 if __name__ == '__main__':
     parser = argparse.ArgumentParser('Build the docker standard library')