Example #1
0
def build_kaylee(opts):
    print('* Copying Kaylee test server files...')
    KLCL_TEMPLATE_DIR = 'templates/build_template'
    KLCL_TEMPLATE_PATH = os.path.join(os.path.dirname(__file__),
                                      KLCL_TEMPLATE_DIR)

    KLCL_CLIENT_PATH = os.path.join(os.path.dirname(kaylee.__file__),
                                    'client')
    CLIENT_FILES = [
        ('kaylee.js', 'kaylee/js/kaylee.js'),
        ('klworker.js', 'kaylee/js/klworker.js'),
    ]

    TEMPLATE_FILES = [
        ('css/klconsole.css', 'kaylee/css/klconsole.css'),
        ('js/kldebug.js', 'kaylee/js/kldebug.js'),
        ('js/jquery.min.js', 'kaylee/js/jquery.min.js'),
        ('index.html', 'index.html'),
    ]

    dest_path = os.path.join(os.getcwd(), opts.build_dir)
    ensure_dir(os.path.join(dest_path, 'kaylee/js'))
    ensure_dir(os.path.join(dest_path, 'kaylee/css'))

    for fname, out_fname in CLIENT_FILES:
        fpath = os.path.join(KLCL_CLIENT_PATH, fname)
        dest_fpath = os.path.join(dest_path, out_fname)
        shutil.copy(fpath, dest_fpath)

    for fname, out_fname in TEMPLATE_FILES:
        fpath = os.path.join(KLCL_TEMPLATE_PATH, fname)
        dest_fpath = os.path.join(dest_path, out_fname)
        shutil.copy(fpath, dest_fpath)
Example #2
0
def stylesheet_handler(fpath, opts):
    if not fpath.endswith('.css'):
        return False

    dest_dir = os.path.join(opts.dest_dir, 'css')
    ensure_dir(dest_dir)
    shutil.copy(fpath, dest_dir)
    return True
Example #3
0
def coffee_handler(fpath, opts):
    if not fpath.endswith('.coffee'):
        return False

    args = ['coffee', '--bare', '-c', fpath]
    proc = subprocess.Popen(args,
                            close_fds=True,
                            stdin=subprocess.PIPE,
                            stdout = subprocess.PIPE,
                            stderr = subprocess.PIPE)
    #pylint: disable-msg=W0612
    #W0612: Unused variable 'stdoutdata'
    stdoutdata, stderrdata = proc.communicate()
    if stderrdata is not '':
        raise Exception('Error compiling .coffee script:\n{}'
                        .format(stderrdata))

    dest_dir = os.path.join(opts.dest_dir, 'js')
    ensure_dir(dest_dir)
    outpath = fpath.rsplit('.coffee', 1)[0] + '.js'
    shutil.move(outpath, dest_dir)
    return True
Example #4
0
def data_handler(fpath, opts):
    dest_dir = os.path.join(opts.dest_dir, 'data')
    ensure_dir(dest_dir)
    shutil.copy(fpath, dest_dir)
    return True