• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python driver_generator.DriverGenerator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mi.idk.driver_generator.DriverGenerator的典型用法代码示例。如果您正苦于以下问题:Python DriverGenerator类的具体用法?Python DriverGenerator怎么用?Python DriverGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了DriverGenerator类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, launch_monitor=False):
        """
        Setup the direct access server
        """
        # Currently we are pulling the driver config information from the driver tests.  There is a better way to do
        # this, but we are time crunched.  TODO: Fix this!

        generator = DriverGenerator(Metadata())
        __import__(generator.test_modulename())
        self.test_config = InstrumentDriverTestConfig()

        # Test to ensure we have initialized our test config
        if not self.test_config.initialized:
            raise TestNotInitialized(msg="Tests non initialized. Missing InstrumentDriverTestCase.initalize(...)?")

        self.launch_monitor = launch_monitor
开发者ID:JeffRoy,项目名称:marine-integrations,代码行数:16,代码来源:da_server.py


示例2: _store_package_files

    def _store_package_files(self):
        """
        @brief Store all files in zip archive and add them to the manifest file
        """
        # make sure metadata is up to date
        self.metadata = Metadata(self.metadata.driver_make,
                                 self.metadata.driver_model,
                                 self.metadata.driver_name,
                                 REPODIR + '/marine-integrations')
        
        self.generator = DriverGenerator(self.metadata)
        egg_generator = EggGenerator(self.metadata)
        egg_file = egg_generator.save()

        # Add egg
        self._add_file(egg_file, 'egg', 'python driver egg package')

        # Add the package metadata file
        self._add_file(self.metadata.metadata_path(), description = 'package metadata')

        # Add the qualification test log
        self._add_file(self.log_path(), description = 'qualification tests results')

        # Store parameter/command string description file
        str_path = "%s/%s" % (self.generator.resource_dir(), self.string_file())
        if os.path.exists(str_path):
            self._add_file(str_path, 'resource', 'driver string file')
        
        # Store additional resource files
        self._store_resource_files()

        # Finally save the manifest file.  This must be last of course
        self._add_file(self.manifest().manifest_path(), description = 'package manifest file')
开发者ID:cwingard,项目名称:marine-integrations,代码行数:33,代码来源:package_driver.py


示例3: __init__

    def __init__(self, metadata, basedir, driver_file = None, driver_test_file = None):
        driver_generator = DriverGenerator(metadata)
        
        self.basedir = basedir

        if driver_file:
            self.driver_file = driver_file
        else:
            self.driver_file = driver_generator.driver_path()

        if driver_test_file:
            self.driver_test_file = driver_test_file
        else:
            self.driver_test_file = driver_generator.driver_test_path()
        
        self.driver_dependency = DependencyList(self.driver_file, include_internal_init=True)
        self.test_dependency = DependencyList(self.driver_test_file, include_internal_init=True)
开发者ID:ccenter,项目名称:marine-integrations,代码行数:17,代码来源:egg_generator.py


示例4: __init__

    def __init__(self):
        """
        @brief ctor
        """
        self.metadata = Metadata()
        self._zipfile = None
        self._manifest = None
        self._compression = None
        self.generator = DriverGenerator(self.metadata)

        # Set compression level
        self.zipfile_compression()
开发者ID:newbrough,项目名称:marine-integrations,代码行数:12,代码来源:package_driver.py


示例5: generate_code

 def generate_code(self, force = False):
     """
     @brief generate the directory structure, code and tests for the new driver.
     """
     driver = DriverGenerator( self.metadata, force = force )
     driver.generate()
开发者ID:JeffRoy,项目名称:marine-integrations,代码行数:6,代码来源:start_driver.py


示例6: PackageDriver

class PackageDriver(object):
    """
    Main class for running the package driver process.
    """

    ###
    #   Configuration
    ###
    def log_file(self):
        return "qualification.log"

    def log_path(self):
        return "%s/%s" % (self.metadata.idk_dir(), self.log_file())

    def archive_file(self):
        return "%s_%s_%s-%s-driver.zip" % (self.metadata.driver_make,
                                                      self.metadata.driver_model,
                                                      self.metadata.driver_name,
                                                      self.metadata.version)
    def archive_path(self):
        return os.path.join(os.path.expanduser("~"),self.archive_file())


    ###
    #   Public Methods
    ###
    def __init__(self):
        """
        @brief ctor
        """
        self.metadata = Metadata()
        self._zipfile = None
        self._manifest = None
        self._compression = None
        self.generator = DriverGenerator(self.metadata)

        # Set compression level
        self.zipfile_compression()

    def run_qualification_tests(self):
        """
        @brief Run all qualification tests for the driver and store the results for packaging
        """
        log.info("-- Running qualification tests")

        test = NoseTest(self.metadata, log_file=self.log_path())
        test.report_header()

        result = test.run_qualification()

        if(test.run_qualification()):
            log.info(" ++ Qualification tests passed")
            return True
        else:
            log.error("Qualification tests have fail!  No package created.")
            return False

    def package_driver(self):
        """
        @brief Store driver files in a zip package
        """
        log.info("-- Building driver package")
        self._store_package_files()

    def run(self):
        print "*** Starting Driver Packaging Process***"

        if( self.run_qualification_tests() ):
            self.package_driver()
            print "Package Created: " + self.archive_path()
        else:
            sys.exit()

    def zipfile(self):
        """
        @brief Return the ZipFile object.  Create the file if it isn't already open
        @retval ZipFile object
        """
        if(not self._zipfile):
            self._zipfile = zipfile.ZipFile(self.archive_path(), mode="w")

        return self._zipfile

    def zipfile_compression(self):
        """
        @brief What type of compression should we use for the package file.  If we have access to zlib, we will compress
        @retval Compression type
        """

        if(self._compression): return self._compression

        try:
            import zlib
            self._compression = zipfile.ZIP_DEFLATED
            log.info("Setting compression level to deflated")
        except:
            log.info("Setting compression level to store only")
            self._compression = zipfile.ZIP_STORED

    def manifest(self):
#.........这里部分代码省略.........
开发者ID:newbrough,项目名称:marine-integrations,代码行数:101,代码来源:package_driver.py


示例7: _driver_test_filename

 def _driver_test_filename(self):
     generator = DriverGenerator(self.metadata)
     return generator.driver_test_path()
开发者ID:ccenter,项目名称:marine-integrations,代码行数:3,代码来源:nose_test.py


示例8: _driver_test_module

 def _driver_test_module(self):
     generator = DriverGenerator(self.metadata)
     return generator.test_modulename()
开发者ID:ccenter,项目名称:marine-integrations,代码行数:3,代码来源:nose_test.py


示例9: __init__

class EggGenerator:
    """
    Generate driver egg
    """

    def __init__(self, metadata, repo_dir=REPODIR):
        """
        @brief Constructor
        @param metadata IDK Metadata object
        """
        self.metadata = metadata
        self._bdir = None
        self._repodir = repo_dir

        if not self._tmp_dir():
            raise InvalidParameters("missing tmp_dir configuration")

        if not self._tmp_dir():
            raise InvalidParameters("missing working_repo configuration")

        self.generator = DriverGenerator(self.metadata)
        test_import = __import__(self._test_module())

    def _test_module(self):
        return self.generator.test_modulename()

    def _driver_module(self):
        test_config = InstrumentDriverTestConfig()
        return test_config.driver_module

    def _driver_class(self):
        test_config = InstrumentDriverTestConfig()
        return test_config.driver_class

    def _repo_dir(self):
        return self._repodir
    
    def _res_dir(self):
        return os.path.join(self._versioned_dir(), 'res')
    
    def _res_config_dir(self):
        return os.path.join(self._res_dir(), 'config' )

    def _tmp_dir(self):
        return Config().get('tmp_dir')

    def _setup_path(self):
        return os.path.join(self._build_dir(), 'setup.py' )

    def _setup_template_path(self):
        return os.path.join(Config().template_dir(), 'setup.tmpl' )

    def _main_path(self):
        return os.path.join(self._versioned_dir(), 'mi/main.py' )

    def _main_template_path(self):
        return os.path.join(Config().template_dir(), 'main.tmpl' )

    def _build_name(self):
        return "%s_%s_%s_%s" % (
                self.metadata.driver_make,
                self.metadata.driver_model,
                self.metadata.driver_name,
                self.metadata.version.replace('.', '_'),
            )

    def _build_dir(self):
        if self._bdir:
            return self._bdir

        self._bdir = self._generate_build_dir()

        log.info( "egg build dir: %s" % self._bdir)
        return self._bdir

    def _generate_build_dir(self):
        build_dir = os.path.join(self._tmp_dir(), self._build_name())
        # clean out an old build if it exists
        if os.path.exists(build_dir):
            shutil.rmtree(build_dir)
        return build_dir

    def _versioned_dir(self):
        return self._build_dir()
        #return os.path.join(self._build_dir(),
        #                    self._build_name())

    def _stage_files(self, files):
        """
        Copy files from the original directory into two levels of versioned
        directories within a staging directory, and replace the mi namespace
        with the versioned driver name.mi to account for the new directory
        (only the lower versioned dir is included in the egg)
        @param files - a list of files to copy into the staging directory
        """
        log.error(repr(files))
        # make two levels of versioned file directories, i.e.
        #     driverA_0_1 (= build_dir)
        #         driverA_0_1 (= versioned_dir)
        # then copy driverA files into the bottom versioned dir
#.........这里部分代码省略.........
开发者ID:j2project,项目名称:marine-integrations,代码行数:101,代码来源:egg_generator.py


示例10: PackageDriver


#.........这里部分代码省略.........
        if(self._compression): return self._compression

        try:
            import zlib
            self._compression = zipfile.ZIP_DEFLATED
            log.info("Setting compression level to deflated")
        except:
            log.info("Setting compression level to store only")
            self._compression = zipfile.ZIP_STORED

    def manifest(self):
        """
        @brief Return the PackageManifest object.  Create it if it doesn't already exist
        @retval PackageManifest object
        """
        if(not self._manifest):
            self._manifest = PackageManifest(self.metadata)

        return self._manifest

    ###
    #   Private Methods
    ###
    def _store_package_files(self):
        """
        @brief Store all files in zip archive and add them to the manifest file
        """
        # make sure metadata is up to date
        self.metadata = Metadata(self.metadata.driver_make,
                                 self.metadata.driver_model,
                                 self.metadata.driver_name,
                                 REPODIR + '/marine-integrations')
        
        self.generator = DriverGenerator(self.metadata)
        egg_generator = EggGenerator(self.metadata)
        egg_file = egg_generator.save()

        # Add egg
        self._add_file(egg_file, 'egg', 'python driver egg package')

        # Add the package metadata file
        self._add_file(self.metadata.metadata_path(), description = 'package metadata')

        # Add the qualification test log
        self._add_file(self.log_path(), description = 'qualification tests results')

        # Store parameter/command string description file
        str_path = "%s/%s" % (self.generator.resource_dir(), self.string_file())
        if os.path.exists(str_path):
            self._add_file(str_path, 'resource', 'driver string file')
        
        # Store additional resource files
        self._store_resource_files()

        # Finally save the manifest file.  This must be last of course
        self._add_file(self.manifest().manifest_path(), description = 'package manifest file')


    def _store_resource_files(self):
        """
        @brief Store additional files added by the driver developer.  These
        files live in the driver resource dir.
        """
        resource_dir = os.path.join(self.metadata.relative_driver_path(), "resource")
        log.debug(" -- Searching for developer added resource files in dir: %s",
                  resource_dir)
开发者ID:cwingard,项目名称:marine-integrations,代码行数:67,代码来源:package_driver.py



注:本文中的mi.idk.driver_generator.DriverGenerator类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python prompt.text函数代码示例发布时间:2022-05-27
下一篇:
Python unit_test.DataSetTestCase类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap