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


Python support.warning函数代码示例

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


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

示例1: send_lowlevel

 def send_lowlevel(self, user, data):
     ip = user.get('ip')
     port = user.get('port')
     if ip == None or port == None:
         warning('fetcher: No ip/port to open %s\n' % (user.tag()))
         return
     send_broadcast(ip, port, data)
开发者ID:proximate,项目名称:proximate,代码行数:7,代码来源:udpfetcher.py

示例2: register_rpchandler

def register_rpchandler(cmd, rpchandler):
    """ register_rpchandler(cmd, rpchandler):

    An RPC handler is registered. The RPC handler is used to
    receive messages from network. Specifically, if an incoming
    TCP connection begins with a line containing 'cmd' string,
    rpchandler is called by rpchandler(data, eof, socket,
    address), where 'data' is the data received so far in the
    socket, 'eof' indicates whether there is more data still
    coming (if 'eof' == False, data can be partial).  'socket' is
    the TCP socket for remote, and 'address' is the network
    address of the remote end (ip address string, remote port).

    rpchandler() can be called many times until eof is True or more data
    comes. This allows incremental processing of incoming message
    (e.g. terminate invalid messages early).

    rpchandler() returns a value that is one of:

    RPC_MORE_DATA: the handler will want more data
    RPC_CLOSE:     the handler asks main handler to terminate the connection
    RPC_RELEASE:   the handler will take care of the socket from now on
    """

    if rpc_commands.has_key(cmd):
        warning('Can not install RPC handler: %s already exists\n' % cmd)
        return False
    rpc_commands[cmd] = rpchandler
    return True
开发者ID:proximate,项目名称:proximate,代码行数:29,代码来源:plugins.py

示例3: get_expiring_file

    def get_expiring_file(self, dt=None, rel=None):
        """ Create a temp file, which expires at a given time. The temp file
            is stored under user's proximate directory. The file will expire
            (be deleted) after the given time. The actual deletion time is
            not very accurate.

            dt is a point in time, which is an instance of datetime.datetime.
            If dt == None, it is assumed to be now. If rel == None,
            it is assumed to be zero. Otherwise it is assumed to be a
            relative delay with respect to dt.
            rel is an instance of datetime.timedelta.

            Hint: Use scheduler.DAY and scheduler.SECOND to specify relative
            times """

        assert(dt == None or isinstance(dt, datetime))
        assert(rel == None or isinstance(rel, timedelta))

        if dt == None:
            dt = datetime.now()
        if rel != None:
            dt = dt + rel
        # ISO date: YYYY-MM-DD-s, where s is a number of seconds in the day
        isodate = str(dt.date())
        seconds = str(dt.hour * 3600 + dt.minute * 60 + dt.second)
        prefix = '%s-%s-%s-' % (self.EXPIRE_PREFIX, isodate, seconds)
        directory = self.community.get_user_dir()
        try:
            (fd, fname) = mkstemp(prefix=prefix, dir=directory)
        except OSError:
            warning('expiring_file: mkstemp() failed\n')
            return None
        xclose(fd)
        return fname
开发者ID:proximate,项目名称:proximate,代码行数:34,代码来源:scheduler.py

示例4: connect

    def connect(self):
        ip = self.user.get('ip')
        port = self.user.get('port')

        if not community.get_network_state(community.IP_NETWORK):
            # Act as if we were missing the IP network
            warning('fetcher: IP network disabled\n')
            ip = None

        if ip == None or port == None:
            warning('fetcher: No ip/port to open %s\n' % (self.user.tag()))
            return False

        debug('fetcher: open from %s: %s:%s\n' % (self.user.tag(), ip, port))

        if self.openingconnection == False or self.q.connect((ip, port), TP_CONNECT_TIMEOUT) == False:
            return False

        # The first write is seen by opposite side's RPC hander, not TCP_Queue
        prefix = '%s\n' %(TP_FETCH_RECORDS)
        self.q.write(prefix, writelength=False)

        self.q.write(fetcher.encode(firstmsg, -1, ''))

        # Close queue that is idle for a period of time. This is also the
        # maximum processing time for pending requests. Requests taking
        # longer than this must use other state tracking mechanisms.
        self.q.set_timeout(TP_FETCH_TIMEOUT)
        return True
开发者ID:proximate,项目名称:proximate,代码行数:29,代码来源:tcpfetcher.py

示例5: add_or_update_user

    def add_or_update_user(self, uid, updatelist, profileversion, ip, port, profile=None):
        user = get_user(uid)
        newuser = (user == None)
        if newuser:
            user = create_user(uid)
            if not user:
                warning('community: Unable to create a new user %s\n' % uid)
                return

        if ip != None:
            user.set('ip', ip)
            user.set('port', port)

        if newuser or user.get('v') != profileversion:
            user.update_attributes(updatelist, user.get('v'))

            if profile != None:
                self.got_user_profile(user, profile, None)
            elif not user.inprogress:
                debug('Fetching new profile from user %s\n' % user.tag())
                request = {'t': 'uprofile'}
                if self.fetcher.fetch(user, PLUGIN_TYPE_COMMUNITY, request, self.got_user_profile):
                    user.inprogress = True

        elif not user.present and not user.inprogress:
            # User appears and user profile is already up-to-date
            self.request_user_icon(user)
            self.fetch_community_profiles(user)

        if user.update_presence(True):
            self.announce_user(user)
开发者ID:proximate,项目名称:proximate,代码行数:31,代码来源:community.py

示例6: gen_key_pair_priv_cb

 def gen_key_pair_priv_cb(data, ctx):
     if not data:
         warning('keymanagement: Could not generate a key pair\n')
         cb(None, None)
     else:
         xrun([self.sslname, 'rsa', '-pubout'], gen_key_pair_pub_cb,
             data, data)
开发者ID:proximate,项目名称:proximate,代码行数:7,代码来源:keymanagement.py

示例7: got_community_profiles

    def got_community_profiles(self, user, reply, ctx):
        if reply == None:
            return

        validator = {
            'cname': [ZERO_OR_MORE, str],
            'profile': [ZERO_OR_MORE, {}]
           }
        if not validate(validator, reply):
            warning('Invalid community profiles reply\n' % str(reply))
            return

        communities = self.get_user_communities(user)

        for (cname, profile) in zip(reply['cname'], reply['profile']):
            if cname == DEFAULT_COMMUNITY_NAME:
                continue
            com = self.get_ordinary_community(cname)
            if com in communities:
                self.update_community_profile(com, user, profile)
                communities.remove(com)

        # Do icon requests for the rest of communities
        for com in communities:
            if com.get('name') != DEFAULT_COMMUNITY_NAME:
                self.request_com_icon(user, com)
开发者ID:proximate,项目名称:proximate,代码行数:26,代码来源:community.py

示例8: add_msg

    def add_msg(self, msg, set_head=False):
        parentid = msg.get_parentid()
        msgid = msg.get_msgid()

        if msgid in self.msgdict:
            warning('add_msg(): Attempted to add same message twice\n')
            return

        # add to msgdict
        self.msgdict[msgid] = msg

        # update children-list of parent
        if parentid != '':
            # Create a new list of children if it does not exist
            parent_children = self.childdict.setdefault(parentid, [])
            parent_children.append(msgid)

        has_parent = self.msgdict.has_key(parentid)
        children = self.childdict.get(msgid, [])

        # if parent of this node is not in msgdict, this is new root node
        if not has_parent:
            self.roots.append(msgid)

        # join trees by removing roots of child trees
        for childid in children:
            self.roots.remove(childid)

        if set_head:
            self.headid = msgid
开发者ID:proximate,项目名称:proximate,代码行数:30,代码来源:messaging.py

示例9: __init__

    def __init__(self):
        DBusGMainLoop(set_as_default=True)

        self.bus = SystemBus()
        self.sessionbus = SessionBus()
        try:
            self.mce = self.bus.get_object("com.nokia.mce", "/com/nokia/mce")
        except DBusException:
            warning("Nokia MCE not found. Vibra is disabled\n")
            return

        self.profiled = self.sessionbus.get_object("com.nokia.profiled", "/com/nokia/profiled")

        self.sessionbus.add_signal_receiver(
            self.profile_changed_handler,
            "profile_changed",
            "com.nokia.profiled",
            "com.nokia.profiled",
            "/com/nokia/profiled",
        )

        profile = self.profiled.get_profile(dbus_interface="com.nokia.profiled")
        self.get_vibra_enabled(profile)

        self.register_plugin(PLUGIN_TYPE_VIBRA)
