Commit 9bf0241a authored by Julien Muchembled's avatar Julien Muchembled

Cleanup imports

parent 9bb2c613
import errno import errno
from hashlib import md5
import slapos.recipe.downloadunpacked
import imp import imp
import logging import logging
import os import os
import pkg_resources
from platform import machine as platform_machine
import re import re
import shutil import shutil
import stat import stat
import subprocess import subprocess
import sys import sys
from hashlib import md5
from platform import machine as platform_machine
import pkg_resources
import zc.buildout import zc.buildout
from zc.buildout import UserError
from zc.buildout.buildout import bool_option from zc.buildout.buildout import bool_option
from slapos.recipe import downloadunpacked
startup_environ = os.environ.copy() startup_environ = os.environ.copy()
...@@ -62,7 +63,7 @@ class Recipe(object): ...@@ -62,7 +63,7 @@ class Recipe(object):
shared = ((options.get('shared', '').lower() == 'true') and shared = ((options.get('shared', '').lower() == 'true') and
buildout['buildout'].get('shared-part-list', None)) buildout['buildout'].get('shared-part-list', None))
if shared: if shared:
self._signature = slapos.recipe.downloadunpacked.Signature( self._signature = downloadunpacked.Signature(
'.slapos.recipe.cmmi.signature') '.slapos.recipe.cmmi.signature')
buildout_directory = buildout['buildout']['directory'] buildout_directory = buildout['buildout']['directory']
profile_base_location = options.get('_profile_base_location_', '') profile_base_location = options.get('_profile_base_location_', '')
...@@ -105,9 +106,9 @@ class Recipe(object): ...@@ -105,9 +106,9 @@ class Recipe(object):
options['strip-top-level-dir'] = options.get('strip-top-level-dir', 'false').strip() options['strip-top-level-dir'] = options.get('strip-top-level-dir', 'false').strip()
if options['url'] and options['path']: if options['url'] and options['path']:
raise zc.buildout.UserError('You must use either "url" or "path", not both!') raise UserError('You must use either "url" or "path", not both!')
if not (options['url'] or options['path']): if not (options['url'] or options['path']):
raise zc.buildout.UserError('You must provide either "url" or "path".') raise UserError('You must provide either "url" or "path".')
if options['url']: if options['url']:
options['compile-directory'] = location + '__compile__' options['compile-directory'] = location + '__compile__'
...@@ -125,7 +126,7 @@ class Recipe(object): ...@@ -125,7 +126,7 @@ class Recipe(object):
key, value = variable.split('=', 1) key, value = variable.split('=', 1)
self.environ[key.strip()] = value self.environ[key.strip()] = value
except ValueError: except ValueError:
raise zc.buildout.UserError('Invalid environment variable definition: %s' % variable) raise UserError('Invalid environment variable definition: %s' % variable)
# Add prefix to PATH, CPPFLAGS, CFLAGS, CXXFLAGS, LDFLAGS # Add prefix to PATH, CPPFLAGS, CFLAGS, CXXFLAGS, LDFLAGS
if self.buildout_prefix != '': if self.buildout_prefix != '':
self.environ['PATH'] = '%s/bin:%s' % (self.buildout_prefix, self.environ.get('PATH', '/usr/bin')) self.environ['PATH'] = '%s/bin:%s' % (self.buildout_prefix, self.environ.get('PATH', '/usr/bin'))
...@@ -210,7 +211,7 @@ class Recipe(object): ...@@ -210,7 +211,7 @@ class Recipe(object):
universal_newlines=True, close_fds=True) universal_newlines=True, close_fds=True)
except Exception as e: except Exception as e:
self.logger.error(e) self.logger.error(e)
raise zc.buildout.UserError('System error') raise UserError('System error')
return files.splitlines() return files.splitlines()
def check_promises(self): def check_promises(self):
...@@ -250,7 +251,7 @@ class Recipe(object): ...@@ -250,7 +251,7 @@ class Recipe(object):
env=self.augmented_environment(), close_fds=True) env=self.augmented_environment(), close_fds=True)
except Exception as e: except Exception as e:
self.logger.error(e) self.logger.error(e)
raise zc.buildout.UserError('System error') raise UserError('System error')
def install(self): def install(self):
log = self.logger log = self.logger
...@@ -310,8 +311,7 @@ class Recipe(object): ...@@ -310,8 +311,7 @@ class Recipe(object):
opt['destination'] = compile_dir opt['destination'] = compile_dir
# no need to shared build for compile dir # no need to shared build for compile dir
opt['shared'] = 'false' opt['shared'] = 'false'
slapos.recipe.downloadunpacked.Recipe( downloadunpacked.Recipe(self.buildout, self.name, opt).install()
self.buildout, self.name, opt).install()
except: except:
shutil.rmtree(compile_dir) shutil.rmtree(compile_dir)
raise raise
...@@ -441,7 +441,7 @@ echo %s ...@@ -441,7 +441,7 @@ echo %s
self.fix_shebang(location) self.fix_shebang(location)
if self.options['shared']: if self.options['shared']:
slapos.recipe.downloadunpacked.make_read_only_recursively(location) downloadunpacked.make_read_only_recursively(location)
return parts return parts
def fix_shebang(self, location): def fix_shebang(self, location):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment