コード例 #1
0
    def test_project_export_import(self):
        proj = Project(os.path.join(self.tdir, 'proj1'))
        self.assertEqual(proj.config.items('info'), [('version', '0'),
                                                     ('description', '')])
        new_info = [('version', 'stinky'), ('description', 'Frobozz rulz!')]
        proj.set_info(dict(new_info))
        proj.activate()
        self._fill_project(proj)

        proj.export(destdir=self.tdir)
        proj.deactivate()

        newproj = project_from_archive(os.path.join(self.tdir,
                                                    'proj1%s' % PROJ_FILE_EXT),
                                       proj_name='proj2',
                                       dest_dir=self.tdir)

        self.assertEqual(newproj.path, os.path.join(self.tdir, 'proj2'))
        self.assertEqual(newproj.config.items('info'), new_info)

        try:
            newproj = project_from_archive(os.path.join(
                self.tdir, 'proj1%s' % PROJ_FILE_EXT),
                                           dest_dir=self.tdir)
        except Exception, err:
            self.assertTrue(str(err).endswith(' already exists'))
コード例 #2
0
    def test_project_export_import(self):
        proj = Project(os.path.join(self.tdir, 'proj1'))
        self.assertEqual(proj.config.items('info'),
                         [('version', '0'), ('description', '')])
        new_info = [('version', 'stinky'), ('description', 'Frobozz rulz!')]
        proj.set_info(dict(new_info))
        proj.activate()
        self._fill_project(proj)

        proj.export(destdir=self.tdir)
        proj.deactivate()

        newproj = project_from_archive(os.path.join(self.tdir,
                                                    'proj1%s' % PROJ_FILE_EXT),
                                       proj_name='proj2',
                                       dest_dir=self.tdir)

        self.assertEqual(newproj.path, os.path.join(self.tdir, 'proj2'))
        self.assertEqual(newproj.config.items('info'), new_info)

        try:
            newproj = project_from_archive(os.path.join(self.tdir,
                                                        'proj1%s' % PROJ_FILE_EXT),
                                           dest_dir=self.tdir)
        except Exception, err:
            self.assertTrue(str(err).endswith(' already exists'))
コード例 #3
0
    def test_using(self):
        proj = Project('a_proj')
        self._fill_project(proj.top)
        proj.top.run()
        self.assertEqual(proj.top.comp1.rval_out, 10.)
        self.assertEqual(proj.top.comp2.rval_out, 40.)
        proj.top.comp1.rval_in = 0.5
        os.chdir(self.tdir)
        proj.export(projname='fooproj')

        fooproj = project_from_archive('fooproj.proj')
        self.assertEqual(fooproj.top.comp1.rval_in, proj.top.comp1.rval_in)
        fooproj.top.run()
        self.assertEqual(fooproj.top.comp1.rval_out, 1.)
        self.assertEqual(fooproj.top.comp2.rval_out, 4.)
コード例 #4
0
 def test_using(self):
     proj = Project('a_proj')
     self._fill_project(proj.top)
     proj.top.run()
     self.assertEqual(proj.top.comp1.rval_out, 10.)
     self.assertEqual(proj.top.comp2.rval_out, 40.)
     proj.top.comp1.rval_in = 0.5
     os.chdir(self.tdir)
     proj.export(projname='fooproj')
     
     fooproj = project_from_archive('fooproj.proj')
     self.assertEqual(fooproj.top.comp1.rval_in, proj.top.comp1.rval_in)
     fooproj.top.run()
     self.assertEqual(fooproj.top.comp1.rval_out, 1.)
     self.assertEqual(fooproj.top.comp2.rval_out, 4.)
コード例 #5
0
    def test_using(self):
        proj = Project('a_proj')
        proj.activate()
        self._fill_project(proj)
        top = proj.get('top')
        top.run()
        self.assertEqual(top.comp1.rval_out, 10.)
        self.assertEqual(top.comp2.rval_out, 40.)
        proj.command("top.comp1.rval_in = 0.5")
        os.chdir(self.tdir)
        proj.export(projname='fooproj')

        fooproj = project_from_archive('fooproj.proj')
        fooproj.activate()
        footop = fooproj.get('top')
        self.assertEqual(footop.comp1.rval_in, top.comp1.rval_in)
        footop.run()
        self.assertEqual(footop.comp1.rval_out, 1.)
        self.assertEqual(footop.comp2.rval_out, 4.)
コード例 #6
0
 def test_using(self):
     proj = Project('a_proj')
     proj.activate()
     self._fill_project(proj)
     top = proj.get('top')
     top.run()
     self.assertEqual(top.comp1.rval_out, 10.)
     self.assertEqual(top.comp2.rval_out, 40.)
     proj.command("top.comp1.rval_in = 0.5")
     os.chdir(self.tdir)
     proj.export(projname='fooproj')
     
     fooproj = project_from_archive('fooproj.proj')
     fooproj.activate()
     footop = fooproj.get('top')
     self.assertEqual(footop.comp1.rval_in, top.comp1.rval_in)
     footop.run()
     self.assertEqual(footop.comp1.rval_out, 1.)
     self.assertEqual(footop.comp2.rval_out, 4.)
