当前位置: 首页>>代码示例>>Python>>正文


Python debug.warning函数代码示例

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


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

示例1: compute

    def compute(self):
        table = self.getInputFromPort('table')
        delimiter = self.getInputFromPort('delimiter')
        fileobj = self.interpreter.filePool.create_file(suffix='.csv')
        fname = fileobj.name

        with open(fname, 'w') as fp:
            write_header = self.forceGetInputFromPort('write_header')
            if write_header is not False:
                if table.names is None:
                    if write_header is True:  # pragma: no cover
                        raise ModuleError(
                                self,
                                "write_header is set but the table doesn't "
                                "have column names")

            if not table.columns:
                raise ModuleError(
                        self,
                        "Table has no columns")

            nb_lines = self.write(fname, table, delimiter,
                                  write_header is not False)

            rows = table.rows
            if nb_lines != rows:  # pragma: no cover
                debug.warning("WriteCSV wrote %d lines instead of expected "
                              "%d" % (nb_lines, rows))

        self.setResult('file', fileobj)
开发者ID:remram44,项目名称:tabledata-backport,代码行数:30,代码来源:write_csv.py

示例2: create_startupxml_if_needed

    def create_startupxml_if_needed(self):
        needs_create = True
        fname = self.get_startup_xml_fname()
        if os.path.isfile(fname):
            try:
                tree = ElementTree.parse(fname)
                startup_version = \
                    vistrails.db.services.io.get_version_for_xml(tree.getroot())
                version_list = version_string_to_list(startup_version)
                if version_list >= [0,1]:
                    needs_create = False
            except:
                debug.warning("Unable to read startup.xml file, "
                              "creating a new one")

        if needs_create:
            root_dir = system.vistrails_root_directory()
            origin = os.path.join(root_dir, 'core','resources',
                                  'default_vistrails_startup_xml')
            try:
                shutil.copyfile(origin, fname)
                debug.log('Succeeded!')
                self.first_run = True
            except:
                debug.critical("""Failed to copy default configuration
                file to %s. This could be an indication of a
                permissions problem. Please make sure '%s' is writable."""
                               % (fname, self._dot_vistrails))
                raise
开发者ID:alexmavr,项目名称:VisTrails,代码行数:29,代码来源:startup.py

示例3: updateVersion

    def updateVersion(self, versionNumber):
        """ updateVersion(versionNumber: int) -> None
        Update the property page of the version
        
        """
        self.versionNumber = versionNumber
        self.versionNotes.updateVersion(versionNumber)
        self.versionThumbs.updateVersion(versionNumber)
        self.versionMashups.updateVersion(versionNumber)
        if self.controller:
            if self.use_custom_colors:
                custom_color = self.controller.vistrail.get_action_annotation(
                        versionNumber, custom_color_key)
                if custom_color is not None:
                    try:
                        custom_color = parse_custom_color(custom_color.value)
                        custom_color = QtGui.QColor(*custom_color)
                    except ValueError, e:
                        debug.warning("Version %r has invalid color "
                                      "annotation (%s)" % (versionNumber, e))
                        custom_color = None
                self.customColor.setColor(custom_color)

            if self.controller.vistrail.actionMap.has_key(versionNumber):
                action = self.controller.vistrail.actionMap[versionNumber]
                name = self.controller.vistrail.getVersionName(versionNumber)
                self.tagEdit.setText(name)
                self.userEdit.setText(action.user)
                self.dateEdit.setText(action.date)
                self.idEdit.setText(unicode(action.id))
                self.tagEdit.setEnabled(True)
                return
            else:
                self.tagEdit.setEnabled(False)
                self.tagReset.setEnabled(False)
开发者ID:tacaswell,项目名称:VisTrails,代码行数:35,代码来源:version_prop.py

示例4: get_module

def get_module(value, signature):
    """
    Creates a module for value, in order to do the type checking.
    """

    from vistrails.core.modules.basic_modules import Boolean, String, Integer, Float, List

    if isinstance(value, Constant):
        return type(value)
    elif isinstance(value, bool):
        return Boolean
    elif isinstance(value, str):
        return String
    elif isinstance(value, int):
        return Integer
    elif isinstance(value, float):
        return Float
    elif isinstance(value, list):
        return List
    elif isinstance(value, tuple):
        v_modules = ()
        for element in xrange(len(value)):
            v_modules += (get_module(value[element], signature[element]))
        return v_modules
    else:
        from vistrails.core import debug
        debug.warning("Could not identify the type of the list element.")
        debug.warning("Type checking is not going to be done inside Map module.")
        return None
开发者ID:cjh1,项目名称:VisTrails,代码行数:29,代码来源:map.py

