コード例 #1
0
ファイル: ip_itk.py プロジェクト: codester2/devide.johannes
    def get(self):
        if os.path.exists(self.source_dir):
            utils.output("ITK already checked out, skipping step.")

        else:
            os.chdir(config.archive_dir)
            ret = os.system("%s -d %s co %s %s" %
                            (config.CVS, CVS_REPO, CVS_VERSION, BASENAME))
            
            if ret != 0:
                utils.error("Could not CVS checkout ITK.  Fix and try again.")

        # also the source dir for other installpackages that wish to build
        # WrapITK external projects
        # itkvtkglue needs this during its get() stage!
        config.WRAPITK_SOURCE_DIR = os.path.join(self.source_dir,
                                            'Wrapping/WrapITK')

        # now apply patch if necessary
        # only on win64
        if config.WINARCH_STR != "x64":
            return

        patch_dst = os.path.join(config.archive_dir, W64SWIG_PATCH)
        if not os.path.exists(patch_dst):
            utils.output("Applying PATCH: win64 swig vs 2008 workaround")
            patch_src = os.path.join(config.patches_dir,W64SWIG_PATCH)
            shutil.copy(patch_src, patch_dst)
            os.chdir(self.source_dir)
            ret = os.system("%s -p0 < %s" % (config.PATCH, patch_dst))
コード例 #2
0
ファイル: ip_dcmtk.py プロジェクト: codester2/devide.johannes
    def configure_posix(self):
        os.chdir(self.build_dir)

        if os.path.exists("dcmdata/config.log"):
            utils.output("DCMTK already configured.  Not redoing.")
        else:
            # we need to configure this without zlib, otherwise dcmtk
            # complains (at least on this system) about the symbol
            # inflateEnd not being available.
            ret = os.system("./configure --without-zlib " "--prefix=%s" % (self.inst_dir,))
            if ret != 0:
                utils.error("Could not configure dcmtk.  Fix and try again.")

            # now modify the generated config/Makefile.def to enable
            # building shared libraries as per
            # http://forum.dcmtk.org/viewtopic.php?t=19
            repls = [
                ("(^CFLAGS\s*=\s*)-O", "\\1-fPIC -O2"),
                ("(^CXXFLAGS\s*=\s*)-O", "\\1-fPIC -O2"),
                ("(^AR\s*=\s*)ar", "\\1gcc"),
                ("(^ARFLAGS\s*=\s*)cruv", "\\1-shared -o"),
                ("(^LIBEXT\s*=\s*)a", "\\1so"),
                ("(^RANLIB\s*=\s*)ranlib", "\\1:"),
            ]

            utils.re_sub_filter_file(repls, "config/Makefile.def")
コード例 #3
0
ファイル: johannes.py プロジェクト: codester2/devide.johannes
def posix_prereq_check(working_dir):
    """Perform posix system check for prerequisite software.

    Largest part of this checking is done in the second bootstrap
    shell script (executed before this file).  Here we check for basic
    stuff like cvs, svn and patch.
    """

    v = utils.find_command_with_ver(
            'CVS', '%s -v' % (config.CVS,),
            '\(CVS\)\s+(.*)\s+')

    v = v and utils.find_command_with_ver(
            'Subversion (SVN)', '%s --version' % (config.SVN,),
            'version\s+(.*)$')

    v = v and utils.find_command_with_ver(
            'patch', '%s -v' % (config.PATCH,),
            '^patch\s+(.*)$')

    # now check that working_dir contains the required subdirs
    dv = True
    for wsub in ['archive', 'build', 'inst']:
        cdir = os.path.join(working_dir, wsub)
        if os.path.isdir(cdir):
            msg = '%s exists.' % (cdir,)
        else:
            msg = '%s does not exist.' % (cdir,)
            dv = False

        utils.output(msg)

    return v and dv
コード例 #4
0
ファイル: ip_swig.py プロジェクト: codester2/devide.johannes
    def get(self):
        if os.path.exists(self.archive_path):
            utils.output("SWIG already downloaded, skipping step.")

        else:
            utils.goto_archive()
            utils.urlget(SWIG_URL)
コード例 #5
0
ファイル: ip_zlib.py プロジェクト: codester2/devide.johannes
 def get(self):
     if os.path.exists(self.archive_path):
         utils.output("%s already present, skipping step." % BASENAME)
         return
     
     utils.goto_archive()
     utils.urlget(URL)
コード例 #6
0
ファイル: ip_zlib.py プロジェクト: codester2/devide.johannes
 def unpack(self):
     if os.path.exists(self.build_dir):
         utils.output("%s already unpacked. Skipping." % BASENAME)
         return
     
     utils.output("Unpacking %s." % BASENAME)
     utils.unpack_build(self.archive_path)
