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

Python shared.safeConfigGetBoolean函数代码示例

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

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



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

示例1: updateText

    def updateText(self):
        text = unicode(shared.config.get(self.address, 'label'), 'utf-8)') + ' (' + self.address + ')'
        
        font = QtGui.QFont()
        if self.unreadCount > 0:
            # only show message count if the child doesn't show
            if not self.isExpanded():
                text += " (" + str(self.unreadCount) + ")"
            font.setBold(True)
        else:
            font.setBold(False)
        self.setFont(0, font)
            
        #set text color
        if shared.safeConfigGetBoolean(self.address, 'enabled'):
            if shared.safeConfigGetBoolean(self.address, 'mailinglist'):
                brush = QtGui.QBrush(QtGui.QColor(137, 04, 177))
            else:
                brush = QtGui.QBrush(QtGui.QApplication.palette().text().color())
            #self.setExpanded(True)        
        else:
            brush = QtGui.QBrush(QtGui.QColor(128, 128, 128))
            #self.setExpanded(False)
        brush.setStyle(QtCore.Qt.NoBrush)
        self.setForeground(0, brush)

        self.setIcon(0, avatarize(self.address))
        self.setText(0, text)
        self.setToolTip(0, text)
开发者ID:N0U,项目名称:PyBitmessage,代码行数:29,代码来源:foldertree.py


示例2: setType

 def setType(self):
     if shared.safeConfigGetBoolean(self.address, 'chan'):
         self.type = "chan"
     elif shared.safeConfigGetBoolean(self.address, 'mailinglist'):
         self.type = "mailinglist"
     else:
         self.type = "normal"
开发者ID:N0U,项目名称:PyBitmessage,代码行数:7,代码来源:foldertree.py


示例3: setType

 def setType(self):
     if self.address is None:
         self.type = self.ALL
     elif shared.safeConfigGetBoolean(self.address, 'chan'):
         self.type = self.CHAN
     elif shared.safeConfigGetBoolean(self.address, 'mailinglist'):
         self.type = self.MAILINGLIST
     else:
         self.type = self.NORMAL
开发者ID:lightrabbit,项目名称:PyBitmessage,代码行数:9,代码来源:foldertree.py


示例4: setType

 def setType(self):
     self.setFlags(self.flags() | QtCore.Qt.ItemIsEditable)
     if self.address is None:
         self.type = self.ALL
         self.setFlags(self.flags() & ~QtCore.Qt.ItemIsEditable)
     elif shared.safeConfigGetBoolean(self.address, 'chan'):
         self.type = self.CHAN
     elif shared.safeConfigGetBoolean(self.address, 'mailinglist'):
         self.type = self.MAILINGLIST
     else:
         self.type = self.NORMAL
开发者ID:Basti1993,项目名称:PyBitmessage,代码行数:11,代码来源:foldertree.py


示例5: run

 def run(self):
     from debug import logger
     
     logger.debug("Starting UPnP thread")
     logger.debug("Local IP: %s", self.localIP)
     lastSent = 0
     while shared.shutdown == 0 and shared.safeConfigGetBoolean('bitmessagesettings', 'upnp'):
         if time.time() - lastSent > self.sendSleep and len(self.routers) == 0:
             try:
                 self.sendSearchRouter()
             except:
                 pass
             lastSent = time.time()
         try:
             while shared.shutdown == 0 and shared.safeConfigGetBoolean('bitmessagesettings', 'upnp'):
                 resp,(ip,port) = self.sock.recvfrom(1000)
                 if resp is None:
                     continue
                 newRouter = Router(resp, ip)
                 for router in self.routers:
                     if router.location == newRouter.location:
                         break
                 else:
                     logger.debug("Found UPnP router at %s", ip)
                     self.routers.append(newRouter)
                     self.createPortMapping(newRouter)
                     shared.UISignalQueue.put(('updateStatusBar', tr._translate("MainWindow",'UPnP port mapping established on port %1').arg(str(self.extPort))))
                     break
         except socket.timeout as e:
             pass
         except:
             logger.error("Failure running UPnP router search.", exc_info=True)
         for router in self.routers:
             if router.extPort is None:
                 self.createPortMapping(router)
     try:
         self.sock.shutdown(socket.SHUT_RDWR)
     except:
         pass
     try:
         self.sock.close()
     except:
         pass
     deleted = False
     for router in self.routers:
         if router.extPort is not None:
             deleted = True
             self.deletePortMapping(router)
     shared.extPort = None
     if deleted:
         shared.UISignalQueue.put(('updateStatusBar', tr._translate("MainWindow",'UPnP port mapping removed')))
     logger.debug("UPnP thread done")
