def saveTest(request, fullpath): if fullpath == 'settings': fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'virtual_paths.py') url = request.POST["url"].lstrip('/') stub(url, request) tools.savetest(request.POST["content"], fullpath) return HttpResponseRedirect('/' + url + '?editor')
def runTest(request, fullpath): path = contrib.normpath(request.REQUEST["path"]) context_name = request.REQUEST.get("context", None) ctx = context.get(fullpath, section=context_name) log.info('run test %s with context %s' % (path, context_name)) server = request.get_host() contextjs = context.render(path, ctx, server) log.debug('contextJS: '+ contextjs) clean_path = contrib.get_relative_clean_path(path) target = contrib.get_runner_url(ctx, server) log.info('target of test %s is %s' % (clean_path, target)) tools.savetest(request.REQUEST.get('content', None), fullpath) test_content = request.REQUEST.get("content", open(fullpath, 'r').read()) #if contrib.target_is_remote( target, server): # log.debug('TARGET: %s, %s' % ( target, server )) # url = "http://%s/%s" % (target, settings.UPLOAD_TESTS_CMD) # saveRemoteContext(os.path.dirname(clean_path), contextjs, url, ctx) # distributor.saveTestSatelliteScripts(url, path, ctx) # distributor.sendContentToRemote(clean_path, test_content, url, ctx) # url = "http://%s/%s?path=/%s" % (target, settings.EXEC_TESTS_CMD, clean_path) #else: # saveLocalContext(fullpath, contextjs) # url = "http://%s/%s?path=/%s" % (target, settings.EXEC_TESTS_CMD, clean_path) saveLocalContext(fullpath, contextjs) if coffee(path): path = coffeescript.compile(test_content, path, fullpath) url = "http://%s/%s?server=%s&path=/%s" % (target, settings.EXEC_TESTS_CMD, server, path) log.info("redirect to run test %s" % url) return HttpResponseRedirect(url)
def save(full_path, path, out): coffee_name, js_name = coffee2js(full_path) full_path = full_path.replace(coffee_name, js_name) if os.path.exists(full_path): os.remove(full_path) if out: dir_index_tools.savetest(out.decode("utf-8"), full_path) return path.replace(coffee_name, js_name) if path else None
def compile(source, path, full_path): args = shlex.split("%s -c -b -s -p" % COFFEESCRIPT_EXECUTABLE) if not source: source = dir_index_tools.gettest(full_path) else: source = source.encode('utf-8') p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE) out, errors = p.communicate(source) coffee_name, js_name = coffee2js(full_path) full_path = full_path.replace(coffee_name, js_name) if os.path.exists(full_path): os.remove(full_path) if out: dir_index_tools.savetest(out.decode("utf-8"), full_path) #return errors return path.replace(coffee_name, js_name) if path else None
def runTest(request, fullpath): path = contrib.normpath(request.REQUEST["path"]) context_name = request.REQUEST.get("context", None) ctx = context.get(fullpath, section=context_name) log.info('run test %s with context %s' % (path, context_name)) server = request.get_host() contextjs = context.render(path, ctx, server, context_name) log.debug('contextJS: '+ contextjs) clean_path = contrib.get_relative_clean_path(path) target = contrib.get_runner_url(ctx, server) log.info('target of test %s is %s' % (clean_path, target)) tools.savetest(request.REQUEST.get('content', None), fullpath) test_content = request.REQUEST.get("content", open(fullpath, 'r').read()) saveLocalContext(fullpath, contextjs) if coffee(path): path = coffeescript.compile2js(test_content, path, fullpath) url = "http://%s/%s?server=%s&path=/%s" % (target, settings.EXEC_TESTS_CMD, server, path) log.info("redirect to run test %s" % url) return HttpResponseRedirect(url)
try: py_compile.compile(path, path+'c', path+'d', True) return True except: return False finally: clean(path) clean(path+'c') clean(path+'d') if not checkSyntax( content ): descriptor = live_settings_json(request, content) descriptor.update({ 'error': 'File got a syntax error' }) return _render_to_response('configure.html', descriptor, context_instance=RequestContext(request)) tools.savetest(request.POST["content"], fullpath) return HttpResponseRedirect('/settings') def report_callback(req): import reporting try: event = req.GET.get('event') if event == 'begin': reporting.start(req.GET) elif event == 'done': reporting.done(req.GET) elif event == 'testDone': reporting.save(req.GET) elif event == 'html': reporting.add_html(req.GET) else: