def test_downloads(self): dbName = self.getOutputPath("downloads.sqlite") # dbName = '/tmp/downloads.sqlite' print ">>> test_downloads: dbName = '%s'" % dbName mapper = SqliteFlatMapper(dbName, globals()) mapper.enableAppend() n = 10 for i in range(n): download = DownloadRecord(fullName="Paco Perez", organization="kkkk") mapper.store(download) mapper.commit() mapper.close()
def test_downloads(self): dbName = self.getOutputPath('downloads.sqlite') print ">>> test_downloads: dbName = '%s'" % dbName mapper = SqliteFlatMapper(dbName, globals()) mapper.enableAppend() n = 10 for i in range(n): download = DownloadRecord(fullName='Paco Perez', organization='kkkk') mapper.store(download) mapper.commit() mapper.close()
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 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')