コード例 #7
0
    def test_project_export_import(self):
        proj = Project(os.path.join(self.tdir, 'proj1'))
        self._fill_project(proj.top)
        
        proj.export(destdir=self.tdir)
        proj.deactivate()
        
        newproj = project_from_archive(os.path.join(self.tdir,
                                                    'proj1%s' % PROJ_FILE_EXT), 
                                       proj_name='proj2',
                                       dest_dir=self.tdir)

        self.assertEqual(newproj.path, os.path.join(self.tdir, 'proj2'))
    
        try:
            newproj = project_from_archive(os.path.join(self.tdir,
                                                        'proj1%s' % PROJ_FILE_EXT), 
                                           dest_dir=self.tdir)
        except Exception, err:
            self.assertTrue(str(err).endswith(' already exists'))
コード例 #8
0
    def test_project_export_import(self):
        proj = Project(os.path.join(self.tdir, 'proj1'))
        self._fill_project(proj.top)

        proj.export(destdir=self.tdir)
        proj.deactivate()

        newproj = project_from_archive(os.path.join(self.tdir,
                                                    'proj1%s' % PROJ_FILE_EXT),
                                       proj_name='proj2',
                                       dest_dir=self.tdir)

        self.assertEqual(newproj.path, os.path.join(self.tdir, 'proj2'))

        try:
            newproj = project_from_archive(os.path.join(
                self.tdir, 'proj1%s' % PROJ_FILE_EXT),
                                           dest_dir=self.tdir)
        except Exception, err:
            self.assertTrue(str(err).endswith(' already exists'))
コード例 #9
0
    def get(self, project_id):
        ''' Browser download of a project file
        '''
        pdb = Projects()
        project = pdb.get(project_id)
        if project['projpath']:
            dirname = project['projpath']

            if os.path.isdir(dirname):
                proj = Project(dirname)
                tdir = mkdtemp()
                try:
                    filename = proj.export(destdir=tdir)
                    proj_file = open(filename, 'rb')
                    self.set_header('content_type', 'application/octet-stream')
                    self.set_header('Content-Length',
                                    str(os.path.getsize(filename)))
                    form_proj = clean_filename(project['projectname'])
                    form_ver = clean_filename(project['version'])
                    form_date = strftime('%Y-%m-%d_%H%M%S')
                    self.set_header(
                        'Content-Disposition',
                        'attachment; filename=%s-%s-%s.proj' %
                        (form_proj, form_ver, form_date))

                    try:
                        self.write(proj_file.read())
                    finally:
                        proj_file.close()
                finally:
                    try:
                        shutil.rmtree(tdir, onerror=onerror)
                    except:
                        pass
            else:
                raise HTTPError(dirname, 403,
                                "%s is not a directory" % dirname, None, None)
        else:
            raise HTTPError(filename, 403,
                            "no file found for %s" % project['projectname'],
                            None, None)
コード例 #10
0
    def get(self, project_id):
        ''' Browser download of a project file
        '''
        pdb = Projects()
        project = pdb.get(project_id)
        if project['projpath']:
            dirname = project['projpath']

            if os.path.isdir(dirname):
                proj = Project(dirname)
                tdir = mkdtemp()
                try:
                    filename = proj.export(destdir=tdir)
                    proj_file = open(filename, 'rb')
                    self.set_header('content_type', 'application/octet-stream')
                    self.set_header('Content-Length', str(os.path.getsize(filename)))
                    form_proj = clean_filename(project['projectname'])
                    form_ver = clean_filename(project['version'])
                    form_date = strftime('%Y-%m-%d_%H%M%S')
                    self.set_header('Content-Disposition',
                                    'attachment; filename=%s-%s-%s.proj' %
                                    (form_proj, form_ver, form_date))
    
                    try:
                        self.write(proj_file.read())
                    finally:
                        proj_file.close()
                finally:
                    try:
                        shutil.rmtree(tdir)
                    except:
                        pass
            else:
                raise HTTPError(dirname, 403, "%s is not a directory" % dirname,
                                None, None)
        else:
            raise HTTPError(filename, 403, "no file found for %s" % \
                                            project['projectname'], None, None)
コード例 #11
0
ファイル: repo.py プロジェクト: akhi28/OpenMDAO-Framework
 def commit(self, comment=''):
     p = Project(self.dirpath)
     p.export(destdir=self.repodir)
コード例 #12
0
 def commit(self, comment=''):
     p = Project(self.dirpath)
     p.export(destdir=self.repodir)