开发者ID:proximate,项目名称:proximate,代码行数:25,代码来源:vibra.py

示例10: handle_rpc_message

    def handle_rpc_message(self, data, eof):
        if len(data) == 0:
            self.close()
            return False

        cmd = data[0:TP_MAX_CMD_NAME_LEN].split('\n')[0]

        rpchandler = rpc_commands.get(cmd)
        if rpchandler == None:
            self.close()
            return False

        payload = data[(len(cmd) + 1):]

        status = rpchandler(cmd, payload, eof, self.sock, self.address)
        ret = False
        if status == RPC_MORE_DATA:
            ret = True
        elif status == RPC_CLOSE:
            self.close()
        elif status == RPC_RELEASE:
            # We are not interested to gobject events anymore
            self.remove_io_notifications()
        else:
            self.close()
            warning('Unknown RPC value: %s\n' %(str(status)))
        return ret
开发者ID:proximate,项目名称:proximate,代码行数:27,代码来源:listener.py

示例11: read_communities

def read_communities():
    global communities
    if proximatedir == None:
        warning('No Proximate directory\n')
        return

    # Read community meta datas
    for dentry in os.listdir(proximatedir):
        if not dentry.startswith('c_'):
            continue
        if str_to_int(dentry[2:], None) == None:
            continue
        cdir = '%s/%s' %(proximatedir, dentry)
        if not os.path.isdir(cdir):
            continue
        cfile = '%s/profile' %(cdir)

        community = Community()
        try:
            f = open(cfile, 'r')
        except IOError:
            continue
        profile = f.read()
        f.close()
        if community.read_profile(profile):
            communities[community.get('cid')] = community

    defcom = get_ordinary_community(DEFAULT_COMMUNITY_NAME)
    if defcom == None:
        create_community(DEFAULT_COMMUNITY_NAME)
开发者ID:proximate,项目名称:proximate,代码行数:30,代码来源:proximatestate.py

示例12: init

def init():
    """ Bind a default and a random port.
        The random port is used for local network communication.
        The default port is used to establish remote connections. """

    global community
    community = get_plugin_by_type(PLUGIN_TYPE_COMMUNITY)

    create_tcp_listener(DEFAULT_PROXIMATE_PORT, tcp_listener_accept, reuse=True)

    success = False
    for i in xrange(PORT_RETRIES):
        port = community.get_rpc_port()
        if port == DEFAULT_PROXIMATE_PORT:
            continue
        (rfd, tag) = create_tcp_listener(port, tcp_listener_accept, reuse=True)
        if rfd != None:
            info('Listening to TCP connections on port %d\n' %(port))
            success = True
            break
        warning('Can not bind to TCP port %d\n' %(port))
        # Generate a new port number so that next iteration will not fail
        if not community.gen_port():
            break

    if not success:
        warning('Can not listen to TCP connections\n')
开发者ID:proximate,项目名称:proximate,代码行数:27,代码来源:listener.py

示例13: save_community_icon

def save_community_icon(com, icon):
    # personal communities can have arbitary large icons because the picture
    # is not sent over network
    if com.get('peer') and len(icon) > TP_MAX_FACE_SIZE:
        warning('Community %s has too large icon picture: %d\n' %(com.get('name'), len(icon)))
        return False
    return save_image(get_community_icon_name(com, legacyname=False), icon)
开发者ID:proximate,项目名称:proximate,代码行数:7,代码来源:proximatestate.py

示例14: chat_cb

 def chat_cb(self, widget):
     uid = self.msg.get('src')
     user = community.get_user(uid)
     if user == community.get_myself():
         warning('Trying to chat with yourself')
         return None
     chat.messaging_gui.start_messaging(user, False)
开发者ID:proximate,项目名称:proximate,代码行数:7,代码来源:messageboard_gui.py

示例15: xmkdir

def xmkdir(dirname, mode = 0700):
    try:
        mkdir(dirname, mode)
    except OSError, (errno, strerror):
        if errno != EEXIST:
            warning('Can not create a directory: %s\n' %(dirname))
            return False
开发者ID:proximate,项目名称:proximate,代码行数:7,代码来源:ossupport.py


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