开发者ID:Basti420,项目名称:PyBitmessage,代码行数:52,代码来源:upnp.py


示例6: setType

 def setType(self):
     self.setFlags(self.flags() | QtCore.Qt.ItemIsEditable)
     if self.address is None:
         self.type = self.ALL
         self.setFlags(self.flags() & ~QtCore.Qt.ItemIsEditable)
     elif shared.safeConfigGetBoolean(self.address, 'chan'):
         self.type = self.CHAN
     elif shared.safeConfigGetBoolean(self.address, 'mailinglist'):
         self.type = self.MAILINGLIST
     elif sqlQuery(
         '''select label from subscriptions where address=?''', self.address):
         self.type = AccountMixin.SUBSCRIPTION
     else:
         self.type = self.NORMAL
开发者ID:52M,项目名称:PyBitmessage,代码行数:14,代码来源:foldertree.py


示例7: __init__

 def __init__(self, address=None):
     self.address = address
     self.type = AccountMixin.NORMAL
     if shared.config.has_section(address):
         if shared.safeConfigGetBoolean(self.address, "chan"):
             self.type = AccountMixin.CHAN
         elif shared.safeConfigGetBoolean(self.address, "mailinglist"):
             self.type = AccountMixin.MAILINGLIST
     elif self.address == str_broadcast_subscribers:
         self.type = AccountMixin.BROADCAST
     else:
         queryreturn = sqlQuery("""select label from subscriptions where address=?""", self.address)
         if queryreturn:
             self.type = AccountMixin.SUBSCRIPTION
开发者ID:Basti1993,项目名称:PyBitmessage,代码行数:14,代码来源:account.py


示例8: __init__

 def __init__(self, address, type = None):
     self.isEnabled = True
     self.address = address
     if type is None:
         if shared.safeConfigGetBoolean(self.address, 'mailinglist'):
             self.type = "mailinglist"
         elif shared.safeConfigGetBoolean(self.address, 'chan'):
             self.type = "chan"
         elif sqlQuery(
             '''select label from subscriptions where address=?''', self.address):
             self.type = 'subscription'
         else:
             self.type = "normal"
     else:
         self.type = type
开发者ID:Atheros1,项目名称:PyBitmessage,代码行数:15,代码来源:account.py


示例9: run

    def run(self):
        # If there is a trusted peer then we don't want to accept
        # incoming connections so we'll just abandon the thread
        if shared.trustedPeer:
            return

        while shared.safeConfigGetBoolean("bitmessagesettings", "dontconnect"):
            time.sleep(1)
        helper_bootstrap.dns()
        # We typically don't want to accept incoming connections if the user is using a
        # SOCKS proxy, unless they have configured otherwise. If they eventually select
        # proxy 'none' or configure SOCKS listening then this will start listening for
        # connections.
        while shared.config.get("bitmessagesettings", "socksproxytype")[
            0:5
        ] == "SOCKS" and not shared.config.getboolean("bitmessagesettings", "sockslisten"):
            time.sleep(5)

        with shared.printLock:
            print "Listening for incoming connections."

        # First try listening on an IPv6 socket. This should also be
        # able to accept connections on IPv4. If that's not available
        # we'll fall back to IPv4-only.
        try:
            sock = self._createListenSocket(socket.AF_INET6)
        except socket.error, e:
            if isinstance(e.args, tuple) and e.args[0] in (errno.EAFNOSUPPORT, errno.EPFNOSUPPORT, errno.ENOPROTOOPT):
                sock = self._createListenSocket(socket.AF_INET)
            else:
                raise
开发者ID:alertisme,项目名称:PyBitmessage,代码行数:31,代码来源:class_singleListener.py


示例10: run

def run(target, initialHash):
    target = int(target)
    if safeConfigGetBoolean('bitmessagesettings', 'opencl') and openclpow.has_opencl():