コード例 #7
0
ファイル: ip_itk.py プロジェクト: codester2/devide.johannes
    def configure(self):
        if os.path.exists(
            os.path.join(self.build_dir, 'CMakeFiles/cmake.check_cache')):
            utils.output("ITK build already configured.")
            return
        
        if not os.path.exists(self.build_dir):
            os.mkdir(self.build_dir)

        # ITK_USE_REVIEW *must* be on for ItkVtkGlue to work!
        # following types are wrapped:
        # complex_float, float, signed_short, unsigned long,
        # vector_float 
        # I've removed "-DITK_USE_REVIEW_STATISTICS=ON " 
        # for now, as this seems to cause problems on win64
        cmake_params = "-DBUILD_EXAMPLES=OFF " \
                       "-DBUILD_SHARED_LIBS=ON " \
                       "-DBUILD_TESTING=OFF " \
                       "-DCMAKE_BUILD_TYPE=RelWithDebInfo " \
                       "-DCMAKE_INSTALL_PREFIX=%s " \
                       "-DITK_USE_REVIEW=ON " \
                       "-DITK_USE_ORIENTED_IMAGE_DIRECTION=ON " \
                       "-DITK_IMAGE_BEHAVES_AS_ORIENTED_IMAGE=ON " \
                       "_DITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY=ON " \
                                              % (self.inst_dir,)
        
        ret = utils.cmake_command(self.build_dir, self.source_dir,
                cmake_params)

        if ret != 0:
            utils.error("Could not configure ITK.  Fix and try again.")
コード例 #8
0
ファイル: ip_dcmtk.py プロジェクト: codester2/devide.johannes
    def build_nt(self):
        os.chdir(self.build_dir)
        # do check for some file

        if os.path.exists(os.path.join("dcmdata/libsrc", BUILD_TARGET, "dcmdata.lib")):
            utils.output("dcmtk::dcmdata already built.  Skipping.")

        else:
            # Release buildtype (vs RelWithDebInfo) so we build with
            # /MD and not /MDd
            ret = utils.make_command("dcmtk.sln", install=False, project="dcmdata", win_buildtype=BUILD_TARGET)

            if ret != 0:
                utils.error("Could not build dcmtk::dcmdata.")

        if os.path.exists(os.path.join("ofstd/libsrc", BUILD_TARGET, "ofstd.lib")):
            utils.output("dcmtk::ofstd already built.  Skipping.")

        else:
            # Release buildtype (vs RelWithDebInfo) so we build with
            # /MD and not /MDd
            ret = utils.make_command("dcmtk.sln", install=False, project="ofstd", win_buildtype=BUILD_TARGET)

            if ret != 0:
                utils.error("Could not build dcmtk::ofstd.")
コード例 #9
0
ファイル: ip_scipy.py プロジェクト: codester2/devide.johannes
    def install(self):
        # to test for install, just do python -c "import scipy"
        # and test the result (we could just import directly, but that would
        # only work once our invoking python has been stopped and started
        # again)
        os.chdir(config.working_dir) # we need to be elsewhere!
        ret = os.system('%s -c "import scipy"' % (sys.executable,))
        if ret == 0:
            utils.output('scipy already installed.  Skipping step.')

        else:
            utils.output('ImportError test shows that scipy is not '
                         'installed.  Installing...')

            if os.name == 'posix':
                os.chdir(self.build_dir)
                
                ret = os.system('%s setup.py install' % (sys.executable,))
                
                if ret != 0:
                    utils.error('scipy install failed.  Please fix and try again.')

            elif os.name == 'nt':
                # unpack relevant ZIP into Python site-packages dir.
                from distutils import sysconfig
                spd = sysconfig.get_python_lib()

                # copy self.build_dir/PLATLIB/* to python/libs/site-packages/
                # we're not copying SCRIPTS/f2py.py
                pl_dir = os.path.join(self.build_dir, 'PLATLIB')
                utils.copy_glob(os.path.join(pl_dir, '*'), spd)
コード例 #10
0
    def configure(self):
        if os.path.exists(
            os.path.join(self.build_dir, 'CMakeFiles/cmake.check_cache')):
            utils.output("vtkdevide build already configured.")
            return
        
        if not os.path.exists(self.build_dir):
            os.mkdir(self.build_dir)

        cmake_params = "-DBUILD_SHARED_LIBS=ON " \
                       "-DBUILD_TESTING=OFF " \
                       "-DCMAKE_BUILD_TYPE=RelWithDebInfo " \
                       "-DCMAKE_INSTALL_PREFIX=%s " \
                       "-DVTK_DIR=%s " \
                       "-DDCMTK_INCLUDE_PATH=%s " \
                       "-DDCMTK_LIB_PATH=%s " \
                       "-DPYTHON_EXECUTABLE=%s " \
                       "-DPYTHON_LIBRARY=%s " \
                       "-DPYTHON_INCLUDE_PATH=%s" % \
                       (self.inst_dir, config.VTK_DIR,
                        config.DCMTK_INCLUDE, config.DCMTK_LIB,
                        config.PYTHON_EXECUTABLE,
                        config.PYTHON_LIBRARY,
                        config.PYTHON_INCLUDE_PATH)

        ret = utils.cmake_command(self.build_dir, self.source_dir,
                cmake_params)

        if ret != 0:
            utils.error("Could not configure vtkdevide.  Fix and try again.")
コード例 #11
0
    def install(self):
        self.copy_devide_to_inst()

        # create versions.py file
        ###################################################

        # first get devide_revision_id
        status, output = utils.get_status_output("%s id %s" % (config.HG, self.inst_dir))
        # on linux, hg id gives "changeset_id tip" (e.g.)
        # on windows build image, only "changeset_id", so we have
        # to remove EOL with strip()
        devide_revision_id = output.split(' ')[0].strip()

        # then write the file
        versions_dict = {
                'devide_version' : config.DEVIDE_DATESTR,
                'devide_revision_id' : devide_revision_id,
                'johannes_revision_id' : config.JOHANNES_REVISION_ID
                }

        utils.output('Writing devide_versions.py')
        versions_fname = os.path.join(self.inst_dir, 'devide_versions.py')
        versions_file = file(versions_fname, 'w')
        cptxt = CONFIG_PY_TEMPLATE % versions_dict
        versions_file.write(cptxt)
        versions_file.close()
