[Checkins] SVN: zc.buildout/branches/tlotze-download-api/src/zc/buildout/ handle the install-from-cache option

Thomas Lotze tl at gocept.com
Thu Jun 11 02:52:41 EDT 2009


Log message for revision 100843:
  handle the install-from-cache option

Changed:
  U   zc.buildout/branches/tlotze-download-api/src/zc/buildout/buildout.py
  U   zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.py
  U   zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.txt
  U   zc.buildout/branches/tlotze-download-api/src/zc/buildout/extends-cache.txt

-=-
Modified: zc.buildout/branches/tlotze-download-api/src/zc/buildout/buildout.py
===================================================================
--- zc.buildout/branches/tlotze-download-api/src/zc/buildout/buildout.py	2009-06-11 06:51:50 UTC (rev 100842)
+++ zc.buildout/branches/tlotze-download-api/src/zc/buildout/buildout.py	2009-06-11 06:52:41 UTC (rev 100843)
@@ -127,7 +127,8 @@
                                     [], None, offline))
 
         extends_cache = data['buildout'].get('extends-cache')
-        offline = offline or data['buildout'].get('offline') == 'true'
+        offline = (offline or data['buildout'].get('offline') == 'true'
+                    or data['buildout'].get('install-from-cache') == 'true')
 
         # load configuration files
         if config_file:
@@ -1219,7 +1220,8 @@
 
     if root_config_file and 'buildout' in result:
         cache = result['buildout'].get('extends-cache', cache)
-        offline = offline or result['buildout'].get('offline') == 'true'
+        offline = (offline or result['buildout'].get('offline') == 'true'
+                   or result['buildout'].get('install-from-cache') == 'true')
 
     if extends:
         extends = extends.split()

Modified: zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.py
===================================================================
--- zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.py	2009-06-11 06:51:50 UTC (rev 100842)
+++ zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.py	2009-06-11 06:52:41 UTC (rev 100843)
@@ -152,7 +152,8 @@
         and scheduled for deletion at process exit.
 
         """
-        if self.buildout.get('offline') == 'true':
+        if (self.buildout.get('offline') == 'true'
+            or self.buildout.get('install-from-cache') == 'true'):
             raise zc.buildout.UserError(
                 "Couldn't download %r in offline mode." % url)
 

Modified: zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.txt
===================================================================
--- zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.txt	2009-06-11 06:51:50 UTC (rev 100842)
+++ zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.txt	2009-06-11 06:52:41 UTC (rev 100843)
@@ -413,8 +413,8 @@
 The wrong text.
 
 
-Specifying offline mode
------------------------
+Specifying offline mode and installation from cache
+---------------------------------------------------
 
 As usual with zc.buildout, the offline option must assume one of the values
 'true' and 'false'. Turning offline mode on with 'true' has been shown above;
@@ -423,3 +423,27 @@
 >>> download = Download({'offline': 'false'})
 >>> cat(download(server_url+'foo.txt'))
 This is a foo text.
+
+Another way to determine offline mode is the ``install-from-cache`` option. It
+accepts the same values as the offline option:
+
+>>> download = Download({'install-from-cache': 'false'})
+>>> cat(download(server_url+'foo.txt'))
+This is a foo text.
+
+>>> download = Download({'install-from-cache': 'true'})
+>>> cat(download(server_url+'foo.txt'))
+Traceback (most recent call last):
+UserError: Couldn't download 'http://localhost/foo.txt' in offline mode.
+
+These two options are combined using logical 'or':
+
+>>> download = Download({'install-from-cache': 'true', 'offline': 'false'})
+>>> cat(download(server_url+'foo.txt'))
+Traceback (most recent call last):
+UserError: Couldn't download 'http://localhost/foo.txt' in offline mode.
+
+>>> download = Download({'install-from-cache': 'false', 'offline': 'true'})
+>>> cat(download(server_url+'foo.txt'))
+Traceback (most recent call last):
+UserError: Couldn't download 'http://localhost/foo.txt' in offline mode.

Modified: zc.buildout/branches/tlotze-download-api/src/zc/buildout/extends-cache.txt
===================================================================
--- zc.buildout/branches/tlotze-download-api/src/zc/buildout/extends-cache.txt	2009-06-11 06:51:50 UTC (rev 100842)
+++ zc.buildout/branches/tlotze-download-api/src/zc/buildout/extends-cache.txt	2009-06-11 06:52:41 UTC (rev 100843)
@@ -256,8 +256,8 @@
 >>> rmdir('user-cache')
 >>> rmdir('cache')
 
-Offline mode
-~~~~~~~~~~~~
+Offline mode and installation from cache
+----------------------------~~~~~~~~~~~~
 
 If we run buildout in offline mode now, it will fail because it cannot get at
 the remote configuration file needed by the user's defaults:
@@ -319,3 +319,59 @@
 ... """ % server_url)
 >>> print system(buildout)
 Unused options for buildout: 'foo'.
+
+The ``install-from-cache`` option is treated accordingly:
+
+>>> write('home', '.buildout', 'default.cfg', """\
+... [buildout]
+... extends = fancy_default.cfg
+... install-from-cache = true
+... """)
+>>> print system(buildout)
+While:
+  Initializing.
+Error: Couldn't download 'http://localhost/base_default.cfg' in offline mode.
+
+>>> write('home', '.buildout', 'default.cfg', """\
+... [buildout]
+... extends = fancy_default.cfg
+... """)
+>>> write('home', '.buildout', 'fancy_default.cfg', """\
+... [buildout]
+... extends = %sbase_default.cfg
+... install-from-cache = true
+... """ % server_url)
+>>> print system(buildout)
+While:
+  Initializing.
+Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
+
+>>> write('home', '.buildout', 'fancy_default.cfg', """\
+... [buildout]
+... extends = %sbase_default.cfg
+... """ % server_url)
+>>> write('buildout.cfg', """\
+... [buildout]
+... extends = fancy.cfg
+... install-from-cache = true
+... """)
+>>> print system(buildout)
+While:
+  Initializing.
+Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
+
+>>> write('buildout.cfg', """\
+... [buildout]
+... extends = fancy.cfg
+... """)
+>>> write('fancy.cfg', """\
+... [buildout]
+... extends = %sbase.cfg
+... install-from-cache = true
+... """ % server_url)
+>>> print system(buildout)
+While:
+  Installing.
+  Checking for upgrades.
+An internal error occured ...
+ValueError: install_from_cache set to true with no download cache



More information about the Checkins mailing list