#        trialvalue1, nonce1 = _doGPUPoW(target, initialHash)
#        trialvalue, nonce = _doFastPoW(target, initialHash)
#        print "GPU: %s, %s" % (trialvalue1, nonce1)
#        print "Fast: %s, %s" % (trialvalue, nonce)
#        return [trialvalue, nonce]
        try:
            return _doGPUPoW(target, initialHash)
        except:
            pass # fallback
    if bmpow:
        try:
            return _doCPoW(target, initialHash)
        except:
            pass # fallback
    if frozen == "macosx_app" or not frozen:
        # on my (Peter Surda) Windows 10, Windows Defender
        # does not like this and fights with PyBitmessage
        # over CPU, resulting in very slow PoW
        # added on 2015-11-29: multiprocesing.freeze_support() doesn't help
        try:
            return _doFastPoW(target, initialHash)
        except:
            pass #fallback
    return _doSafePoW(target, initialHash)
开发者ID:lightrabbit,项目名称:PyBitmessage,代码行数:27,代码来源:proofofwork.py


示例11: signal_handler

def signal_handler(signal, frame):
    if shared.safeConfigGetBoolean('bitmessagesettings', 'daemon'):
        shared.doCleanShutdown()
        sys.exit(0)
    else:
        print('Unfortunately you cannot use Ctrl+C ' +
              'when running the UI because the UI captures the signal.')
开发者ID:vinctux,项目名称:PyBitmessage,代码行数:7,代码来源:helper_generic.py


示例12: getBitfield

def getBitfield(address):
    # bitfield of features supported by me (see the wiki).
    bitfield = 0
    # send ack
    if not shared.safeConfigGetBoolean(address, "dontsendack"):
        bitfield |= shared.BITFIELD_DOESACK
    return struct.pack(">I", bitfield)
开发者ID:Basti1993,项目名称:PyBitmessage,代码行数:7,代码来源:protocol.py


示例13: run

    def run(self):
        # If there is a trusted peer then we don't want to accept
        # incoming connections so we'll just abandon the thread
        if shared.trustedPeer:
            return

        while shared.safeConfigGetBoolean('bitmessagesettings', 'dontconnect') and shared.shutdown == 0:
            self.stop.wait(1)
        helper_bootstrap.dns()
        # We typically don't want to accept incoming connections if the user is using a
        # SOCKS proxy, unless they have configured otherwise. If they eventually select
        # proxy 'none' or configure SOCKS listening then this will start listening for
        # connections.
        while shared.config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS' and not shared.config.getboolean('bitmessagesettings', 'sockslisten') and shared.shutdown == 0:
            self.stop.wait(5)

        logger.info('Listening for incoming connections.')

        # First try listening on an IPv6 socket. This should also be
        # able to accept connections on IPv4. If that's not available
        # we'll fall back to IPv4-only.
        try:
            sock = self._createListenSocket(socket.AF_INET6)
        except socket.error, e:
            if (isinstance(e.args, tuple) and
                e.args[0] in (errno.EAFNOSUPPORT,
                              errno.EPFNOSUPPORT,
                              errno.ENOPROTOOPT)):
                sock = self._createListenSocket(socket.AF_INET)
            else:
                raise
开发者ID:vinctux,项目名称:PyBitmessage,代码行数:31,代码来源:class_singleListener.py


示例14: run

    def run(self):
        while shared.safeConfigGetBoolean('bitmessagesettings', 'dontconnect'):
            time.sleep(1)
        helper_bootstrap.dns()
        # We typically don't want to accept incoming connections if the user is using a
        # SOCKS proxy, unless they have configured otherwise. If they eventually select
        # proxy 'none' or configure SOCKS listening then this will start listening for
        # connections.
        while shared.config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS' and not shared.config.getboolean('bitmessagesettings', 'sockslisten'):
            time.sleep(5)

        logger.info('Listening for incoming connections.')

        HOST = ''  # Symbolic name meaning all available interfaces
        PORT = shared.config.getint('bitmessagesettings', 'port')
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        # This option apparently avoids the TIME_WAIT state so that we can
        # rebind faster
        sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        sock.bind((HOST, PORT))
        sock.listen(2)

        while True:
            # We typically don't want to accept incoming connections if the user is using a
            # SOCKS proxy, unless they have configured otherwise. If they eventually select
            # proxy 'none' or configure SOCKS listening then this will start listening for
            # connections.
            while shared.config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS' and not shared.config.getboolean('bitmessagesettings', 'sockslisten'):
                time.sleep(10)
            while len(shared.connectedHostsList) > 220:
                logger.info('We are connected to too many people. Not accepting further incoming connections for ten seconds.')

                time.sleep(10)
            a, (HOST, PORT) = sock.accept()

            # The following code will, unfortunately, block an incoming
            # connection if someone else on the same LAN is already connected
            # because the two computers will share the same external IP. This
            # is here to prevent connection flooding.
            while HOST in shared.connectedHostsList:
                logger.info('We are already connected to %s . Ignoring connection.'%HOST)

                a.close()
                a, (HOST, PORT) = sock.accept()
            someObjectsOfWhichThisRemoteNodeIsAlreadyAware = {} # This is not necessairly a complete list; we clear it from time to time to save memory.
            a.settimeout(20)

            sd = sendDataThread()
            sd.setup(
                a, HOST, PORT, -1, someObjectsOfWhichThisRemoteNodeIsAlreadyAware)
            sd.start()

            rd = receiveDataThread()
            rd.daemon = True  # close the main program even if there are threads left
            rd.setup(
                a, HOST, PORT, -1, someObjectsOfWhichThisRemoteNodeIsAlreadyAware, self.selfInitiatedConnections)
            rd.start()

            logger.info('%s connected to %s during INCOMING request.'%(self,HOST))