示例5: get_server_news

def get_server_news():
    global _server_news

    if _server_news is not None:
        return _server_news

    dot_vistrails = os.path.expanduser('~/.vistrails')
    if not os.path.exists(dot_vistrails):
        os.mkdir(dot_vistrails)

    file_name = os.path.join(dot_vistrails, 'server_news.json')
    file_exists = os.path.exists(file_name)

    headers = {}
    if file_exists:
        mtime = email.utils.formatdate(os.path.getmtime(file_name),
                                       usegmt=True)
        headers['If-Modified-Since'] = mtime

    try:
        resp = requests.get(
            'https://reprozip-stats.poly.edu/vistrails_news/%s' %
            vistrails_version(), headers=headers,
            timeout=2 if file_exists else 10,
            stream=True, verify=get_ca_certificate())
        resp.raise_for_status()
        if resp.status_code == 304:
            raise requests.HTTPError(
                '304 File is up to date, no data returned',
                response=resp)
    except requests.RequestException, e:
        if not e.response or e.response.status_code != 304:
            debug.warning("Can't download server news", e)
开发者ID:VisTrails,项目名称:VisTrails,代码行数:33,代码来源:reportusage.py

示例6: open

 def open(self):        
     retry = True
     while retry:
         config = {'host': self.host,
                   'port': self.port,
                   'user': self.user}
         
         # unfortunately keywords are not standard across libraries
         if self.protocol == 'mysql':    
             config['db'] = self.db_name
             if self.password is not None:
                 config['passwd'] = self.password
         elif self.protocol == 'postgresql':
             config['database'] = self.db_name
             if self.password is not None:
                 config['password'] = self.password
         try:
             self.conn = self.get_db_lib().connect(**config)
             break
         except self.get_db_lib().Error, e:
             debug.warning(str(e))
             if (e[0] == 1045 or self.get_db_lib().OperationalError 
                 and self.password is None):
                 passwd_dlg = QPasswordEntry()
                 if passwd_dlg.exec_():
                     self.password = passwd_dlg.get_password()
                 else:
                     retry = False
             else:
                 raise ModuleError(self, str(e))
开发者ID:lumig242,项目名称:VisTrailsRecommendation,代码行数:30,代码来源:init.py

示例7: py_import

def py_import(module_name, dependency_dictionary):
    """Tries to import a python module, installing if necessary.

    If the import doesn't succeed, we guess which system we are running on and
    install the corresponding package from the dictionary. We then run the
    import again.
    If the installation fails, we won't try to install that same module again
    for the session.
    """
    try:
        result = _vanilla_import(module_name)
        return result
    except ImportError:
        if not getattr(get_vistrails_configuration(), 'installBundles'):
            raise

    if module_name in _previously_failed_pkgs:
        raise PyImportException("Import of Python module '%s' failed again, "
                                "not triggering installation" % module_name)
    debug.warning("Import of python module '%s' failed. "
                  "Will try to install bundle." % module_name)

    success = vistrails.core.bundles.installbundle.install(dependency_dictionary)

    if not success:
        _previously_failed_pkgs.add(module_name)
        raise PyImportException("Installation of Python module '%s' failed." %
                                module_name)
    try:
        result = _vanilla_import(module_name)
        return result
    except ImportError, e:
        _previously_failed_pkgs.add(module_name)
        raise PyImportBug("Installation of package '%s' succeeded, but import "
                          "still fails." % module_name)
开发者ID:cjh1,项目名称:VisTrails,代码行数:35,代码来源:pyimport.py

示例8: get_module

def get_module(value, signature):
    """
    Creates a module for value, in order to do the type checking.
    """
    if isinstance(value, Constant):
        return type(value)
    elif isinstance(value, bool):
        return Boolean
    elif isinstance(value, str):
        return String
    elif isinstance(value, int):
        return Integer
    elif isinstance(value, float):
        return Float
    elif isinstance(value, list):
        return List
    elif isinstance(value, tuple):
        v_modules = ()
        for element in xrange(len(value)):
            v_modules += (get_module(value[element], signature[element]),)
        return v_modules
    else:
        debug.warning("Could not identify the type of the list element.")
        debug.warning("Type checking is not going to be done inside"
                      "FoldWithModule module.")
        return None
开发者ID:lumig242,项目名称:VisTrailsRecommendation,代码行数:26,代码来源:fold.py

示例9: py_import

