本文整理汇总了Python中shared.safeConfigGetBoolean函数的典型用法代码示例。如果您正苦于以下问题:Python safeConfigGetBoolean函数的具体用法?Python safeConfigGetBoolean怎么用?Python safeConfigGetBoolean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了safeConfigGetBoolean函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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"
示例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
示例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
示例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")
示例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
示例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
示例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
示例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
示例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)
示例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.')
示例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)
示例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
示例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))
示例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
}