def protocol_info(request): from pyworkflow.web.app.views_util import parseText from pyworkflow.em.data import EMObject if request.is_ajax(): jsonStr = '' # projectName = request.session['projectName'] protId = request.GET.get('protocolId', None) # projectPath = request.session['projectPath'] project = loadProject(request) if len(protId) > 0: protocol = project.getProtocol(int(protId)) # PROTOCOL IO input_obj = [{'name':name, 'nameId': attr.getNameId(), 'id': attr.getObjId(), 'info': str(attr.get()) if attr.isPointer() else str(attr)} for name, attr in protocol.iterInputAttributes()] output_obj = [{'name':name, 'nameId': attr.getNameId(), 'id': attr.getObjId(), 'info': str(attr)} for name, attr in protocol.iterOutputAttributes(EMObject)] # PROTOCOL SUMMARY summary = parseText(protocol.summary()) # PROTOCOL METHODS methods = parseText(protocol.methods()) # STATUS status = protocol.status.get() # LOGS (ERROR & OUTPUT) fOutString, fErrString, fScpnString = protocol.getLogsAsStrings() ioDict = {'inputs': input_obj, 'outputs': output_obj, 'summary': summary, 'methods': methods, 'status': status, 'logs_out': parseText(fOutString), 'logs_error': parseText(fErrString), 'logs_scipion': parseText(fScpnString) } # print "ioDict: ", ioDict jsonStr = json.dumps(ioDict, ensure_ascii=False) return HttpResponse(jsonStr, mimetype='application/javascript')
def doDownload(request): fullName = request.POST.get('fullName') organization = request.POST.get('organization') email = request.POST.get('email') mailoption = request.POST.get('mailoption') country = request.POST.get('country') version = request.POST.get('version') platform = request.POST.get('platform') errors = "" if not len(fullName) > 0: errors += "Please fill in the fullName field.\n" if not len(organization) > 0: errors += "Please fill in the Organization field.\n" if not len(email) > 0: errors += "Please fill in the Email field.\n" # if not len(mailoption) > 0: # errors += "Please choose one into the Country field.\n" if not len(version) > 0: errors += "Please fill in the Scipion Version field.\n" if not len(platform) > 0: errors += "Please fill in the Platform field.\n" if len(errors) == 0: dbName = os.path.join(os.environ['SCIPION_HOME'], 'downloads.sqlite') #dbName = '/tmp/downloads.sqlite' mapper = SqliteFlatMapper(dbName, globals()) mapper.enableAppend() download = DownloadRecord(fullName = fullName, organization = organization, email = email, subscription = mailoption, country = country, version = version, platform = platform) mapper.store(download) mapper.commit() mapper.close() "Return a response with the scipion download file" if platform == 'linuxbin': path = os.path.join(os.environ['SCIPION_HOME'], 'pyworkflow', 'web', 'pages', 'resources', 'install', 'scipion_all_packages_2015-06-29.tgz') else: path = os.path.join(os.environ['SCIPION_HOME'], 'pyworkflow', 'web', 'pages', 'resources', 'install', 'scipion_source_2015-06-29.tgz') if not os.path.exists(path): return HttpResponseNotFound('Path not found: %s' % path) response = HttpResponse(FileWrapper(open(path)), content_type=mimetypes.guess_type(path)[0]) response['Content-Length'] = os.path.getsize(path) response['Content-Disposition'] = 'attachment; filename=%s'%os.path.basename(path) return response else: jsonStr = json.dumps({'errors' : parseText(errors)}, ensure_ascii=False) return HttpResponse(jsonStr, mimetype='application/javascript')
def protocol_info(request): from pyworkflow.web.app.views_util import parseText from pyworkflow.em.data import EMObject if request.is_ajax(): jsonStr = '' # projectName = request.session['projectName'] protId = request.GET.get('protocolId', None) # projectPath = request.session['projectPath'] project = loadProject(request) if len(protId) > 0: protocol = project.getProtocol(int(protId)) # PROTOCOL IO input_obj = [{ 'name': name, 'nameId': attr.getNameId(), 'id': attr.getObjId(), 'info': str(attr.get()) if attr.isPointer() else str(attr) } for name, attr in protocol.iterInputAttributes()] output_obj = [{ 'name': name, 'nameId': attr.getNameId(), 'id': attr.getObjId(), 'info': str(attr) } for name, attr in protocol.iterOutputAttributes(EMObject)] # PROTOCOL SUMMARY summary = parseText(protocol.summary()) # PROTOCOL METHODS methods = parseText(protocol.methods()) # STATUS status = protocol.status.get() # LOGS (ERROR & OUTPUT) fOutString, fErrString, fScpnString = protocol.getLogsAsStrings() ioDict = { 'inputs': input_obj, 'outputs': output_obj, 'summary': summary, 'methods': methods, 'status': status, 'logs_out': parseText(fOutString), 'logs_error': parseText(fErrString), 'logs_scipion': parseText(fScpnString) } # print "ioDict: ", ioDict jsonStr = json.dumps(ioDict, ensure_ascii=False) return HttpResponse(jsonStr, mimetype='application/javascript')
def doDownload(request): fullName = request.POST.get('fullName') organization = request.POST.get('organization') email = request.POST.get('email') mailoption = request.POST.get('mailoption') country = request.POST.get('country') version = request.POST.get('version') platform = request.POST.get('platform') errors = "" if not len(fullName) > 0: errors += "Please fill in the fullName field.\n" if not len(organization) > 0: errors += "Please fill in the Organization field.\n" if not len(email) > 0: errors += "Please fill in the Email field.\n" # if not len(mailoption) > 0: # errors += "Please choose one into the Country field.\n" if not len(version) > 0: errors += "Please fill in the Scipion Version field.\n" if not len(platform) > 0: errors += "Please fill in the Platform field.\n" if len(errors) == 0: dbName = os.path.join(os.environ['SCIPION_HOME'], 'downloads.sqlite') #dbName = '/tmp/downloads.sqlite' mapper = SqliteFlatMapper(dbName, globals()) mapper.enableAppend() download = DownloadRecord(fullName=fullName, organization=organization, email=email, subscription=mailoption, country=country, version=version, platform=platform) mapper.store(download) mapper.commit() mapper.close() "Return a response with the scipion download file" if platform == 'linuxbin': path = os.path.join(os.environ['SCIPION_HOME'], 'pyworkflow', 'web', 'pages', 'resources', 'install', 'scipion_all_packages_2015-06-29.tgz') else: path = os.path.join(os.environ['SCIPION_HOME'], 'pyworkflow', 'web', 'pages', 'resources', 'install', 'scipion_source_2015-06-29.tgz') if not os.path.exists(path): return HttpResponseNotFound('Path not found: %s' % path) response = HttpResponse(FileWrapper(open(path)), content_type=mimetypes.guess_type(path)[0]) response['Content-Length'] = os.path.getsize(path) response[ 'Content-Disposition'] = 'attachment; filename=%s' % os.path.basename( path) return response else: jsonStr = json.dumps({'errors': parseText(errors)}, ensure_ascii=False) return HttpResponse(jsonStr, mimetype='application/javascript')
def __getattr__(self, name): text = getattr(Icon, name) return parseText(text)
def __getattr__(self, name): text = getattr(Color, name) return parseText(text)
def __getattr__(self, name): text = getattr(Message, name) return parseText(text)