Esempio n. 1
0
 def test_insertObjects(self):
     dbName = self.getOutputPath('images.sqlite')
     print ">>> test_insertObjects: dbName = '%s'" % dbName
     mapper = SqliteFlatMapper(dbName, globals())
     n = 10
     
     for i in range(n):
         img = Image()
         img.setLocation(i+1, 'images.stk')
         mapper.store(img)
         
     mapper.setProperty('samplingRate', '3.0')
     mapper.setProperty('defocusU', 1000)
     mapper.setProperty('defocusV', 1000)
     mapper.setProperty('defocusU', 2000) # Test update a property value
     mapper.deleteProperty('defocusV') # Test delete a property
     mapper.commit()
     self.assertEqual(1, mapper.db.getVersion())
     mapper.close()
     
     # Test that values where stored properly
     mapper2 = SqliteFlatMapper(dbName, globals())
     
     self.assertTrue(mapper2.hasProperty('samplingRate'))
     self.assertTrue(mapper2.hasProperty('defocusU'))
     self.assertFalse(mapper2.hasProperty('defocusV'))
     
     self.assertEqual(mapper2.getProperty('samplingRate'), '3.0')
     self.assertEqual(mapper2.getProperty('defocusU'), '2000')
Esempio n. 2
0
    def test_insertObjects(self):
        dbName = self.getOutputPath('images.sqlite')
        print ">>> test_insertObjects: dbName = '%s'" % dbName
        mapper = SqliteFlatMapper(dbName, globals())
        n = 10

        for i in range(n):
            img = Image()
            img.setLocation(i + 1, 'images.stk')
            mapper.store(img)

        mapper.setProperty('samplingRate', '3.0')
        mapper.setProperty('defocusU', 1000)
        mapper.setProperty('defocusV', 1000)
        mapper.setProperty('defocusU', 2000)  # Test update a property value
        mapper.deleteProperty('defocusV')  # Test delete a property
        mapper.commit()
        self.assertEqual(1, mapper.db.getVersion())
        mapper.close()

        # Test that values where stored properly
        mapper2 = SqliteFlatMapper(dbName, globals())

        self.assertTrue(mapper2.hasProperty('samplingRate'))
        self.assertTrue(mapper2.hasProperty('defocusU'))
        self.assertFalse(mapper2.hasProperty('defocusV'))

        self.assertEqual(mapper2.getProperty('samplingRate'), '3.0')
        self.assertEqual(mapper2.getProperty('defocusU'), '2000')
Esempio n. 3
0
    def test_insertObjects(self):
        dbName = self.getOutputPath("images.sqlite")
        print ">>> test_insertObjects: dbName = '%s'" % dbName
        mapper = SqliteFlatMapper(dbName, globals())
        n = 10

        for i in range(n):
            img = Image()
            img.setLocation(i + 1, "images.stk")
            mapper.store(img)

        mapper.setProperty("samplingRate", "3.0")
        mapper.setProperty("defocusU", 1000)
        mapper.setProperty("defocusV", 1000)
        mapper.setProperty("defocusU", 2000)  # Test update a property value
        mapper.deleteProperty("defocusV")  # Test delete a property
        mapper.commit()
        mapper.close()

        # Test that values where stored properly
        mapper2 = SqliteFlatMapper(dbName, globals())

        self.assertTrue(mapper2.hasProperty("samplingRate"))
        self.assertTrue(mapper2.hasProperty("defocusU"))
        self.assertFalse(mapper2.hasProperty("defocusV"))

        self.assertEqual(mapper2.getProperty("samplingRate"), "3.0")
        self.assertEqual(mapper2.getProperty("defocusU"), "2000")
Esempio n. 4
0
    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()
Esempio n. 5
0
    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()
Esempio n. 6
0
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')   
Esempio n. 7
0
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')