1010# The software version variable is now held in shared.py
1111
1212#import ctypes
13+ try :
14+ from gevent import monkey
15+ monkey .patch_all ()
16+ except ImportError as ex :
17+ print "cannot find gevent"
18+
1319import signal # Used to capture a Ctrl-C keypress so that Bitmessage can shutdown gracefully.
1420# The next 3 are used for the API
1521from SimpleXMLRPCServer import *
2935import helper_startup
3036import helper_bootstrap
3137
38+ import sys
39+ if sys .platform == 'darwin' :
40+ if float ( "{1}.{2}" .format (* sys .version_info ) ) < 7.5 :
41+ print "You should use python 2.7.5 or greater."
42+ print "Your version: {0}.{1}.{2}" .format (* sys .version_info )
43+ sys .exit (0 )
44+
3245def connectToStream (streamNumber ):
3346 selfInitiatedConnections [streamNumber ] = {}
3447 if sys .platform [0 :3 ] == 'win' :
@@ -459,9 +472,9 @@ def _dispatch(self, method, params):
459472 status , addressVersionNumber , streamNumber , toRipe = decodeAddress (
460473 toAddress )
461474 if status != 'success' :
462- shared .printLock . acquire ()
463- print 'API Error 0007: Could not decode address:' , toAddress , ':' , status
464- shared . printLock . release ()
475+ with shared .printLock :
476+ print 'API Error 0007: Could not decode address:' , toAddress , ':' , status
477+
465478 if status == 'checksumfailed' :
466479 return 'API Error 0008: Checksum failed for address: ' + toAddress
467480 if status == 'invalidcharacters' :
@@ -476,9 +489,9 @@ def _dispatch(self, method, params):
476489 status , addressVersionNumber , streamNumber , fromRipe = decodeAddress (
477490 fromAddress )
478491 if status != 'success' :
479- shared .printLock . acquire ()
480- print 'API Error 0007: Could not decode address:' , fromAddress , ':' , status
481- shared . printLock . release ()
492+ with shared .printLock :
493+ print 'API Error 0007: Could not decode address:' , fromAddress , ':' , status
494+
482495 if status == 'checksumfailed' :
483496 return 'API Error 0008: Checksum failed for address: ' + fromAddress
484497 if status == 'invalidcharacters' :
@@ -541,9 +554,9 @@ def _dispatch(self, method, params):
541554 status , addressVersionNumber , streamNumber , fromRipe = decodeAddress (
542555 fromAddress )
543556 if status != 'success' :
544- shared .printLock . acquire ()
545- print 'API Error 0007: Could not decode address:' , fromAddress , ':' , status
546- shared . printLock . release ()
557+ with shared .printLock :
558+ print 'API Error 0007: Could not decode address:' , fromAddress , ':' , status
559+
547560 if status == 'checksumfailed' :
548561 return 'API Error 0008: Checksum failed for address: ' + fromAddress
549562 if status == 'invalidcharacters' :
@@ -612,9 +625,9 @@ def _dispatch(self, method, params):
612625 status , addressVersionNumber , streamNumber , toRipe = decodeAddress (
613626 address )
614627 if status != 'success' :
615- shared .printLock . acquire ()
616- print 'API Error 0007: Could not decode address:' , address , ':' , status
617- shared . printLock . release ()
628+ with shared .printLock :
629+ print 'API Error 0007: Could not decode address:' , address , ':' , status
630+
618631 if status == 'checksumfailed' :
619632 return 'API Error 0008: Checksum failed for address: ' + address
620633 if status == 'invalidcharacters' :
@@ -741,9 +754,9 @@ def run(self):
741754 except :
742755 apiNotifyPath = ''
743756 if apiNotifyPath != '' :
744- shared .printLock . acquire ()
745- print 'Trying to call' , apiNotifyPath
746- shared . printLock . release ()
757+ with shared .printLock :
758+ print 'Trying to call' , apiNotifyPath
759+
747760 call ([apiNotifyPath , "startingUp" ])
748761 singleAPIThread = singleAPI ()
749762 singleAPIThread .daemon = True # close the main program even if there are threads left
@@ -774,9 +787,9 @@ def run(self):
774787 import bitmessageqt
775788 bitmessageqt .run ()
776789 else :
777- shared .printLock . acquire ()
778- print 'Running as a daemon. You can use Ctrl+C to exit.'
779- shared . printLock . release ()
790+ with shared .printLock :
791+ print 'Running as a daemon. You can use Ctrl+C to exit.'
792+
780793 while True :
781794 time .sleep (20 )
782795
0 commit comments