开发者ID:merlink01,项目名称:PyBitmessage,代码行数:59,代码来源:class_singleListener.py


示例15: get_api_address

 def get_api_address():
     if not shared.safeConfigGetBoolean('bitmessagesettings', 'apienabled'):
         return None
     address = shared.config.get('bitmessagesettings', 'apiinterface')
     port = shared.config.getint('bitmessagesettings', 'apiport')
     return {
         'address': address,
         'port': port
     }
开发者ID:boisei0,项目名称:PyBitmessage,代码行数:9,代码来源:bitmessagemain.py


示例16: getMyAddresses

def getMyAddresses():
    """
    Generator which returns all your addresses.
    """
    configSections = shared.config.sections()
    for addressInKeysFile in configSections:
        if addressInKeysFile != 'bitmessagesettings' and not shared.safeConfigGetBoolean(addressInKeysFile, 'chan'):
            isEnabled = shared.config.getboolean(
                addressInKeysFile, 'enabled')  # I realize that this is poor programming practice but I don't care. It's easier for others to read.
            if isEnabled:
                yield addressInKeysFile
开发者ID:jesperborgstrup,项目名称:PyBitmessageVote,代码行数:11,代码来源:helper_keys.py


示例17: run

def run(target, initialHash):
    target = int(target)
    if shared.safeConfigGetBoolean('bitmessagesettings', 'opencl') and openclpow.has_opencl():
#        trialvalue1, nonce1 = _doGPUPoW(target, initialHash)
#        trialvalue, nonce = _doFastPoW(target, initialHash)
#        print "GPU: %s, %s" % (trialvalue1, nonce1)
#        print "Fast: %s, %s" % (trialvalue, nonce)
#        return [trialvalue, nonce]
        return _doGPUPoW(target, initialHash)
    elif frozen == "macosx_app" or not frozen:
        return _doFastPoW(target, initialHash)
    else:
        return _doSafePoW(target, initialHash)
开发者ID:N0U,项目名称:PyBitmessage,代码行数:13,代码来源:proofofwork.py


示例18: createSupportMessage

def createSupportMessage(myapp):
    checkAddressBook(myapp)
    address = createAddressIfNeeded(myapp)
    if shared.shutdown:
        return

    myapp.ui.lineEditSubject.setText(str(QtGui.QApplication.translate("Support", SUPPORT_SUBJECT)))
    addrIndex = myapp.ui.comboBoxSendFrom.findData(address, QtCore.Qt.UserRole, QtCore.Qt.MatchFixedString | QtCore.Qt.MatchCaseSensitive)
    if addrIndex == -1: # something is very wrong
        return
    myapp.ui.comboBoxSendFrom.setCurrentIndex(addrIndex)
    myapp.ui.lineEditTo.setText(SUPPORT_ADDRESS)
    
    version = shared.softwareVersion
    os = sys.platform
    if os == "win32":
        windowsversion = sys.getwindowsversion()
        os = "Windows " + str(windowsversion[0]) + "." + str(windowsversion[1])
    else:
        try:
            from os import uname
            unixversion = uname()
            os = unixversion[0] + " " + unixversion[2]
        except:
            pass
    architecture = "32" if ctypes.sizeof(ctypes.c_voidp) == 4 else "64"
    frozen = "N/A"
    if shared.frozen:
        frozen = shared.frozen
    portablemode = "True" if shared.appdata == shared.lookupExeFolder() else "False"
    cpow = "True" if bmpow else "False"
    #cpow = QtGui.QApplication.translate("Support", cpow)
    openclpow = "True" if shared.safeConfigGetBoolean('bitmessagesettings', 'opencl') and has_opencl() else "False"
    #openclpow = QtGui.QApplication.translate("Support", openclpow)
    locale = getTranslationLanguage()
    try:
        socks = shared.config.get('bitmessagesettings', 'socksproxytype')
    except:
        socks = "N/A"
    try:
        upnp = shared.config.get('bitmessagesettings', 'upnp')
    except:
        upnp = "N/A"
    connectedhosts = len(shared.connectedHostsList)

    myapp.ui.textEditMessage.setText(str(QtGui.QApplication.translate("Support", SUPPORT_MESSAGE)).format(version, os, architecture, frozen, portablemode, cpow, openclpow, locale, socks, upnp, connectedhosts))

    # single msg tab
    myapp.ui.tabWidgetSend.setCurrentIndex(0)
    # send tab
    myapp.ui.tabWidget.setCurrentIndex(1)