def py_import(module_name, dependency_dictionary, store_in_config=False):
    """Tries to import a python module, installing if necessary.

    If the import doesn't succeed, we guess which system we are running on and
    install the corresponding package from the dictionary. We then run the
    import again.
    If the installation fails, we won't try to install that same module again
    for the session.
    """
    try:
        result = _vanilla_import(module_name)
        return result
    except ImportError:
        if not getattr(get_vistrails_configuration(), 'installBundles'):
            raise

    if module_name in _previously_failed_pkgs:
        raise PyImportException("Import of Python module '%s' failed again, "
                                "not triggering installation" % module_name)
    if store_in_config:
        ignored_packages_list = getattr(get_vistrails_configuration(),
                                        'bundleDeclinedList',
                                        None)
        if ignored_packages_list:
            ignored_packages = set(ignored_packages_list.split(';'))
        else:
            ignored_packages = set()
        if module_name in ignored_packages:
            raise PyImportException("Import of Python module '%s' failed "
                                    "again, installation disabled by "
                                    "configuration" % module_name)
    debug.warning("Import of python module '%s' failed. "
                  "Will try to install bundle." % module_name)

    success = vistrails.core.bundles.installbundle.install(
            dependency_dictionary)

    if store_in_config:
        if bool(success):
            ignored_packages.discard(module_name)
        else:
            ignored_packages.add(module_name)
        setattr(get_vistrails_configuration(),
                'bundleDeclinedList',
                ';'.join(sorted(ignored_packages)))
        setattr(get_vistrails_persistent_configuration(),
                'bundleDeclinedList',
                ';'.join(sorted(ignored_packages)))

    if not success:
        _previously_failed_pkgs.add(module_name)
        raise PyImportException("Installation of Python module '%s' failed." %
                                module_name)
    try:
        result = _vanilla_import(module_name)
        return result
    except ImportError, e:
        _previously_failed_pkgs.add(module_name)
        raise PyImportBug("Installation of package '%s' succeeded, but import "
                          "still fails." % module_name)
开发者ID:AnyarInc,项目名称:VisTrails,代码行数:60,代码来源:pyimport.py

示例10: compute_evaluation_order

 def compute_evaluation_order(self, aliases):
     # Build the dependencies graph
     dp = {}
     for alias,(atype,(base,exp)) in aliases.items():
         edges = []
         for e in exp:
             edges += self.get_name_dependencies()
         dp[alias] = edges
         
     # Topological Sort to find the order to compute aliases
     # Just a slow implementation, O(n^3)...
     unordered = copy.copy(list(aliases.keys()))
     ordered = []
     while unordered:
         added = []
         for i in xrange(len(unordered)):
             ok = True
             u = unordered[i]
             for j in xrange(len(unordered)):
                 if i!=j:
                     for v in dp[unordered[j]]:
                         if u==v:
                             ok = False
                             break
                     if not ok: break
             if ok: added.append(i)
         if not added:
             debug.warning('Looping dependencies detected!')
             break
         for i in reversed(added):
             ordered.append(unordered[i])
             del unordered[i]
     return ordered
开发者ID:danielballan,项目名称:VisTrails,代码行数:33,代码来源:base.py

示例11: identifier_is_available

    def identifier_is_available(self, identifier):
        """Searchs for an available (but disabled) package.

        If found, returns succesfully loaded, uninitialized package.

        There can be multiple package versions for a single identifier. If so,
        return the version that passes requirements, or the latest version.
        """
        matches = []
        for codepath in self.available_package_names_list():
            pkg = self.get_available_package(codepath)
            try:
                pkg.load()
                if pkg.identifier == identifier:
                    matches.append(pkg)
                elif identifier in pkg.old_identifiers:
                    matches.append(pkg)
                if (hasattr(pkg._module, "can_handle_identifier") and
                        pkg._module.can_handle_identifier(identifier)):
                    matches.append(pkg)
            except (pkg.LoadFailed, pkg.InitializationFailed,
                    MissingRequirement):
                pass
            except Exception, e:
                debug.warning(
                    "Error loading package <codepath %s>" % pkg.codepath,
                    e)
开发者ID:AnyarInc,项目名称:VisTrails,代码行数:27,代码来源:packagemanager.py

示例12: install

def install(dependency_dictionary):
    """Tries to install a bundle after a py_import() failed.."""

    distro = guess_system()
    files = (dependency_dictionary.get(distro) or
             dependency_dictionary.get('pip'))
    if not files:
        debug.warning("No source for bundle on this platform")
        return None
    can_install = (('pip' in dependency_dictionary and pip_installed) or
                   distro in dependency_dictionary)
    if can_install:
        action = show_question(
                files,
                distro in dependency_dictionary,
                'pip' in dependency_dictionary)
        if action == 'distro':
            callable_ = getattr(vistrails.gui.bundles.installbundle,
                                distro.replace('-', '_') + '_install')
            return callable_(files)
        elif action == 'pip':
            if not pip_installed:
                debug.warning("Attempted to use pip, but it is not installed.")
                return False
            return pip_install(dependency_dictionary.get('pip'))
        else:
            return False
