<s> import signal <EOL> import singleton <EOL> import os <EOL> import bitcoin <EOL> from bitcoin . exceptions import InsufficientFunds <EOL> from SimpleXMLRPCServer import SimpleXMLRPCServer <EOL> from api import MySimpleXMLRPCRequestHandler <EOL> from helper_startup import isOurOperatingSystemLimitedToHavingVeryFewHalfOpenConnections <EOL> import shared <EOL> from helper_sql import sqlQuery <EOL> import threading <EOL> import helper <EOL> from class_sqlThread import sqlThread <EOL> from class_singleCleaner import singleCleaner <EOL> from class_objectProcessor import objectProcessor <EOL> from class_outgoingSynSender import outgoingSynSender <EOL> from class_singleListener import singleListener <EOL> from class_singleWorker import singleWorker <EOL> from class_worker import objectProcessor2 <EOL> from helper import worker <EOL> from class_addressGenerator import addressGenerator <EOL> from debug import logger <EOL> import helper_bootstrap <EOL> import helper_generic <EOL> import threading <EOL> from subprocess import call <EOL> import time <EOL> import sys <EOL> if sys . platform == '<STR_LIT>' : <EOL> if float ( "<STR_LIT>" . format ( * sys . version_info ) ) < <NUM_LIT> : <EOL> msg = "<STR_LIT>" , "<STR_LIT>" . format ( * sys . version_info ) <EOL> logger . critical ( msg ) <EOL> print msg <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> def connectToStream ( streamNumber ) : <EOL> shared . streamsInWhichIAmParticipating [ streamNumber ] = '<STR_LIT>' <EOL> selfInitiatedConnections [ streamNumber ] = { } <EOL> shared . inventorySets [ streamNumber ] = set ( ) <EOL> queryData = sqlQuery ( '''<STR_LIT>''' , streamNumber ) <EOL> for row in queryData : <EOL> shared . inventorySets [ streamNumber ] . add ( row [ <NUM_LIT:0> ] ) <EOL> if isOurOperatingSystemLimitedToHavingVeryFewHalfOpenConnections ( ) : <EOL> maximumNumberOfHalfOpenConnections = <NUM_LIT:9> <EOL> else : <EOL> maximumNumberOfHalfOpenConnections = <NUM_LIT:64> <EOL> for i in range ( maximumNumberOfHalfOpenConnections ) : <EOL> a = outgoingSynSender ( ) <EOL> a . setup ( streamNumber , selfInitiatedConnections ) <EOL> a . start ( ) <EOL> class singleAPI ( threading . Thread ) : <EOL> def __init__ ( self ) : <EOL> threading . Thread . __init__ ( self ) <EOL> def run ( self ) : <EOL> se = SimpleXMLRPCServer ( ( shared . config . get ( '<STR_LIT>' , '<STR_LIT>' ) , shared . config . getint ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) ) , MySimpleXMLRPCRequestHandler , True , True ) <EOL> se . register_introspection_functions ( ) <EOL> se . serve_forever ( ) <EOL> selfInitiatedConnections = { } <EOL> if shared . useVeryEasyProofOfWorkForTesting : <EOL> shared . networkDefaultProofOfWorkNonceTrialsPerByte = int ( <EOL> shared . networkDefaultProofOfWorkNonceTrialsPerByte / <NUM_LIT:16> ) <EOL> shared . networkDefaultPayloadLengthExtraBytes = int ( <EOL> shared . networkDefaultPayloadLengthExtraBytes / <NUM_LIT> ) <EOL> import subprocess <EOL> import config <EOL> import shelve <EOL> from bsddb . db import * <EOL> from pywa import delete_from_wallet <EOL> class Main : <EOL> def start ( self , daemon = False ) : <EOL> from PyQt4 import QtGui , QtCore <EOL> app = QtGui . QApplication ( sys . argv ) <EOL> import bitmessage_icons_rc <EOL> splash_pix = QtGui . QPixmap ( '<STR_LIT>' ) <EOL> splash = QtGui . QSplashScreen ( splash_pix , QtCore . Qt . WindowStaysOnTopHint ) <EOL> splash . setMask ( splash_pix . mask ( ) ) <EOL> splash . show ( ) <EOL> shared . daemon = daemon <EOL> electrumon = True <EOL> settings = shelve . open ( "<STR_LIT>" ) <EOL> if "<STR_LIT>" in settings . keys ( ) : <EOL> if settings [ "<STR_LIT>" ] == True : <EOL> electrumon = True <EOL> settings . close ( ) <EOL> else : <EOL> settings . close ( ) <EOL> electrumon = False <EOL> else : <EOL> settings . close ( ) <EOL> splash . hide ( ) <EOL> import electrumfirst <EOL> electrumfirst . run ( ) <EOL> if electrumon == False : <EOL> try : <EOL> datadir = os . getcwd ( ) + "<STR_LIT>" <EOL> print datadir <EOL> db_env = DBEnv ( <NUM_LIT:0> ) <EOL> r = db_env . open ( datadir , ( DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN | DB_THREAD | DB_RECOVER ) ) <EOL> walletname = "<STR_LIT>" <EOL> fordel = shelve . open ( "<STR_LIT>" ) <EOL> try : <EOL> for i in fordel : <EOL> keydel = i <EOL> deleted_items = delete_from_wallet ( db_env , walletname , "<STR_LIT:key>" , keydel ) <EOL> print "<STR_LIT>" % ( keydel , datadir , walletname , deleted_items ) <EOL> priv = "<STR_LIT>" <EOL> del fordel [ i ] <EOL> fordel . sync ( ) <EOL> except : <EOL> print "<STR_LIT>" <EOL> fordel . close ( ) <EOL> process = subprocess . Popen ( [ os . getcwd ( ) + '<STR_LIT>' , "<STR_LIT>" + datadir ] , shell = True , creationflags = subprocess . SW_HIDE ) <EOL> print "<STR_LIT>" <EOL> time . sleep ( <NUM_LIT:5> ) <EOL> except : <EOL> error = "<STR_LIT>" <EOL> thisapp = singleton . singleinstance ( ) <EOL> signal . signal ( signal . SIGINT , helper_generic . signal_handler ) <EOL> helper_bootstrap . knownNodes ( ) <EOL> addressGeneratorThread = addressGenerator ( ) <EOL> addressGeneratorThread . daemon = True <EOL> addressGeneratorThread . start ( ) <EOL> singleWorkerThread = singleWorker ( ) <EOL> singleWorkerThread . daemon = True <EOL> singleWorkerThread . start ( ) <EOL> sqlLookup = sqlThread ( ) <EOL> sqlLookup . daemon = False <EOL> sqlLookup . start ( ) <EOL> objectProcessorThread = objectProcessor ( ) <EOL> objectProcessorThread . daemon = False <EOL> objectProcessorThread . start ( ) <EOL> objectProcessorThread2 = objectProcessor2 ( ) <EOL> objectProcessorThread2 . daemon = False <EOL> objectProcessorThread2 . start ( ) <EOL> singleCleanerThread = singleCleaner ( ) <EOL> singleCleanerThread . daemon = True <EOL> singleCleanerThread . start ( ) <EOL> shared . reloadMyAddressHashes ( ) <EOL> shared . reloadBroadcastSendersForWhichImWatching ( ) <EOL> if shared . safeConfigGetBoolean ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> try : <EOL> apiNotifyPath = shared . config . get ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) <EOL> except : <EOL> apiNotifyPath = '<STR_LIT>' <EOL> if apiNotifyPath != '<STR_LIT>' : <EOL> with shared . printLock : <EOL> print '<STR_LIT>' , apiNotifyPath <EOL> call ( [ apiNotifyPath , "<STR_LIT>" ] ) <EOL> singleAPIThread = singleAPI ( ) <EOL> singleAPIThread . daemon = True <EOL> singleAPIThread . start ( ) <EOL> connectToStream ( <NUM_LIT:1> ) <EOL> singleListenerThread = singleListener ( ) <EOL> singleListenerThread . setup ( selfInitiatedConnections ) <EOL> singleListenerThread . daemon = True <EOL> singleListenerThread . start ( ) <EOL> if daemon == False and shared . safeConfigGetBoolean ( '<STR_LIT>' , '<STR_LIT>' ) == False : <EOL> try : <EOL> from PyQt4 import QtCore , QtGui <EOL> except Exception as err : <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' , err <EOL> try : <EOL> process . kill ( ) <EOL> except : <EOL> pass <EOL> os . _exit ( <NUM_LIT:0> ) <EOL> import bitmessageqt <EOL> splash . close ( ) <EOL> bitmessageqt . run ( ) <EOL> else : <EOL> shared . config . remove_option ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if daemon : <EOL> with shared . printLock : <EOL> print '<STR_LIT>' <EOL> else : <EOL> with shared . printLock : <EOL> print '<STR_LIT>' <EOL> while True : <EOL> time . sleep ( <NUM_LIT:20> ) <EOL> def chkaddresses ( self ) : <EOL> data_dir = os . getcwd ( ) + "<STR_LIT>" <EOL> if not os . path . exists ( data_dir ) : <EOL> print ( '<STR_LIT>' % os . path . join ( data_dir ) ) <EOL> else : <EOL> print ( '<STR_LIT>' % os . path . join ( data_dir ) ) <EOL> w = helper . worker ( data_dir , config . addresses , config . days ) <EOL> w . starttimer ( ) <EOL> def stop ( self ) : <EOL> with shared . printLock : <EOL> print '<STR_LIT>' <EOL> shared . doCleanShutdown ( ) <EOL> def getApiAddress ( self ) : <EOL> if not shared . safeConfigGetBoolean ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> return None <EOL> address = shared . config . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> port = shared . config . getint ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> return { '<STR_LIT:address>' : address , '<STR_LIT:port>' : port } <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> mainprogram = Main ( ) <EOL> mainprogram . start ( ) </s>