开发者ID:Basti1993,项目名称:PyBitmessage,代码行数:51,代码来源:support.py


示例19: translateText

def translateText(context, text):
    if not shared.safeConfigGetBoolean('bitmessagesettings', 'daemon'):
        try:
            from PyQt4 import QtCore, QtGui
        except Exception as err:
            print 'PyBitmessage requires PyQt unless you want to run it as a daemon and interact with it using the API. You can download PyQt from http://www.riverbankcomputing.com/software/pyqt/download   or by searching Google for \'PyQt Download\'. If you want to run in daemon mode, see https://bitmessage.org/wiki/Daemon'
            print 'Error message:', err
            os._exit(0)
        return QtGui.QApplication.translate(context, text)
    else:
        if '%' in text:
            return translateClass(context, text.replace('%','',1))
        else:
            return text
开发者ID:AllenWang,项目名称:PyBitmessage,代码行数:14,代码来源:tr.py


示例20: processgetpubkey

    def processgetpubkey(self, data):
        readPosition = 20  # bypass the nonce, time, and object type
        requestedAddressVersionNumber, addressVersionLength = decodeVarint(
            data[readPosition:readPosition + 10])
        readPosition += addressVersionLength
        streamNumber, streamNumberLength = decodeVarint(
            data[readPosition:readPosition + 10])
        readPosition += streamNumberLength

        myAddress = ''
        if requestedAddressVersionNumber <= 3 :
            requestedHash = data[readPosition:readPosition + 20]
            if len(requestedHash) != 20:
                return
            if requestedHash in shared.myAddressesByHash:  # if this address hash is one of mine
                myAddress = shared.myAddressesByHash[requestedHash]
        elif requestedAddressVersionNumber >= 4:
            requestedTag = data[readPosition:readPosition + 32]
            if len(requestedTag) != 32:
                return
            if requestedTag in shared.myAddressesByTag:
                myAddress = shared.myAddressesByTag[requestedTag]

        if myAddress == '':
            return

        if decodeAddress(myAddress)[1] != requestedAddressVersionNumber:
            return
        if decodeAddress(myAddress)[2] != streamNumber:
            return
        if shared.safeConfigGetBoolean(myAddress, 'chan'):
            return
        try:
            lastPubkeySendTime = int(shared.config.get(
                myAddress, 'lastpubkeysendtime'))
        except:
            lastPubkeySendTime = 0
        if lastPubkeySendTime > time.time() - 2419200:  # If the last time we sent our pubkey was more recent than 28 days ago...
            return
        if requestedAddressVersionNumber == 2:
            shared.workerQueue.put((
                'doPOWForMyV2Pubkey', requestedHash))
        elif requestedAddressVersionNumber == 3:
            shared.workerQueue.put((
                'sendOutOrStoreMyV3Pubkey', requestedHash))
        elif requestedAddressVersionNumber == 4:
            shared.workerQueue.put((
                'sendOutOrStoreMyV4Pubkey', myAddress))
开发者ID:onejob6800,项目名称:minibm,代码行数:48,代码来源:class_objectProcessor.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python shared.try_delete函数代码示例发布时间:2022-05-27
下一篇:
Python shared.run_peru_command函数代码示例发布时间: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