开发者ID:hjanime,项目名称:VisTrails,代码行数:27,代码来源:installbundle.py

示例13: download

    def download(self, url):
        """download(url:string) -> (result: int, downloaded_file: File,
                                    local_filename:string)
        Tries to download a file from url. It returns a tuple with:
        result: 0 -> success
                1 -> couldn't download the file, but found a cached version
                2 -> failed (in this case downloaded_file will contain the 
                             error message)
        downloaded_file: The downloaded file or the error message in case it
                         failed
                         
        local_filename: the path to the local_filename
        
        """
        
        self._parse_url(url)

        opener = urllib2.build_opener()

        local_filename = self._local_filename(url)

        # Get ETag from disk
        try:
            with open(local_filename + '.etag') as etag_file:
                etag = etag_file.read()
        except IOError:
            etag = None

        try:
            request = urllib2.Request(url)
            if etag is not None:
                request.add_header(
                    'If-None-Match',
                    etag)
            try:
                mtime = email.utils.formatdate(os.path.getmtime(local_filename),
                                               usegmt=True)
                request.add_header(
                    'If-Modified-Since',
                    mtime)
            except OSError:
                pass
            f1 = opener.open(request)
        except urllib2.URLError, e:
            if isinstance(e, urllib2.HTTPError) and e.code == 304:
                # Not modified
                result = vistrails.core.modules.basic_modules.File()
                result.name = local_filename
                return (0, result, local_filename)
            if self._file_is_in_local_cache(local_filename):
                debug.warning('A network error occurred. HTTPFile will use a '
                              'cached version of the file')
                result = vistrails.core.modules.basic_modules.File()
                result.name = local_filename
                return (1, result, local_filename)
            else:
                return (2, (str(e)), local_filename)
开发者ID:dakoop,项目名称:vistrails-mta-example,代码行数:57,代码来源:init.py

示例14: compute

    def compute(self):
        localpath = self.force_get_input('path')
        hasquery = self.has_input('metadata')
        hashash = self.has_input('hash')

        file_store = get_default_store()

        if hashash:
            if localpath or hasquery:
                raise ModuleError(self,
                                  "Don't set other ports if 'hash' is set")
            h = self.get_input('hash')._hash
            self._set_result(file_store.get(h))
        elif hasquery:
            # Do the query
            metadata = self.get_input_list('metadata')
            metadata = dict(m.metadata for m in metadata)
            # Find the most recent match
            best = None
            for entry in file_store.query(metadata):
                if best is None or (KEY_TIME in entry.metadata and
                        entry[KEY_TIME] > best[KEY_TIME]):
                    best = entry
            if best is not None:
                self.check_path_type(best.filename)

            if localpath and os.path.exists(localpath.name):
                path = localpath.name
                self.check_path_type(path)
                if best is not None:
                    # Compare
                    if hash_path(path) != best['hash']:
                        # Record new version of external file
                        use_local = True
                    else:
                        # Recorded version is up to date
                        use_local = False
                else:
                    # No external file: use recorded version
                    use_local = True
                if use_local:
                    data = dict(metadata)
                    data[KEY_TYPE] = TYPE_INPUT
                    data[KEY_TIME] = datetime.strftime(datetime.utcnow(),
                                                       '%Y-%m-%d %H:%M:%S')
                    best = file_store.add(path, data)
                    self.annotate({'added_file': best['hash']})
            elif localpath:
                debug.warning("Local file does not exist: %s" % localpath)
            if best is None:
                raise ModuleError(self, "Query returned no file")
            self._set_result(best)
        else:
            raise ModuleError(self,
                              "Missing input: set either 'metadata' "
                              "(optionally with path) or hash")
开发者ID:AnyarInc,项目名称:VisTrails,代码行数:56,代码来源:persistedinput.py

示例15: package_requirements

def package_requirements():
    from vistrails.core.requirements import require_python_module, python_module_exists

    require_python_module(
        "vtk", {"linux-debian": "python-vtk", "linux-ubuntu": "python-vtk", "linux-fedora": "vtk-python"}
    )
    if not python_module_exists("PyQt4"):
        from vistrails.core import debug

        debug.warning("PyQt4 is not available. There will be no interaction " "between VTK and the spreadsheet.")
开发者ID:hjanime,项目名称:VisTrails,代码行数:10,代码来源:__init__.py


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