コード例 #12
0
    def get(self):
        if os.path.exists(self.source_dir):
            utils.output("ITK already checked out, skipping step.")

        else:
            utils.goto_archive()

            ret = os.system("git clone %s %s" % (GIT_REPO, BASENAME))
            if ret != 0:
                utils.error("Could not clone ITK repo.  Fix and try again.")

            os.chdir(self.source_dir)
            # FIXME: error checking
            ret = os.system("git submodule update --init")

            ret = os.system("git checkout %s" % (GIT_TAG,))
            if ret != 0:
                utils.error("Could not checkout ITK 4.0.0. Fix and try again.")

            # FIXME: error checking
            ret = os.system("git submodule update")

        # also the source dir for other installpackages that wish to build
        # WrapITK external projects
        # itkvtkglue needs this during its get() stage!
        config.WRAPITK_SOURCE_DIR = os.path.join(self.source_dir,
                                            'Wrapping/WrapITK')

        # now apply patch if necessary
        # only on win64
        if config.WINARCH_STR != "x64":
            return
コード例 #13
0
    def configure(self):
        if os.path.exists(
            os.path.join(self.build_dir, 'CMakeFiles/cmake.check_cache')):
            utils.output("wrapitk build already configured.")
            return
        
        if not os.path.exists(self.build_dir):
            os.mkdir(self.build_dir)

        # need unsigned short for itkPyImageFilter
        # with the switches below, I need /bigobj on win64 for the
        # following projects: ITKPyBasePython
        cmake_params = \
                "-DBUILD_TESTING=OFF " \
                "-DCMAKE_BUILD_TYPE=RelWithDebInfo " \
                "-DCMAKE_INSTALL_PREFIX=%s " \
                "-DINSTALL_WRAP_ITK_COMPATIBILITY=NO " \
                "-DITK_DIR=%s " \
                "-DITK_TEST_DRIVER=%s " \
                "-DCableSwig_DIR=%s " \
                "-DSWIG_DIR=%s " \
                "-DSWIG_EXECUTABLE=%s " \
                "-DVTK_DIR=%s " \
                "-DWRAP_ITK_PYTHON=ON " \
                "-DWRAP_complex_double=OFF " \
                "-DWRAP_complex_float=ON " \
                "-DWRAP_covariant_vector_double=OFF " \
                "-DWRAP_covariant_vector_float=ON " \
                "-DWRAP_double=OFF " \
                "-DWRAP_float=ON " \
                "-DWRAP_rgb_unsigned_char=OFF " \
                "-DWRAP_rgb_unsigned_short=ON " \
                "-DWRAP_rgba_unsigned_char=OFF " \
                "-DWRAP_rgba_unsigned_short=OFF " \
                "-DWRAP_signed_char=OFF " \
                "-DWRAP_signed_long=OFF " \
                "-DWRAP_signed_short=ON " \
                "-DWRAP_unsigned_char=OFF " \
                "-DWRAP_unsigned_long=OFF " \
                "-DWRAP_unsigned_short=ON " \
                "-DWRAP_vector_double=OFF " \
                "-DWRAP_vector_float=ON " \
                "-DPYTHON_EXECUTABLE=%s " \
                "-DPYTHON_LIBRARY=%s " \
                "-DPYTHON_INCLUDE_PATH=%s " % \
                (self.inst_dir, config.ITK_DIR,
                 config.ITK_TEST_DRIVER,
                 config.CABLESWIG_DIR,
                 config.SWIG_DIR,
                 config.SWIG_EXECUTABLE, config.VTK_DIR,
                 config.PYTHON_EXECUTABLE,
                 config.PYTHON_LIBRARY,
                 config.PYTHON_INCLUDE_PATH)


        ret = utils.cmake_command(self.build_dir, self.source_dir,
                cmake_params)

        if ret != 0:
            utils.error("Could not configure WrapITK.  Fix and try again.")
コード例 #14
0
ファイル: ip_vtk.py プロジェクト: codester2/devide.johannes
    def install(self):
        posix_file = os.path.join(self.inst_dir, 'bin/vtkpython')
        nt_file = os.path.join(self.inst_dir, 'bin', 'vtkpython.exe')

        if utils.file_exists(posix_file, nt_file):    
            utils.output("VTK already installed.  Skipping build step.")

        else:
            # python 2.5.2 setup.py complains that this does not exist
            # with VTK PV-3-2-1.  This is only on installations with
            # EasyInstall / Python Eggs, then the VTK setup.py uses
            # EasyInstall and not standard distutils.  gah!
            if not os.path.exists(config.VTK_PYTHON):
                os.makedirs(config.VTK_PYTHON)

            os.chdir(self.build_dir)

            # we save, set and restore the PP env variable, else
            # stupid setuptools complains
            save_env = os.environ.get('PYTHONPATH', '')
            os.environ['PYTHONPATH'] = config.VTK_PYTHON
            ret = utils.make_command('VTK.sln', install=True)
            os.environ['PYTHONPATH'] = save_env

            if ret != 0:
                utils.error("Could not install VTK.  Fix and try again.")
