def main(): topdir = detect_topdir() if topdir is None: print('Could not locate topdir. You must run ``gloabl-wasp`` ' 'either from a file tree' 'containing a ``wasp`` file or from a build directory ' 'containing an initialized `{0}` file.'.format(CACHE_FILE)) sys.exit(1) unpack_dir = os.path.join(topdir, UNPACK_DIR) if not os.path.exists(unpack_dir): fname = os.path.join(topdir, 'wasp') code = [] with open(fname, 'r') as f: start = False for line in f: if 'wasp_packed=[' in line: start = True if line == '\n' and start: break if start: code.append(line) vs = {} exec(''.join(code), vs, vs) unpack(unpack_dir, vs['wasp_packed']) sys.path.append(unpack_dir) run(topdir, unpack_dir)
def run(topdir, unpack_dir): # make sure cwd is the directory in which the wasp script # is. Thus, topdir gets set to cwd. os.chdir(topdir) try: wasp = __import__('wasp') except ImportError: raise WaspInstallationError('Something went wrong during the installation. Does {0} directory with all wasp files exist?'.format(UNPACK_DIR)) # run the main routine from wasp.main import run success = run(topdir) if success: sys.exit(0) else: sys.exit(1)