def patch(request): path = get_path(request) if path: document_root = contrib.get_document_root(path) full_path = contrib.get_full_path(document_root, path) log.debug('add full path for %s path: %s , fullpath: %s' % (fn, path, full_path)) return fn(request, contrib.get_full_path(document_root, path)) return fn(request)
def uploadFolderToRemote(folder_content, virtual_path, document_root, ctx, url, name): for file_ in folder_content: file_path = os.path.join(virtual_path, file_) rel_path = contrib.get_relative_clean_path(file_path) fullpath = contrib.get_full_path(document_root, file_path) result = uploadContentToRemote(url, fullpath, rel_path, ctx) log.info("%s %s is saved: %s" % (name, file_path, result))
def saveAllLibraries(document_root, virtual_root, url, path, ctx): for lib in contrib.get_libraries(path, ctx): lib_relpath = contrib.get_lib_path_by_name(document_root, lib, ctx) if lib_relpath: lib_path = os.path.join(virtual_root, lib_relpath) fullpath = contrib.get_full_path(document_root, lib_path) result = uploadContentToRemote(url, fullpath, lib_relpath, ctx) log.info("library %s is saved: %s" % (lib_relpath, result))
def saveToolsAllScripts(url, document_root, virtual_root, ctx): tools_dirs = contrib.get_context_tools_folders(ctx) for tools_dir in tools_dirs: log.info('save tools folder: %s' % tools_dir) virtual_path = os.path.join(virtual_root, tools_dir) tools_dir_fullpath = contrib.get_full_path(document_root, virtual_path) files = contrib.enum_files_in_folders(tools_dir_fullpath) uploadFolderToRemote(files, virtual_path, document_root, ctx, url, 'tools script')
def show_context(request, path): document_root = contrib.get_document_root(path) fullpath = contrib.get_full_path(document_root, path) log.debug('show context of %s (%s %s)' % (fullpath, document_root, path)) result = "" sections = config.sections(context.get(fullpath).inifile) for section_name in sections: ctx = context.get(fullpath, section=section_name) context_ini = context.render_ini(path, ctx, request.get_host(), section_name) result += context_ini return HttpResponse(result)
def search_view_ext(request, path=None, search_pattern=None, as_json=False, global_search=True): path = request.GET.get('path', path) search_pattern = request.GET.get('search_pattern',search_pattern) as_json = request.GET.get('as_json', as_json) document_root = contrib.get_document_root(path) if global_search: path = contrib.get_virtual_root(path) full_path = contrib.get_full_path(document_root, path) print path, full_path, document_root folders = [ full_path ] log.debug(locals()) if os.path.isfile(full_path): folders = [ os.path.dirname(full_path) ] path = os.path.dirname( path ) return search_view(request, folders, path, search_pattern, as_json)
def serve(request, path, show_indexes=False): document_root = contrib.get_document_root(path) fullpath = contrib.get_full_path(document_root, path) log.debug('show index of %s(%s %s)' % (fullpath, document_root, path)) if os.path.isdir(fullpath): if 'history' in request.REQUEST: import reporting context = request.REQUEST.get('context') date = request.REQUEST.get('history', None) asxml = request.REQUEST.get('xml', None) asjson = request.REQUEST.get('json', None) if not date: results = reporting.getSuiteHistoryResults(path, context) return _render_to_response('history_list.html', locals()) if asxml: tests_list = reporting.getResultsAsXml(path, context, date, request) return HttpResponse(tests_list) tests_list = reporting.getResults(path, context, date) if asjson: url = reporting.getTestResultsUrl(path, context, date, request) result = { 'url': url, 'data': tests_list } return HttpResponse(json.dumps(result)) return _render_to_response('history.html', locals()) if request.path and request.path[-1:] != '/': return HttpResponseRedirect(request.path + '/') if show_indexes: template = load_index_template() descriptor = get_dir_index(document_root, path, fullpath) return HttpResponse(template.render(descriptor)) if not os.path.exists(fullpath): if 'editor' in request.REQUEST: #open(fullpath, 'w').close() # creating file if not exists by editor opening it first time tools.make(fullpath) else: raise Http404('"%s" does not exist' % fullpath) if 'editor' in request.REQUEST: descriptor = get_file_content_to_edit(path, fullpath, is_stubbed(path, request)) stub(path, request) return _render_to_response('editor.html', descriptor, context_instance=RequestContext(request)) return get_file_content(fullpath)
def breadcrumbs(path): """ >>> breadcrumbs('') '' >>> breadcrumbs('/') '' >>> breadcrumbs('/path1/') '<a href="/">•</a> <a>path1</a> <a href="//"><img height="11" src="/static/img/up.png" /></a>' """ path = path.replace('\\','/') document_root = contrib.get_document_root(path) fullpath = contrib.get_full_path(document_root, path) type = dir_index_tools.get_type(fullpath) if document_root and document_root != '/': html = '<a href="/">•</a> ' root = '/' lastpath = root i = 0 crumbs = path.rstrip('/').split('/') for p in crumbs: i += 1 if p: lastpath += p lastpath += '/' if i < len(crumbs): html += '<a href="%s">%s</a> ‣ ' % ( lastpath, p ) else: html += '<a>%s</a> ' % ( p ) if type != 'test': html += '<a href="%s%s"><img height="11" src="/static/img/up.png" /></a>' % (root, above(path)) else: html = '' return mark_safe(html)
def serve(request, path, show_indexes=False): document_root = contrib.get_document_root(path) fullpath = contrib.get_full_path(document_root, path) log.debug('show index of %s(%s %s)' % (fullpath, document_root, path)) if os.path.isdir(fullpath): if request.path and request.path[-1:] != '/': return HttpResponseRedirect(request.path + '/') if show_indexes: template = load_index_template() descriptor = get_dir_index(document_root, path, fullpath) return HttpResponse(template.render(descriptor)) if not os.path.exists(fullpath): if 'editor' in request.REQUEST: open(fullpath, 'w').close() # creating file if not exists by editor opening it first time else: raise Http404('"%s" does not exist' % fullpath) if 'editor' in request.REQUEST: descriptor = get_file_content_to_edit(path, fullpath, is_stubbed(path, request)) stub(path, request) return _render_to_response('editor.html', descriptor, context_instance=RequestContext(request)) return get_file_content(fullpath)
def get_descriptor(title): fullpath = os.path.join(path, title) return { 'title': title, 'type': tools.get_type(contrib.get_full_path(document_root, fullpath)) }
def saveSuiteAllTests(url, path, ctx): document_root = contrib.get_document_root(path) tests = contrib.enum_suite_tests( contrib.get_full_path(document_root, path) ) log.info('save suite tests for: %s' % path) uploadFolderToRemote(tests, path, document_root, ctx, url, 'test')