コード例 #15
0
ファイル: ip_vtk58.py プロジェクト: codester2/devide.johannes
    def get(self):
        if os.path.exists(self.source_dir):
            utils.output("VTK already checked out, skipping step.")

        else:
            utils.goto_archive()

            ret = os.system("git clone %s %s" % (GIT_REPO, BASENAME))
            if ret != 0:
                utils.error("Could not clone VTK repo.  Fix and try again.")

            os.chdir(self.source_dir)
            ret = os.system("git checkout %s" % (GIT_TAG,))
            if ret != 0:
                utils.error("Could not checkout VTK %s. Fix and try again." % (GIT_TAG,))


        if not os.path.exists(self.exc_patch_dst):
            utils.output("Applying EXC patch")
            # we do this copy so we can see if the patch has been done yet or not
            shutil.copyfile(self.exc_patch_src, self.exc_patch_dst)

            os.chdir(self.source_dir)
            # default git-generated patch, so needs -p1
            ret = os.system(
                "%s -p1 < %s" % (config.PATCH, self.exc_patch_dst))

            if ret != 0:
                utils.error(
                    "Could not apply EXC patch.  Fix and try again.")
コード例 #16
0
ファイル: main.py プロジェクト: iamparas/openVulnAPI
def main():

    args = process_command_line()
    api_resource_key, api_resource_value = args.api_resource

    client = query_client.OpenVulnQueryClient(config.CLIENT_ID, config.CLIENT_SECRET)
    query_client_func = getattr(client, 'get_by_{0}'.format(api_resource_key))
    if not args.advisory_format:
        advisories = query_client_func(api_resource_value)
    else:
        if api_resource_key in constants.allows_filter:
            filter = query_client.Filter()
            if args.first_published:
                start_date, end_date = args.first_published
                filter = query_client.FirstPublishedFilter(start_date, end_date)
            elif args.last_published:
                start_date, end_date = args.last_published
                filter = query_client.LastPublishedFilter(start_date, end_date)
            advisories = query_client_func(args.advisory_format, api_resource_value, filter)
        else:
            advisories = query_client_func(args.advisory_format, api_resource_value)

    returned_output = None
    if args.fields:
        if args.count:
            returned_output = [utils.count_fields(advisories, args.fields)]
        else:
            returned_output = utils.filter_advisories(advisories, args.fields)
    else:
        returned_output = utils.filter_advisories(advisories, constants.API_LABELS)

    output_format, file_path = args.output_format

    with utils.get_output_filehandle(file_path) as f:
        utils.output(returned_output, output_format, f)
コード例 #17
0
    def configure(self):
        if os.path.exists(
            os.path.join(self.build_dir, 'CMakeFiles/cmake.check_cache')):
            utils.output("vtktud build already configured.")
            return
        
        if not os.path.exists(self.build_dir):
            os.mkdir(self.build_dir)

        cmake_params = "-DBUILD_SHARED_LIBS=ON " \
                       "-DBUILD_CONTRIB=OFF " \
                       "-DBUILD_TESTING=OFF " \
                       "-DCMAKE_BACKWARDS_COMPATIBILITY=2.6 " \
                       "-DCMAKE_BUILD_TYPE=RelWithDebInfo " \
                       "-DCMAKE_INSTALL_PREFIX=%s " \
                       "-DVTK_DIR=%s" % (self.inst_dir, config.VTK_DIR)

        # we only add this under posix as a work-around to compile the
        # STLib code under g++
        if os.name == 'posix':
            cmake_params = cmake_params + " -DCMAKE_CXX_FLAGS=-fpermissive "

        ret = utils.cmake_command(self.build_dir, self.source_dir,
                cmake_params)

        if ret != 0:
            utils.error("Could not configure vtktud.  Fix and try again.")
コード例 #18
0
ファイル: ip_pyqt.py プロジェクト: codester2/devide.johannes
 def clean_build(self):
     # nuke the build dir, the source dir is pristine
     utils.output("Removing build and installation directories.")
     if os.path.exists(self.build_dir):
         shutil.rmtree(self.build_dir)
     
     self.clean_install()
コード例 #19
0
ファイル: ip_scipy.py プロジェクト: codester2/devide.johannes
 def get(self):
     if os.path.exists(self.tbfilename):
         utils.output("%s already present, not downloading." %
                      (SCIPY_ARCHIVE,))
     else:
         utils.goto_archive()
         utils.urlget(SCIPY_URL, SCIPY_ARCHIVE)
コード例 #20
0
    def clean_build(self):
        utils.output("Removing build and installation directories.")
        if os.path.exists(self.inst_dir):
            shutil.rmtree(self.inst_dir)

        if os.path.exists(self.build_dir):
            shutil.rmtree(self.build_dir)
コード例 #21
0
    def install(self):
        # to test for install, just do python -c "import matplotlib"
        # and test the result (we could just import directly, but that would
        # only work once our invoking python has been stopped and started
        # again)
        os.chdir(config.archive_dir) # we need to be elsewhere!
        ret = os.system('%s -c "import matplotlib"' % (sys.executable,))
        if ret == 0:
            utils.output('matplotlib already installed.  Skipping step.')

        else:
            utils.output('ImportError test shows that matplotlib is not '
                         'installed.  Installing...')

            if os.name == 'nt':
                self.install_nt()
            else:
                self.install_posix()

            # make sure the backend is set to WXAgg
            # and that interactive is set to True
            rcfn = os.path.join(
                    config.PYTHON_SITE_PACKAGES,
                    'matplotlib', 'mpl-data', 'matplotlibrc')
            utils.re_sub_filter_file(
                    [("(\s*backend\s*\:).*", "\\1 WXAgg"),
                     ("#*(\s*interactive\s:).*","\\1 True")], rcfn)
