def fridge_refill(appname, flavor="default", refill_behavior= RB_IGNORE): ''' refill fridge: appname, flavor, refill_behavior refill_behavior= "abort-if-existing" abort if file to be downloaded already exists "ignore-if-existing" ignore file to be downloaded if already exists "update-if-different" update file if file to be downloaded is unequal stored file "overwrite-existing" download file and overwrite regardless if already there and equal ''' if refill_behavior not in REFILL_BEHAVIOR: abort("refill behavior can be only one of %s" % str(REFILL_BEHAVIOR)) if not os.path.exists(_fridgedir()): os.makedirs(_fridgedir()) appconfigfile = os.path.join(fabdir(), appname, 'application.py') appconfig = import_from(appconfigfile) try: package_bundles = appconfig.package_bundles except AttributeError: abort('package_bundles is not defined') try: package_bundle = package_bundles[flavor] except KeyError: abort('No flavor "%s"\n' % flavor) package_bundle= package_merge(package_bundle) for line in package_bundle.splitlines(): (name, pkgtype, platform, resource, url, opt1, opt2) = packageline_split(line) if name is None: continue if resource not in ['https', 'http', 'ftp', 'pypi']: continue if resource == "pypi": url = url.replace('\\','') elif resource in ["http", "https", "ftp"]: url = "".join((resource,":",url)) print "freezing ", name, pkgtype, platform, resource, url, opt1, opt2, " as ", _frozenname(resource, url) _transfer_to_fridge(resource, url, refill_behavior)
def _get_appconfig(appname): dirname = os.path.dirname(env.real_fabfile) appconfigfile = os.path.join(dirname, appname, 'application.py') appconfig = import_from(appconfigfile) return appconfig