Swap print statements for logging statements #440
|
@ -768,7 +768,8 @@ if shared.useVeryEasyProofOfWorkForTesting:
|
||||||
shared.networkDefaultPayloadLengthExtraBytes = int(
|
shared.networkDefaultPayloadLengthExtraBytes = int(
|
||||||
shared.networkDefaultPayloadLengthExtraBytes / 7000)
|
shared.networkDefaultPayloadLengthExtraBytes / 7000)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
class Main:
|
||||||
|
def start(self, deamon=False):
|
||||||
# is the application already running? If yes then exit.
|
# is the application already running? If yes then exit.
|
||||||
thisapp = singleton.singleinstance()
|
thisapp = singleton.singleinstance()
|
||||||
|
|
||||||
|
@ -806,7 +807,8 @@ if __name__ == "__main__":
|
||||||
except:
|
except:
|
||||||
apiNotifyPath = ''
|
apiNotifyPath = ''
|
||||||
if apiNotifyPath != '':
|
if apiNotifyPath != '':
|
||||||
logger.debug('Trying to call %s', apiNotifyPath)
|
with shared.printLock:
|
||||||
|
print 'Trying to call', apiNotifyPath
|
||||||
|
|
||||||
call([apiNotifyPath, "startingUp"])
|
call([apiNotifyPath, "startingUp"])
|
||||||
singleAPIThread = singleAPI()
|
singleAPIThread = singleAPI()
|
||||||
|
@ -820,23 +822,47 @@ if __name__ == "__main__":
|
||||||
singleListenerThread.daemon = True # close the main program even if there are threads left
|
singleListenerThread.daemon = True # close the main program even if there are threads left
|
||||||
singleListenerThread.start()
|
singleListenerThread.start()
|
||||||
|
|
||||||
if not shared.safeConfigGetBoolean('bitmessagesettings', 'daemon'):
|
if deamon == False and shared.safeConfigGetBoolean('bitmessagesettings', 'daemon') == False:
|
||||||
try:
|
try:
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.error('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 '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'
|
||||||
logger.error('Error message: %s', err)
|
print 'Error message:', err
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
|
|
||||||
import bitmessageqt
|
import bitmessageqt
|
||||||
bitmessageqt.run()
|
bitmessageqt.run()
|
||||||
else:
|
else:
|
||||||
shared.config.remove_option('bitmessagesettings', 'dontconnect')
|
shared.config.remove_option('bitmessagesettings', 'dontconnect')
|
||||||
logger.info('Running as a daemon. You can use Ctrl+C to exit.')
|
|
||||||
|
|
||||||
|
if deamon:
|
||||||
|
with shared.printLock:
|
||||||
|
print 'Running as a daemon. The main program should exit this thread.'
|
||||||
|
else:
|
||||||
|
with shared.printLock:
|
||||||
|
print 'Running as a daemon. You can use Ctrl+C to exit.'
|
||||||
while True:
|
while True:
|
||||||
time.sleep(20)
|
time.sleep(20)
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
with shared.printLock:
|
||||||
|
print 'Stopping Bitmessage Deamon.'
|
||||||
|
shared.doCleanShutdown()
|
||||||
|
|
||||||
|
|
||||||
|
def getApiAddress(self):
|
||||||
|
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}
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
mainprogram = Main()
|
||||||
|
mainprogram.start()
|
||||||
|
|
||||||
|
|
||||||
# So far, the creation of and management of the Bitmessage protocol and this
|
# So far, the creation of and management of the Bitmessage protocol and this
|
||||||
# client is a one-man operation. Bitcoin tips are quite appreciated.
|
# client is a one-man operation. Bitcoin tips are quite appreciated.
|
||||||
# 1H5XaDA6fYENLbknwZyjiYXYPQaFjjLX2u
|
# 1H5XaDA6fYENLbknwZyjiYXYPQaFjjLX2u
|
||||||
|
|
|
@ -346,6 +346,19 @@ def checkSensitiveFilePermissions(filename):
|
||||||
# Windows systems.
|
# Windows systems.
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
|
# Skip known problems for non-Win32 filesystems without POSIX permissions.
|
||||||
|
import subprocess
|
||||||
|
fstype = subprocess.check_output('stat -f -c "%%T" %s' % (filename),
|
||||||
|
shell=True,
|
||||||
|
stderr=subprocess.STDOUT)
|
||||||
|
if 'fuseblk' in fstype:
|
||||||
|
logger.info('Skipping file permissions check for %s. Filesystem fuseblk detected.',
|
||||||
|
filename)
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
# Swallow exception here, but we might run into trouble later!
|
||||||
|
logger.error('Could not determine filesystem type.', filename)
|
||||||
present_permissions = os.stat(filename)[0]
|
present_permissions = os.stat(filename)[0]
|
||||||
disallowed_permissions = stat.S_IRWXG | stat.S_IRWXO
|
disallowed_permissions = stat.S_IRWXG | stat.S_IRWXO
|
||||||
return present_permissions & disallowed_permissions == 0
|
return present_permissions & disallowed_permissions == 0
|
||||||
|
|
Reference in New Issue
Block a user