コード例 #22
0
    def install(self):
        config.WRAPITK_TOPLEVEL = self.inst_dir
        # this dir contains the WrapITK cmake config (WrapITKConfig.cmake)
        config.WRAPITK_DIR = os.path.join(
                self.inst_dir, 'lib', 'InsightToolkit', 'WrapITK')
        # contains all WrapITK shared objects / libraries
        config.WRAPITK_LIB = os.path.join(config.WRAPITK_DIR, 'lib')
        # contains itk.py
        config.WRAPITK_PYTHON = os.path.join(config.WRAPITK_DIR, 'Python')
        # subsequent wrapitk components will need this
        config.WRAPITK_SOURCE_DIR = self.source_dir

        posix_file = os.path.join(
                config.WRAPITK_LIB, '_RegistrationPython.so')
        nt_file = os.path.join(
                config.WRAPITK_LIB, '_RegistrationPython' + config.PYE_EXT)

        if utils.file_exists(posix_file, nt_file):
            utils.output("WrapITK already installed, skipping step.")
        else:
            os.chdir(self.build_dir)
            ret = utils.make_command('WrapITK.sln', install=True)

            if ret != 0:
                utils.error(
                "Could not install WrapITK.  Fix and try again.")
コード例 #23
0
ファイル: ip_qt.py プロジェクト: codester2/devide.johannes
 def install(self):
     if os.path.exists(config.QT_BIN):
         utils.output("%s already installed. Skipping step." % BASENAME)
         return
     
     # Just copy the bin folder
     shutil.copytree(config.QT_BUILD_BIN, config.QT_BIN)
コード例 #24
0
    def copy_devide_to_inst(self):
        # we unpack by copying the checked out tree to the build dir
        if os.path.isdir(self.inst_dir):
            utils.output(
                'DeVIDE already present in inst dir.  Skipping step.')
            return

        shutil.copytree(self.source_dir, self.inst_dir)
コード例 #25
0
 def list(self):
     """ Lists the methods of this install package.
        (Sometimes I forget what the exact names are)
     """
     atts = dir(self)
     for att in atts:
         if type(getattr(self, att)) == types.MethodType:
             utils.output(att)
コード例 #26
0
ファイル: ip_dcmtk.py プロジェクト: codester2/devide.johannes
    def clean_build(self):
        # nuke installation and build directories, at the next run this
        # will lead to a configure, build and install.
        utils.output("Removing DCMTK build and installation dirs.")
        if os.path.exists(self.build_dir):
            shutil.rmtree(self.build_dir)

        if os.path.exists(self.inst_dir):
            shutil.rmtree(self.inst_dir)
コード例 #27
0
ファイル: ip_ima3d.py プロジェクト: codester2/devide.johannes
 def get(self):
     if os.path.exists(self.source_dir):
         utils.output("%s already checked out, skipping step." % BASENAME)            
     
     else:
         os.chdir(config.archive_dir)
         ret = os.system("%s clone %s" % (config.HG, HG_REPO))
         if ret != 0:
             utils.error("Could check out %s using HG. Fix and try again." % BASENAME)
             return   
コード例 #28
0
 def install(self):
     if os.path.exists(os.path.join(self.site_packages, 'py2exe')):
         utils.output("%s already installed. Skipping step." % BASENAME)
         return
     
     os.chdir(self.build_dir)
     ret = call("%s setup.py install" % config.PYTHON_EXECUTABLE, shell=True) 
     
     if ret != 0:
         utils.error("Could not install %s.  Fix and try again." % BASENAME)
コード例 #29
0
ファイル: ip_zlib.py プロジェクト: codester2/devide.johannes
 def build(self):
     if os.path.exists(os.path.join(self.build_dir, 'compress.obj')) or os.path.exists(os.path.join(self.build_dir, 'compress.o')):
         utils.output("%s already built, skipping step." % BASENAME)
         return
     
     os.chdir(self.build_dir)
     ret = utils.execute_in_vs_environment('nmake /f win32/Makefile.msc')
     
     if ret != 0:
         utils.error("Could not build %s.  Fix and try again." % BASENAME)
コード例 #30
0
 def clean_build(self):
     """This method should clean up in such a way that the next build
     of this package will result in AT LEAST all steps from configure
     and onwards. By default, it removes the build dir and calls
     clean_install().
     """
     utils.output("Removing build and installation directories.")
     if os.path.exists(self.build_dir):
         shutil.rmtree(self.build_dir)
     self.clean_install()
コード例 #31
0
    def get(self):
        if os.path.exists(self.source_dir):
            utils.output("DeVIDE already checked out, skipping step.")

        else:
            os.chdir(config.archive_dir)
            ret = os.system("%s clone %s -u %s" % (config.HG, HG_REPO, CHANGESET_ID))
            if ret != 0:
                utils.error("Could not hg clone DeVIDE.  "
                            "Fix and try again.")
コード例 #32
0
    def build(self):
        if os.path.exists(self.build_dir):
            utils.output("%s already built, skipping step." % BASENAME)
            return

        shutil.copytree(self.source_dir, self.build_dir)
        os.chdir(self.build_dir)
        ret = call("%s setup.py build" % config.PYTHON_EXECUTABLE, shell=True)

        if ret != 0:
            utils.error("Could not build %s.  Fix and try again." % BASENAME)
コード例 #33
0
    def get(self):
        if os.path.exists(self.source_dir):
            utils.output("%s already checked out, skipping step." % BASENAME)
            return

        os.chdir(config.archive_dir)
        ret = call("%s co %s %s" % (config.SVN, SVN_REPO, BASENAME),
                   shell=True)

        if ret != 0:
            utils.error("Could not SVN checkout.  Fix and try again.")
コード例 #34
0
ファイル: ip_teem.py プロジェクト: nagyistoce/devide.johannes
    def install(self):
        if os.path.exists(
                os.path.join(self.inst_dir, 'bin', 'unu' + config.EXE_EXT)):
            utils.output("teem already installed.  Skipping step.")

        else:
            os.chdir(self.build_dir)
            ret = utils.make_command('teem.sln', install=True)

            if ret != 0:
                utils.error("Could not install teem.  Fix and try again.")
コード例 #35
0
ファイル: next.py プロジェクト: jtorresdev/leonify
def next(request):
    device_id = getDeviceId()
    if device_id:
        sp_request('POST', 'me/player/next', {"device_id": device_id})
        current_song = getCurrentSong()
        utils.output(
            'end', 'success',
            utils.translate('next', {
                "name": current_song['name'],
                "by": current_song['artists']
            }))
コード例 #36
0
    def get(self):
        if os.path.exists(self.source_dir):
            utils.output("%s already checked out, skipping step." % BASENAME)

        else:
            os.chdir(config.archive_dir)
            ret = os.system("%s clone %s" % (config.HG, HG_REPO))
            if ret != 0:
                utils.error("Could check out %s using HG. Fix and try again." %
                            BASENAME)
                return
コード例 #37
0
    def clean_build(self):
        utils.output("Removing build and install directories.")
        if os.path.exists(self.build_dir):
            shutil.rmtree(self.build_dir)

        from distutils import sysconfig
        matplotlib_instdir = os.path.join(sysconfig.get_python_lib(),
                                          'matplotlib')
        
        if os.path.exists(matplotlib_instdir):
            shutil.rmtree(matplotlib_instdir)
コード例 #38
0
 def build(self):
     test_file = os.path.join(self.build_dir, 'sipgen', 'sip.exe')
     if os.path.exists(test_file):
         utils.output("%s already installed, skipping step." % BASENAME)
         return
     
     os.chdir(self.build_dir)
     ret = utils.execute_in_vs_environment('nmake')
     
     if ret != 0:
         utils.error("Could not build %s.  Fix and try again." % BASENAME)
コード例 #39
0
ファイル: ip_swig.py プロジェクト: nagyistoce/devide.johannes
    def unpack(self):
        # on posix, we have to unpack in the build directory as we're
        # actually going to compile.  On Windows, we unpack binaries
        # in the install step.
        if os.name == "posix":
            if os.path.isdir(self.build_dir):
                utils.output("SWIG already unpacked, skipping step.")

            else:
                utils.output("Unpacking SWIG.")
                utils.unpack_build(self.archive_path)
コード例 #40
0
ファイル: ip_qt.py プロジェクト: nagyistoce/devide.johannes
    def unpack(self):
        if os.path.exists(os.path.join(self.build_dir, "configure.exe")):
            utils.output("%s already unpacked. Skipping." % BASENAME)
            return

        utils.output("Unpacking %s." % BASENAME)
        utils.unpack_build(self.archive_path)

        # Rename the folder:
        shutil.move(os.path.join(config.build_dir, ARCHIVE_BASENAME),
                    self.build_dir)
コード例 #41
0
    def install(self):
        if os.path.exists(os.path.join(self.site_packages, 'py2exe')):
            utils.output("%s already installed. Skipping step." % BASENAME)
            return

        os.chdir(self.build_dir)
        ret = call("%s setup.py install" % config.PYTHON_EXECUTABLE,
                   shell=True)

        if ret != 0:
            utils.error("Could not install %s.  Fix and try again." % BASENAME)
コード例 #42
0
ファイル: ip_twb.py プロジェクト: nagyistoce/devide.johannes
    def install(self):
        posix_file = os.path.join(self.inst_dir, 'bin/ErGUI')
        nt_file = os.path.join(self.inst_dir, 'bin', 'ErGUI.exe')

        if utils.file_exists(posix_file, nt_file):    
            utils.output("Template Workbench already installed. Skipping install step.")

        else:
			ret = utils.make_command('ErGUI.sln', install=True)
			if ret != 0:
				utils.error("Could not install Template Workbench. Fix and try again.")
コード例 #43
0
ファイル: ip_pyqt.py プロジェクト: nagyistoce/devide.johannes
    def build(self):
        if os.path.exists(os.path.join(self.build_dir, 'QtCore',
                                       'QtCore.pyd')):
            utils.output("%s already built.  Skipping build step." % BASENAME)
            return

        os.chdir(self.build_dir)
        ret = utils.execute_in_vs_environment('nmake')

        if ret != 0:
            utils.error("Could not build %s.  Fix and try again." % BASENAME)
コード例 #44
0
    def get(self):
        if os.path.exists(self.source_dir):
            utils.output("vtktudoss already checked out, skipping step.")

        else:
            os.chdir(config.archive_dir)
            # checkout trunk into directory vtktudoss
            ret = os.system("%s co %s %s -r%s" %
                            (config.SVN, SVN_REPO, BASENAME, SVN_REL))
            if ret != 0:
                utils.error("Could not SVN checkout.  Fix and try again.")
コード例 #45
0
    def get(self):
        if os.path.exists(self.source_dir):
            utils.output("CableSwig already checked out, skipping step.")

        else:
            os.chdir(config.archive_dir)
            ret = os.system("%s -d %s co %s %s" %
                            (config.CVS, CVS_REPO, CVS_VERSION, BASENAME))

            if ret != 0:
                utils.error("Could not CVS checkout.  Fix and try again.")
コード例 #46
0
    def get(self):
        if os.path.exists(self.source_dir):
            utils.output("vtkdevide already checked out, skipping step.")

        else:
            os.chdir(config.archive_dir)
            ret = os.system("%s clone %s -u %s %s" %
                            (config.HG, HG_REPO, CHANGESET_ID, BASENAME))
            if ret != 0:
                utils.error("Could not hg clone vtkdevide.  "
                            "Fix and try again.")
コード例 #47
0
def complete_todos(string, entities):
    """Complete todos"""

    # List name
    listname = ''

    # Todos
    todos = []

    # Find entities
    for item in entities:
        if item['entity'] == 'list':
            listname = item['sourceText'].lower()
        elif item['entity'] == 'todos':
            # Split todos into array and trim start/end-whitespaces
            todos = [
                chunk.strip()
                for chunk in item['sourceText'].lower().split(',')
            ]

    # Verify if a list name has been provided
    if not listname:
        return utils.output('end', 'list_not_provided',
                            utils.translate('list_not_provided'))

    # Verify todos have been provided
    if len(todos) == 0:
        return utils.output('end', 'todos_not_provided',
                            utils.translate('todos_not_provided'))

    # Verify the list exists
    if db_lists.count(Query.name == listname) == 0:
        # Create the new to-do list
        dbCreateList(listname)

    result = ''
    for todo in todos:
        for db_todo in db_todos.search(Query.list == listname):
            # Rough matching (e.g. 1kg of rice = rice)
            if db_todo['name'].find(todo) != -1:
                db_todos.update({
                    'is_completed': True,
                    'updated_at': timestamp
                }, (Query.list == listname) & (Query.name == db_todo['name']))

                result += utils.translate('list_completed_todo_element',
                                          {'todo': db_todo['name']})

    return utils.output(
        'end', 'todos_completed',
        utils.translate('todos_completed', {
            'list': listname,
            'result': result
        }))
コード例 #48
0
    def install_nt(self):
        config.CMAKE_BINPATH = os.path.join(self.inst_dir, 'bin', 'cmake.exe')

        utils.goto_inst()
        if os.path.exists('cmake'):
            utils.output('CMAKE already installed, Skipping.')
            return

        # this will unpack into inst/cmake-VER-win32-x86/bin etc
        utils.unpack(self.afilename)
        # so we rename it to plain 'cmake'
        os.rename(CMAKE_DIRBASE, 'cmake')
コード例 #49
0
    def install_posix(self):
        cmake_binpath = os.path.join(self.inst_dir, 'bin/cmake')
        if os.path.exists(cmake_binpath):
            utils.output("CMAKE already installed. Skipping.")

        else:
            ret = os.system('make install')
            if ret != 0:
                utils.error('Could not install cmake.  Fix and try again.')

        # either way, we have to register our binary path with config
        config.CMAKE_BINPATH = cmake_binpath
コード例 #50
0
ファイル: ip_teem.py プロジェクト: nagyistoce/devide.johannes
    def build(self):
        bin_path = os.path.join(self.build_dir, 'bin')

        if utils.file_exists(bin_path, bin_path):
            utils.output("teem already built.  Skipping build step.")

        else:
            os.chdir(self.build_dir)
            ret = utils.make_command('teem.sln')

            if ret != 0:
                utils.error("Could not build teem.  Fix and try again.")
コード例 #51
0
    def install(self):
        if os.path.exists(
                os.path.join(config.WRAPITK_LIB,
                             '_itktudossPython' + config.PYE_EXT)):
            utils.output("itktudoss already installed.  Skipping step.")

        else:
            os.chdir(self.build_dir)
            ret = utils.make_command('itktudoss.sln', install=True)

            if ret != 0:
                utils.error("Could not install itktudoss.  Fix and try again.")
コード例 #52
0
 def configure(self):
     if os.path.exists(os.path.join(self.build_dir, 'Makefile')):
         utils.output("%s build already configured." % BASENAME)
         return
     
     os.chdir(self.build_dir)
     platform = 'win32-msvc2008' #TODO: platform on linux?
     ret = call('%s configure.py -p %s' %
             (config.PYTHON_EXECUTABLE, platform), shell=True)
     
     if ret != 0:
         utils.error("Could not configure %s.  Fix and try again." % BASENAME)
コード例 #53
0
ファイル: ip_qt.py プロジェクト: nagyistoce/devide.johannes
    def build(self):
        posix_file = os.path.join(config.QT_BUILD_BIN, 'libQtCore4.so')  #TODO:
        nt_file = os.path.join(config.QT_BUILD_BIN, 'QtCore4.dll')
        if utils.file_exists(posix_file, nt_file):
            utils.output("%s already built.  Skipping build step." % BASENAME)
            return

        os.chdir(self.build_dir)
        ret = utils.execute_in_vs_environment('nmake')

        if ret != 0:
            utils.error("Could not build %s.  Fix and try again." % BASENAME)
コード例 #54
0
ファイル: ip_zlib.py プロジェクト: nagyistoce/devide.johannes
    def build(self):
        if os.path.exists(os.path.join(
                self.build_dir, 'compress.obj')) or os.path.exists(
                    os.path.join(self.build_dir, 'compress.o')):
            utils.output("%s already built, skipping step." % BASENAME)
            return

        os.chdir(self.build_dir)
        ret = utils.execute_in_vs_environment('nmake /f win32/Makefile.msc')

        if ret != 0:
            utils.error("Could not build %s.  Fix and try again." % BASENAME)
コード例 #55
0
    def unpack(self):
        if os.path.isdir(self.build_dir):
            utils.output("SCIPY source already unpacked, not redoing.")
            return

        utils.output("Unpacking SCIPY source.")
        if os.name == 'posix':
            utils.unpack_build(self.tbfilename)
        else:
            os.mkdir(self.build_dir)
            os.chdir(self.build_dir)
            utils.unpack(self.tbfilename)
コード例 #56
0
    def build(self):
        nt_file = os.path.join(self.build_dir, 'vtkTeemInit.cxx')

        if utils.file_exists(nt_file, nt_file):
            utils.output("vtkTeem already built.  Skipping build step.")

        else:
            os.chdir(self.build_dir)
            ret = utils.make_command('vtkTeem.sln')

            if ret != 0:
                utils.error("Could not build vtkTeem.  Fix and try againn.")
コード例 #57
0
    def get(self):
        if os.path.exists(self.afilename):
            utils.output("%s already present, not downloading." %
                         (WXP_ARCHIVE, ))

        else:
            utils.goto_archive()
            utils.urlget(WXP_URL)

        if os.name == 'posix':
            if not os.path.exists(self.patch1_dst):
                shutil.copy(self.patch1_src, self.patch1_dst)
コード例 #58
0
ファイル: feature_selection.py プロジェクト: lvjunmei/thesis
def convertDSMatrix():
    ds = loadDataset(DOC_DATAEST)
    print 'collect vocabulary'
    V = set()
    instances = []
    for i in ds.instances:
        tokenDict = {}

        for l in i.split('\n'):
            tokens = l.split()
            for i in range(len(tokens)):
                t = tokens[i]
                if t not in tokenDict:
                    tokenDict[t] = 0

                tokenDict[t] += 1
                V.add(t)

        instances.append(tokenDict)

    print 'len(V) =', len(V)
    vocabularyIndex = {t: i for i, t in enumerate(V)}
    utils.output('vocabulary_index.txt',
                 [(f, i) for f, i in vocabularyIndex.iteritems()])

    row = []
    col = []
    data = []

    for i, instance in enumerate(instances):
        if i % 100 == 0:
            print i

        for f, c in instance.iteritems():
            j = vocabularyIndex[f]

            row.append(i)
            col.append(j)
            data.append(1.0 * c)

    row = np.array(row)
    col = np.array(col)
    data = np.array(data)

    m = spmatrix((data, (row, col)))

    spDS = Dataset()
    spDS.labels = np.array(ds.labels)
    spDS.users = ds.users
    spDS.instances = m
    spDS.vocabularyIndex = vocabularyIndex

    spDS.save(PATH + 'unigram_sp.dat')
コード例 #59
0
ファイル: weather.py プロジェクト: gnouf1/leonweather
def weather(string, entities):
    """Check the weather"""

    city = 'vide0'  #On initialise la variable city

    for item in entities:  #On va chercher dans 'entities' la ville demandée par l'utilisateur
        if item['entity'] == 'city':
            city = item['sourceText'].lower()

    #return utils.output('end', 'inter', utils.translate('inter', {'cit' : city}))

    if city == 'vide0':
        return utils.output('end', 'error', utils.translate('error'))

    url = "http://api.openweathermap.org/data/2.5/weather?appid=9ad6e7083f9e9c5d558ee4d7925e17ed&q=" + city
    content = requests.get(url)
    data = content.json()

    #On test les codes d'erreurs
    if data['cod'] != 200:  #Si c'est différent de 200 c'est qu'il y'a un problème
        if data['cod'] == "404":  #Il ne trouve pas
            return utils.output('end', '404_city_not_found',
                                utils.translate('404_city_not_found'))
        elif data['cod'] == "429":  #Trop de demande à la minute
            return utils.output('end', 'ezy', utils.translate('ezy'))
        else:
            return utils.output('end', 'error', utils.translate('error'))

    t = data['main']['temp']
    sky = data['weather'][0]['main']

    t = t - 273.15
    t = round(t, 1)

    vir = city.find(',')
    es = city.find(' ')

    if vir != -1:
        city = city[:vir]
    elif es != -1:
        city = city[:es]

    city = city.capitalize()
    sky = sky.lower()

    return utils.output(
        'end', 'weather',
        utils.translate('weather', {
            'cit': city,
            'sky': sky,
            't': t
        }))
コード例 #60
0
ファイル: ip_vtk.py プロジェクト: nagyistoce/devide.johannes
    def build(self):
        posix_file = os.path.join(self.build_dir, 'bin/libvtkWidgetsPython.so')
        nt_file = os.path.join(self.build_dir, 'bin', config.BUILD_TARGET,
                               'vtkWidgetsPythonD.dll')

        if utils.file_exists(posix_file, nt_file):
            utils.output("VTK already built.  Skipping build step.")

        else:
            os.chdir(self.build_dir)
            ret = utils.make_command('VTK.sln')
            if ret != 0:
                utils.error("Error building VTK.  Fix and try again.")